-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
415 additions
and
280 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 0 additions & 105 deletions
105
packages/tui-components-svelte/src/lib/modal/ModalView.svelte
This file was deleted.
Oops, something went wrong.
98 changes: 0 additions & 98 deletions
98
packages/tui-components-svelte/src/lib/modal/ModalViewController.svelte
This file was deleted.
Oops, something went wrong.
72 changes: 72 additions & 0 deletions
72
packages/tui-components-svelte/src/lib/modals/ModalView.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<script lang="ts"> | ||
import { setContext, type Snippet } from "svelte" | ||
import type { Modal } from "." | ||
import { MODAL_KEY } from "./internal" | ||
const { | ||
id, | ||
topMost, | ||
bottomMost, | ||
close, | ||
children, | ||
}: { | ||
id: string | ||
topMost: boolean | ||
bottomMost: boolean | ||
close: () => void | ||
children: Snippet | ||
} = $props() | ||
/* ============================================================================================================== */ | ||
let _fullscreen = $state(false) | ||
let _escClose = $state(true) | ||
/* ============================================================================================================== */ | ||
const MODAL: Modal = { | ||
get id() { | ||
return id | ||
}, | ||
get topMost() { | ||
return topMost | ||
}, | ||
get bottomMost() { | ||
return bottomMost | ||
}, | ||
close, | ||
get fullscreen() { | ||
return _fullscreen | ||
}, | ||
set fullscreen(fullscreen) { | ||
_fullscreen = fullscreen | ||
}, | ||
get escClose() { | ||
return _escClose | ||
}, | ||
set escClose(escClose) { | ||
_escClose = escClose | ||
}, | ||
} | ||
setContext(MODAL_KEY, MODAL) | ||
/* ============================================================================================================== */ | ||
const onkeydown = (e: KeyboardEvent) => { | ||
if (topMost && _escClose && e.key === "Escape") { | ||
MODAL.close() | ||
} | ||
} | ||
</script> | ||
|
||
<svelte:window {onkeydown} /> | ||
|
||
<div | ||
id="ModalView" | ||
class="absolute inset-0 z-40 flex flex-col items-center justify-center | ||
bg-black/75 backdrop-blur-sm transition-opacity duration-300" | ||
style:display={topMost || _fullscreen ? "" : "none"} | ||
ontouchmove={(e) => e.stopPropagation()} | ||
> | ||
{@render children()} | ||
</div> |
Oops, something went wrong.