|
5 | 5 | import "@unocss/reset/tailwind.css" |
6 | 6 | import "virtual:uno.css" |
7 | 7 | import "../app.css" |
8 | | - import { activeColorHsl$, activeColor, colors$ } from "$lib/state/colors" |
| 8 | + import { activeColorHsl$, activeColor, colors$, setColors } from "$lib/state/colors" |
9 | 9 | import { cssVar } from "$lib/utils" |
10 | 10 | // import { Toaster } from "svelte-sonner" |
11 | 11 | import { type Okhsl } from "culori" |
12 | 12 | import Button from "$lib/components/ui/button/button.svelte" |
| 13 | + import Json from "$lib/icons/json.svelte" |
13 | 14 |
|
14 | 15 | function getActiveColorForeground(active: Okhsl) { |
15 | 16 | const lightness = active.l |
|
22 | 23 | } |
23 | 24 |
|
24 | 25 | let smallScreenDialog: HTMLDialogElement |
| 26 | + let restoreColorsDialog: HTMLDialogElement |
25 | 27 |
|
26 | 28 | $effect(() => { |
27 | 29 | if (window.innerWidth < 640) { |
28 | 30 | smallScreenDialog.showModal() |
29 | 31 | } |
| 32 | +
|
| 33 | + if (localStorage.getItem("colors")) { |
| 34 | + restoreColorsDialog.showModal() |
| 35 | + } |
30 | 36 | }) |
31 | 37 | </script> |
32 | 38 |
|
|
35 | 41 | </noscript> |
36 | 42 |
|
37 | 43 | <!-- <Toaster /> --> |
38 | | -<dialog bind:this={smallScreenDialog} class="bg-transparent"> |
39 | | - <div |
40 | | - class="border-5 flex flex-col gap-5 rounded-xl text-xl border-red px-6 py-3 bg-crust text-rosewater" |
41 | | - > |
42 | | - This app does not work properly on small screens. |
43 | | - |
44 | | - <form method="dialog"><Button onclick={() => smallScreenDialog.close()}>Okay</Button></form> |
45 | | - </div> |
46 | | -</dialog> |
47 | 44 |
|
48 | 45 | <div |
49 | 46 | class="min-h-screen flex flex-col max-h-screen h-screen font-sans" |
|
55 | 52 | </main> |
56 | 53 | </div> |
57 | 54 |
|
| 55 | +<dialog bind:this={restoreColorsDialog} class="bg-transparent border-none"> |
| 56 | + <div class="bg-base rounded-2xl border-2 border-subtext0 p-6 flex flex-col gap-6"> |
| 57 | + <h1 class="text-lg text-rosewater">Restore colors of last session?</h1> |
| 58 | + <div class="flex gap-6"> |
| 59 | + <form method="dialog"> |
| 60 | + <Button variant="link" onclick={() => restoreColorsDialog.close()}>Nah</Button> |
| 61 | + </form> |
| 62 | + <Button |
| 63 | + autofocus |
| 64 | + onclick={() => { |
| 65 | + const saved = localStorage.getItem("colors") |
| 66 | + if (saved) { |
| 67 | + const colors = JSON.parse(saved) |
| 68 | + setColors(colors) |
| 69 | + restoreColorsDialog.close() |
| 70 | + } |
| 71 | + restoreColorsDialog.close() |
| 72 | + }}>Restore colors</Button |
| 73 | + > |
| 74 | + </div> |
| 75 | + </div> |
| 76 | +</dialog> |
| 77 | + |
| 78 | +<dialog bind:this={smallScreenDialog} class="bg-transparent"> |
| 79 | + <div |
| 80 | + class="border-5 flex flex-col gap-5 rounded-xl text-xl border-red px-6 py-3 bg-crust text-rosewater" |
| 81 | + > |
| 82 | + This app does not work properly on small screens. |
| 83 | + |
| 84 | + <form method="dialog"><Button onclick={() => smallScreenDialog.close()}>Okay</Button></form> |
| 85 | + </div> |
| 86 | +</dialog> |
| 87 | + |
58 | 88 | <style> |
59 | 89 | ::backdrop { |
60 | 90 | background-color: theme("colors.crust"); |
|
0 commit comments