diff options
Diffstat (limited to 'apps/web-shared')
| -rw-r--r-- | apps/web-shared/src/components/blowout-toolbelt.svelte | 20 | ||||
| -rw-r--r-- | apps/web-shared/src/components/locale-switcher.svelte | 2 | ||||
| -rw-r--r-- | apps/web-shared/src/components/theme-switcher.svelte | 2 |
3 files changed, 21 insertions, 3 deletions
diff --git a/apps/web-shared/src/components/blowout-toolbelt.svelte b/apps/web-shared/src/components/blowout-toolbelt.svelte index 2927d70..b83048c 100644 --- a/apps/web-shared/src/components/blowout-toolbelt.svelte +++ b/apps/web-shared/src/components/blowout-toolbelt.svelte @@ -1,4 +1,5 @@ <script> + import { onMount } from "svelte"; import ThemeSwitcher from "./theme-switcher.svelte"; import ThemeSwitcherIcon from "./theme-switcher-icon.svelte"; import LocaleSwitcher from "./locale-switcher.svelte"; @@ -15,6 +16,19 @@ show: false, selection: "system" }; + + onMount(() => { + document.addEventListener("keydown", (e) => { + if (e.code === "Escape") { + expanded = false; + } + }); + document.addEventListener("click", (e) => { + if (e.target.closest("[data-blowout-toolbelt-element]") === null) { + expanded = false; + } + }); + }); </script> <style> .blowout { @@ -25,21 +39,25 @@ right: 0 !important; } </style> -<aside class="blowout position-fixed bg-light inner-glow shadow-xs padding-xxs bottom-50% right-0 z-index-popover {expanded ? 'expanded' : ''}"> +<aside class="blowout position-fixed bg-light inner-glow shadow-xs padding-xxs bottom-50% right-0 z-index-popover {expanded ? 'expanded' : ''}" data-blowout-toolbelt-element> <LocaleSwitcher bind:show="{localeSwitcher.show}" glow="{false}" + data-blowout-toolbelt-element bind:selection="{localeSwitcher.selection}"/> <ThemeSwitcher bind:show="{themeSwitcher.show}" glow="{false}" + data-blowout-toolbelt-element bind:selection="{themeSwitcher.selection}"/> <div class="flex flex-row gap-sm justify-end"> {#if !expanded} <div class="flex ld-switch-btn" + data-blowout-toolbelt-element on:click={() => expanded = true}> <ChevronsLeftIcon/> </div> {:else} <div class="flex ld-switch-btn" + data-blowout-toolbelt-element on:click={() => expanded = false}> <ChevronsRightIcon/> </div> diff --git a/apps/web-shared/src/components/locale-switcher.svelte b/apps/web-shared/src/components/locale-switcher.svelte index 9cffc7a..5399247 100644 --- a/apps/web-shared/src/components/locale-switcher.svelte +++ b/apps/web-shared/src/components/locale-switcher.svelte @@ -17,7 +17,7 @@ onMount(() => { selection = get_cookie(CookieNames.locale); document.addEventListener("keydown", (e) => { - if (e.code === "Esc") { + if (e.code === "Escape") { show = false; } }); diff --git a/apps/web-shared/src/components/theme-switcher.svelte b/apps/web-shared/src/components/theme-switcher.svelte index 397bad4..6f86875 100644 --- a/apps/web-shared/src/components/theme-switcher.svelte +++ b/apps/web-shared/src/components/theme-switcher.svelte @@ -13,7 +13,7 @@ onMount(() => { selection = get_cookie(CookieNames.theme) as theme; document.addEventListener("keydown", (e) => { - if (e.code === "Esc") show = false; + if (e.code === "Escape") show = false; }); document.addEventListener("click", (e: any) => { if (e.target.closest("[data-theme-switcher-element]") === null) show = false; |
