diff --git a/package.json b/package.json index 44e0478..b1bb518 100644 --- a/package.json +++ b/package.json @@ -8,8 +8,8 @@ ], "scripts": { "dev": "vite", - "build": "tsc && vite build", - "build-app": "tsc && vite build --config vite.config.app.ts" + "build": "vite build", + "build-app": "vite build --config vite.config.app.ts" }, "devDependencies": { "@ark-ui/solid": "2.2.0", diff --git a/src/lib/WalletProviderSelector/components/CloseButton.tsx b/src/lib/WalletProviderSelector/components/CloseButton.tsx index 1b188a9..863f1ff 100644 --- a/src/lib/WalletProviderSelector/components/CloseButton.tsx +++ b/src/lib/WalletProviderSelector/components/CloseButton.tsx @@ -60,8 +60,8 @@ export function CloseButton(props: Props) { margin: "0", "border-radius": "50%", }} - onClick={props.onClose} - onKeyDown={handleKeyDown} + on:click={props.onClose} + on:keydown={handleKeyDown} > diff --git a/src/lib/WalletProviderSelector/components/SidePanelInstallWalletPrompt.tsx b/src/lib/WalletProviderSelector/components/SidePanelInstallWalletPrompt.tsx index 7c78532..fb5f27e 100644 --- a/src/lib/WalletProviderSelector/components/SidePanelInstallWalletPrompt.tsx +++ b/src/lib/WalletProviderSelector/components/SidePanelInstallWalletPrompt.tsx @@ -60,8 +60,8 @@ export function SidePanelInstallWalletPrompt(props: Props) { class="install-prompt-button" role="button" tabIndex={0} - onClick={handleClick} - onKeyDown={handleKeyDown} + on:click={handleClick} + on:keydown={handleKeyDown} style={{ ...buttonTextStyles, cursor: "pointer", diff --git a/src/lib/WalletProviderSelector/components/WalletProviderOption.tsx b/src/lib/WalletProviderSelector/components/WalletProviderOption.tsx index 38de7b0..e1e25f3 100644 --- a/src/lib/WalletProviderSelector/components/WalletProviderOption.tsx +++ b/src/lib/WalletProviderSelector/components/WalletProviderOption.tsx @@ -61,12 +61,12 @@ export function WalletProviderOption(props: Props) { outline: "none", "padding-top": "10px", }} - onClick={handleWalletSelected} - onKeyDown={handleKeyDown} - onMouseEnter={() => setIsMouseOver(true)} - onMouseLeave={() => setIsMouseOver(false)} - onFocus={() => setIsFocused(true)} - onBlur={() => setIsFocused(false)} + on:click={handleWalletSelected} + on:keydown={handleKeyDown} + on:mouseenter={() => setIsMouseOver(true)} + on:mouseleave={() => setIsMouseOver(false)} + on:focus={() => setIsFocused(true)} + on:blur={() => setIsFocused(false)} > (); + const [card, setCard] = createSignal(); const [sidePanel, setSidePanel] = createSignal(); /** @@ -75,6 +84,21 @@ export function WalletProviderSelector() { triggerFadeOut(); } + function handleEscKeyDown(e: KeyboardEvent) { + if (e.key === "Escape") { + handleCancelClick(); + } + } + + createEffect(() => { + if (isVisible()) { + window.addEventListener("keydown", handleEscKeyDown); + return; + } + + window.removeEventListener("keydown", handleEscKeyDown); + }); + function handleWalletSelected(walletId: string) { const option = options().find( (p) => p.id === walletId, @@ -158,16 +182,25 @@ export function WalletProviderSelector() { ); }); - function handleAsCancelled(e: Event) { - e.preventDefault(); - handleCancelClick(); - } - onCleanup(() => { window.removeEventListener(open, handleOpen); window.removeEventListener(close, handleClose); }); + function handleRootClick(e: MouseEvent) { + const target = e.target; + if (!target) return; + + const cardEl = card(); + if (!cardEl) return; + + if (cardEl.contains(target as Node)) { + return; + } + + handleCancelClick(); + } + return (
{ + console.log("Inside root keydown"); + }} > - root()?.getRootNode() as Node} - open={shouldRender()} - onEscapeKeyDown={handleAsCancelled} - onInteractOutside={handleAsCancelled} - onPointerDownOutside={handleAsCancelled} +
- -
-
- - +
+
- +
- - +
+
); diff --git a/src/lib/utils.ts b/src/lib/utils.ts index d471241..22763ac 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -30,6 +30,11 @@ export function loadSelector() { const element = document.createElement(elementName); element.id = elementId; + + // Ensure above all else + element.style.position = "relative"; + element.style.zIndex = "999999"; + document.body.appendChild(element); }