-
Notifications
You must be signed in to change notification settings - Fork 51
Add HTML demos for Bitcoin Connect's core web components #301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
32c8831
to
7b173af
Compare
Hi @rolznz, I've implemented the corrections you suggested. Apologies for the delay in pushing, I needed to set up a personal Lightning channel with Alby Hub to properly test everything, and also took some time to better understand how the codebase works. I ran into an issue with the const waitForModal = setInterval(() => {
const modal = document.querySelector('bc-modal');
if (modal) {
clearInterval(waitForModal);
modal.addEventListener('bc:onpaid', (e) => {
console.log('Payment succeeded!', e.detail);
setPaid({
preimage: e.detail.preimage,
});
});
}
}, 50); However, it seems to only capture internal payments made through the modal, not external ones. As a workaround, I implemented a polling mechanism that checks the invoice status every second to confirm when payment has been made. would love your thought on improving this or if there's a preferred approach. |
Hi @Dunsin-cyber how you do the polling looks good |
Alright, thank you. I’d take this PR out of draft status and move it to review. |
@rolznz , When you have a moment, could you please review this and let me know if there are any other demo I should make? |
…scripts and usage
Just pushed a tidy-up @rolznz |
a675475
to
732d30e
Compare
also @rolznz , I noticed that when using To improve modularity and make it easier to listen for events in scoped components or apps using Web Components (or frameworks like React/Vue), I suggest forwarding the event from const { setPaid } = launchPaymentModal({
onPaid: (response) => {
this._paid = true;
this.dispatchEvent(new CustomEvent('bc:onpaid', {
detail: response,
bubbles: true,
composed: true,
}));
},
invoice: this.invoice,
paymentMethods: this.paymentMethods,
}); This allows users to do: payButton.addEventListener('bc:onpaid', (e) => {
console.log('got paid', e.detail);
}); instead of having to rely on a global |
@Dunsin-cyber forwarding the events sounds good. Could you create a separate issue and PR for that? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tACK
alright. |
This PR addresses issue #300 by adding standalone pure HTML demos for the core Bitcoin Connect web components. The goal is to showcase how to use each component independently without any framework, making it easier for developers to understand and integrate them in basic setups.
✅ Added:
<bc-pay-button />
Each demo includes:
Proper usage of attributes like
invoice
,payment-methods
,title
, etc.Minimal styling and code for clarity
📂 Location:
All demos are added to the
demos/html/
directory.This structure allows easier future expansion and clearer documentation for developers using the package without build tools or frameworks.