web-player: unify primitive link/button rendering, add onEscape action and self-contained AccountMenu
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
import IconButton from '../primitives/IconButton.svelte';
|
||||
import { fade } from 'svelte/transition';
|
||||
import { pop } from '$lib/utils/transitions';
|
||||
import { onEscape } from '$lib/actions/onEscape';
|
||||
|
||||
interface Props {
|
||||
open: boolean;
|
||||
@@ -48,12 +49,7 @@
|
||||
}
|
||||
|
||||
function onWindowKeydown(event: KeyboardEvent) {
|
||||
if (!open) return;
|
||||
if (event.key === 'Escape') {
|
||||
onClose();
|
||||
return;
|
||||
}
|
||||
if (event.key !== 'Tab') return;
|
||||
if (!open || event.key !== 'Tab') return;
|
||||
const elements = focusableElements();
|
||||
if (elements.length === 0) return;
|
||||
const first = elements[0];
|
||||
@@ -79,6 +75,7 @@
|
||||
>
|
||||
<div
|
||||
bind:this={panel}
|
||||
use:onEscape={onClose}
|
||||
transition:pop={{ duration: 200 }}
|
||||
class="glass-panel max-h-[85dvh] w-full glow-drift overflow-y-auto {maxWidth} rounded-panel p-5 outline-none sm:p-6 {panelClass}"
|
||||
role="dialog"
|
||||
|
||||
Reference in New Issue
Block a user