Skip to content

Commit 56e9cb5

Browse files
committed
fix: use modal for settings layout
1 parent f2cfd6a commit 56e9cb5

File tree

2 files changed

+20
-29
lines changed

2 files changed

+20
-29
lines changed

src/lib/components/Modal.svelte

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script lang="ts">
22
import { createEventDispatcher, onDestroy, onMount } from "svelte";
33
import { cubicOut } from "svelte/easing";
4-
import { fade } from "svelte/transition";
4+
import { fade, fly } from "svelte/transition";
55
import Portal from "./Portal.svelte";
66
import { browser } from "$app/environment";
77
@@ -63,7 +63,11 @@
6363
tabindex="-1"
6464
bind:this={modalEl}
6565
onkeydown={handleKeydown}
66-
class="max-h-[90dvh] overflow-y-auto overflow-x-hidden rounded-2xl bg-white shadow-2xl outline-none sm:-mt-10 {width}"
66+
in:fly={{ y: 100 }}
67+
class={[
68+
"max-h-[90dvh] overflow-y-auto overflow-x-hidden rounded-2xl bg-white shadow-2xl outline-none sm:-mt-10",
69+
width,
70+
]}
6771
>
6872
{@render children?.()}
6973
</div>

src/routes/settings/+layout.svelte

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
<script lang="ts">
22
import { base } from "$app/paths";
3-
import { clickOutside } from "$lib/actions/clickOutside";
43
import { afterNavigate, goto } from "$app/navigation";
54
import { useSettingsStore } from "$lib/stores/settings";
65
import CarbonCheckmark from "~icons/carbon/checkmark";
76
8-
import { fade, fly } from "svelte/transition";
7+
import Modal from "$lib/components/Modal.svelte";
98
interface Props {
109
children?: import("svelte").Snippet;
1110
}
@@ -23,29 +22,17 @@
2322
const settings = useSettingsStore();
2423
</script>
2524

26-
<div
27-
class="fixed inset-0 z-20 flex items-center justify-center bg-black/80 backdrop-blur-sm dark:bg-black/50"
28-
in:fade
25+
<Modal
26+
on:close={() => goto(previousPage)}
27+
width="!h-[95dvh] !w-[90dvw] overflow-hidden rounded-2xl bg-white shadow-2xl outline-none sm:!h-[85dvh] xl:!w-[1200px] 2xl:!h-[75dvh]"
2928
>
30-
<dialog
31-
in:fly={{ y: 100 }}
32-
open
33-
use:clickOutside={() => {
34-
if (window?.getSelection()?.toString()) {
35-
return;
36-
}
37-
goto(previousPage);
38-
}}
39-
class="h-[95dvh] w-[90dvw] overflow-hidden rounded-2xl bg-white shadow-2xl outline-none sm:h-[85dvh] xl:w-[1200px] 2xl:h-[75dvh]"
40-
>
41-
{@render children?.()}
42-
{#if $settings.recentlySaved}
43-
<div
44-
class="absolute bottom-4 right-4 m-2 flex items-center gap-1.5 rounded-full border border-gray-300 bg-gray-200 px-3 py-1 text-black"
45-
>
46-
<CarbonCheckmark class="text-green-500" />
47-
Saved
48-
</div>
49-
{/if}
50-
</dialog>
51-
</div>
29+
{@render children?.()}
30+
{#if $settings.recentlySaved}
31+
<div
32+
class="absolute bottom-4 right-4 m-2 flex items-center gap-1.5 rounded-full border border-gray-300 bg-gray-200 px-3 py-1 text-black"
33+
>
34+
<CarbonCheckmark class="text-green-500" />
35+
Saved
36+
</div>
37+
{/if}
38+
</Modal>

0 commit comments

Comments
 (0)