diff options
| author | David Hill <[email protected]> | 2026-01-26 16:39:01 +0000 |
|---|---|---|
| committer | David Hill <[email protected]> | 2026-01-26 19:47:57 +0000 |
| commit | 92229b44f885b78d6c729d5d2e71ddbe096d2672 (patch) | |
| tree | cb3d57506d42b5c3776600dfaa2ba968f489cc9e /packages/ui/src/context | |
| parent | 0a572afd46ecdaaee3d411fe95f0ff9c26b8e1ab (diff) | |
| download | opencode-92229b44f885b78d6c729d5d2e71ddbe096d2672.tar.gz opencode-92229b44f885b78d6c729d5d2e71ddbe096d2672.zip | |
feat(ui): add optional transition animations to dialog
Diffstat (limited to 'packages/ui/src/context')
| -rw-r--r-- | packages/ui/src/context/dialog.tsx | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/packages/ui/src/context/dialog.tsx b/packages/ui/src/context/dialog.tsx index a3aafa0c7..4d03b218d 100644 --- a/packages/ui/src/context/dialog.tsx +++ b/packages/ui/src/context/dialog.tsx @@ -21,6 +21,7 @@ type Active = { dispose: () => void owner: Owner onClose?: () => void + setClosing: (closing: boolean) => void } const Context = createContext<ReturnType<typeof init>>() @@ -32,8 +33,11 @@ function init() { const current = active() if (!current) return current.onClose?.() - current.dispose() - setActive(undefined) + current.setClosing(true) + setTimeout(() => { + current.dispose() + setActive(undefined) + }, 100) } createEffect(() => { @@ -55,14 +59,17 @@ function init() { const id = Math.random().toString(36).slice(2) let dispose: (() => void) | undefined + let setClosing: ((closing: boolean) => void) | undefined const node = runWithOwner(owner, () => createRoot((d: () => void) => { dispose = d + const [closing, setClosingSignal] = createSignal(false) + setClosing = setClosingSignal return ( <Kobalte modal - open={true} + open={!closing()} onOpenChange={(open: boolean) => { if (open) return close() @@ -77,9 +84,9 @@ function init() { }), ) - if (!dispose) return + if (!dispose || !setClosing) return - setActive({ id, node, dispose, owner, onClose }) + setActive({ id, node, dispose, owner, onClose, setClosing }) } return { |
