diff options
Diffstat (limited to 'fe/src/lib/Layout.svelte')
-rw-r--r-- | fe/src/lib/Layout.svelte | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/fe/src/lib/Layout.svelte b/fe/src/lib/Layout.svelte new file mode 100644 index 0000000..f349632 --- /dev/null +++ b/fe/src/lib/Layout.svelte | |||
@@ -0,0 +1,57 @@ | |||
1 | <script> | ||
2 | import { authenticated, token } from '../stores/auth'; | ||
3 | |||
4 | const logout = () => token.unauthenticate(); | ||
5 | |||
6 | function showSettingsDialog() { | ||
7 | console.log('show settings'); | ||
8 | } | ||
9 | |||
10 | </script> | ||
11 | |||
12 | <div class="layout"> | ||
13 | {#if $authenticated} | ||
14 | <nav> | ||
15 | <div> | ||
16 | <h1>Water</h1> | ||
17 | </div> | ||
18 | <div> | ||
19 | <button on:click={showSettingsDialog}>Settings</button> | ||
20 | <button on:click={logout}>Logout</button> | ||
21 | </div> | ||
22 | </nav> | ||
23 | {/if} | ||
24 | <div id="content"> | ||
25 | <slot /> | ||
26 | </div> | ||
27 | </div> | ||
28 | |||
29 | <style> | ||
30 | .layout { | ||
31 | height: 100vh; | ||
32 | } | ||
33 | nav { | ||
34 | display: flex; | ||
35 | flex-direction: row; | ||
36 | align-items: center; | ||
37 | justify-content: space-between; | ||
38 | height: 64px; | ||
39 | padding: 0 2em; | ||
40 | } | ||
41 | |||
42 | nav div { | ||
43 | width: fit-content; | ||
44 | } | ||
45 | |||
46 | nav div h1 { | ||
47 | font-size: 1.75em; | ||
48 | } | ||
49 | |||
50 | #content { | ||
51 | display: flex; | ||
52 | flex-direction: column; | ||
53 | justify-content: center; | ||
54 | align-items: center; | ||
55 | padding: 3em 0; | ||
56 | } | ||
57 | </style> | ||