diff --git a/src/components/bc-balance.ts b/src/components/bc-balance.ts index 568282f..e483e13 100644 --- a/src/components/bc-balance.ts +++ b/src/components/bc-balance.ts @@ -49,6 +49,9 @@ export class Balance extends withTwind()(BitcoinConnectElement) { class="font-medium font-sans mr-2 flex justify-center items-center gap-0.5 ${classes[ 'text-brand-mixed' ]}" + role="status" + aria-live="${this._loading ? 'polite' : 'off'}" + aria-busy="${this._loading ? 'true' : 'false'}" > ${this._balance || 'Loading...'} `; @@ -109,6 +112,8 @@ export class Balance extends withTwind()(BitcoinConnectElement) { this._balance = '⚠️'; // FIXME: better error handling console.error(error); + } finally { + this._loading = false; } })(); } diff --git a/src/components/bc-button.ts b/src/components/bc-button.ts index 6c654e3..c9e3e6f 100644 --- a/src/components/bc-button.ts +++ b/src/components/bc-button.ts @@ -42,6 +42,9 @@ export class Button extends withTwind()(BitcoinConnectElement) {
@@ -81,7 +85,12 @@ export class CurrencySwitcher extends withTwind()(BitcoinConnectElement) { class="${selectedCurrency === currency.value ? 'bg-blue-500 text-white' : ''} flex items-center justify-center py-2 px-4 hover:text-white hover:bg-blue-500 rounded-lg hover:border-blue-500 cursor-pointer" + role="option" + aria-selected="${selectedCurrency === currency.value}" + tabindex="0" @click=${() => this._selectCurrency(currency.value)} + @keydown=${(event: KeyboardEvent) => + this._handleCurrencyKeydown(event, currency.value)} > ${currency.flag}
store.getState().pushRoute('/help')} + @keydown=${this._handleKeydownHelp} > ${helpIcon}
` @@ -39,7 +45,11 @@ export class ModalHeader extends withTwind()(BitcoinConnectElement) { ${this.closable ? html`
${crossIcon}
` @@ -54,6 +64,22 @@ export class ModalHeader extends withTwind()(BitcoinConnectElement) { private _handleClose() { this.dispatchEvent(new Event('onclose', {bubbles: true, composed: true})); } + + // Handle keyboard interactions for the close button + private _handleKeydownClose(event: KeyboardEvent) { + if (event.key === 'Enter' || event.key === ' ') { + event.preventDefault(); + this._handleClose(); + } + } + + // Handle keyboard interactions for the help button + private _handleKeydownHelp(event: KeyboardEvent) { + if (event.key === 'Enter' || event.key === ' ') { + event.preventDefault(); + store.getState().pushRoute('/help'); + } + } } declare global { diff --git a/src/components/bc-modal.ts b/src/components/bc-modal.ts index 2b08287..64c9b61 100644 --- a/src/components/bc-modal.ts +++ b/src/components/bc-modal.ts @@ -11,18 +11,26 @@ import {closeModal} from '../api'; @customElement('bc-modal') export class Modal extends withTwind()(BitcoinConnectElement) { override render() { - return html`