|
1 | 1 | import { MetaProvider, Title } from "@solidjs/meta"; |
2 | | -import { createSignal, Show } from "solid-js"; |
| 2 | +import { Show } from "solid-js"; |
| 3 | + |
| 4 | +import { createStorageSignal } from "~/storage"; |
3 | 5 |
|
4 | | -import { Button } from "~/components/ui/Button"; |
5 | 6 | import { ThemeToggle } from "~/components/ui/ThemeToggle"; |
| 7 | +import { Flex } from "~/components/ui/Flex"; |
| 8 | +import { IMEField } from "~/components/IMEField"; |
| 9 | +import { |
| 10 | + Dialog, |
| 11 | + DialogContent, |
| 12 | + DialogDescription, |
| 13 | + DialogHeader, |
| 14 | + DialogTitle, |
| 15 | + DialogTrigger, |
| 16 | +} from "~/components/ui/Dialog"; |
| 17 | +import { Label } from "~/components/ui/Label"; |
| 18 | +import { Switch, SwitchControl, SwitchThumb, SwitchLabel } from "~/components/ui/Switch"; |
6 | 19 |
|
7 | 20 | export default function Home() { |
8 | | - const [count, setCount] = createSignal(0); |
| 21 | + const [showTitle, setShowTitle] = createStorageSignal("setting-show-title", true); |
| 22 | + const [showExplanation, setShowExplanation] = createStorageSignal( |
| 23 | + "setting-show-explanation", |
| 24 | + true |
| 25 | + ); |
9 | 26 |
|
10 | 27 | return ( |
11 | | - <> |
12 | | - <MetaProvider> |
13 | | - <Title>IME</Title> |
14 | | - </MetaProvider> |
15 | | - |
16 | | - <div class="mx-auto flex max-w-2xl flex-col items-center space-y-6 p-4"> |
17 | | - <Show when={import.meta.env.VITE_ENABLE_COLOR_MODE === "true"}> |
18 | | - <ThemeToggle /> |
19 | | - </Show> |
20 | | - <Button onClick={() => setCount(count() + 1)} class="w-fit"> |
21 | | - Clicked {count()} times |
22 | | - </Button> |
23 | | - </div> |
24 | | - </> |
| 28 | + <MetaProvider> |
| 29 | + <Title>IME – An Input Method Editor that doesn't suck</Title> |
| 30 | + <Flex |
| 31 | + flexDirection="col" |
| 32 | + justifyContent="start" |
| 33 | + alignItems="center" |
| 34 | + class="bg-background text-foreground relative min-h-screen pt-[20vh]"> |
| 35 | + <Dialog> |
| 36 | + <Flex flexDirection="col" alignItems="center" class="w-full max-w-2xl gap-4 px-4"> |
| 37 | + <div class="text-center"> |
| 38 | + <Show when={showTitle()}> |
| 39 | + <h1 class="text-3xl font-semibold sm:text-4xl"> |
| 40 | + IME – An Input Method Editor that <span class="text-primary">doesn't suck</span> |
| 41 | + </h1> |
| 42 | + </Show> |
| 43 | + |
| 44 | + <Show when={showExplanation()}> |
| 45 | + <p class="text-muted-foreground mx-auto mt-4 max-w-xl text-base sm:text-lg"> |
| 46 | + Tired of clunky setups, invasive tracking, and unreliable input methods? IME is a |
| 47 | + fast, private, and simple web-based alternative that just works. |
| 48 | + </p> |
| 49 | + </Show> |
| 50 | + </div> |
| 51 | + |
| 52 | + <IMEField /> |
| 53 | + |
| 54 | + <footer class="text-muted-foreground text-sm"> |
| 55 | + <Flex alignItems="center" class="gap-3"> |
| 56 | + <span> |
| 57 | + Made by{" "} |
| 58 | + <a |
| 59 | + href="https://github.com/xlc-dev" |
| 60 | + class="text-foreground font-bold hover:underline"> |
| 61 | + xlcdev |
| 62 | + </a> |
| 63 | + </span> |
| 64 | + <span>·</span> |
| 65 | + <a |
| 66 | + href="https://github.com/xlc-dev/IME" |
| 67 | + class="text-foreground font-bold hover:underline"> |
| 68 | + GitHub |
| 69 | + </a> |
| 70 | + <span>·</span> |
| 71 | + <DialogTrigger |
| 72 | + as="button" |
| 73 | + class="text-foreground cursor-pointer font-bold hover:underline"> |
| 74 | + Settings |
| 75 | + </DialogTrigger> |
| 76 | + </Flex> |
| 77 | + </footer> |
| 78 | + </Flex> |
| 79 | + |
| 80 | + <DialogContent> |
| 81 | + <DialogHeader> |
| 82 | + <DialogTitle>Settings</DialogTitle> |
| 83 | + <DialogDescription> |
| 84 | + Customize your experience. Changes are saved automatically. |
| 85 | + </DialogDescription> |
| 86 | + </DialogHeader> |
| 87 | + <div class="grid gap-4 py-4"> |
| 88 | + <Switch |
| 89 | + checked={showTitle()} |
| 90 | + onChange={setShowTitle} |
| 91 | + id="show-title" |
| 92 | + class="flex w-full items-center justify-between"> |
| 93 | + <SwitchLabel>Show Title</SwitchLabel> |
| 94 | + <SwitchControl> |
| 95 | + <SwitchThumb /> |
| 96 | + </SwitchControl> |
| 97 | + </Switch> |
| 98 | + |
| 99 | + <Switch |
| 100 | + checked={showExplanation()} |
| 101 | + onChange={setShowExplanation} |
| 102 | + id="show-explanation" |
| 103 | + class="flex w-full items-center justify-between"> |
| 104 | + <SwitchLabel>Show Explanation</SwitchLabel> |
| 105 | + <SwitchControl> |
| 106 | + <SwitchThumb /> |
| 107 | + </SwitchControl> |
| 108 | + </Switch> |
| 109 | + |
| 110 | + <Flex justifyContent="between" alignItems="center"> |
| 111 | + <Label>Theme</Label> |
| 112 | + <ThemeToggle /> |
| 113 | + </Flex> |
| 114 | + </div> |
| 115 | + </DialogContent> |
| 116 | + </Dialog> |
| 117 | + </Flex> |
| 118 | + </MetaProvider> |
25 | 119 | ); |
26 | 120 | } |
0 commit comments