aboutsummaryrefslogtreecommitdiff
path: root/fe/src/lib/Layout.svelte
blob: 94ce84d4431ebf028ec2f0b602bc9268fa6ca77f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<script>
  import { authenticated, token } from "../stores/auth";
  import PreferencesForm from "./PreferencesForm.svelte";
  const logout = () => token.unauthenticate();
  let open = false;

  function showSettingsDialog() {
    open = true;
  }

  function closeDialog() {
    open = false;
  }
</script>

<div class="layout">
  {#if $authenticated}
    <nav>
      <div>
        <h1>Water</h1>
      </div>
      <div>
        <button on:click={showSettingsDialog}>Settings</button>
        <button on:click={logout}>Logout</button>
      </div>
    </nav>
    <PreferencesForm {open} on:close={closeDialog} />
  {/if}
  <div id="content">
    <slot />
  </div>
</div>

<style>
  .layout {
    height: 100vh;
  }
  nav {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    padding: 0 2em;
  }

  nav div {
    width: fit-content;
  }

  nav div h1 {
    font-size: 1.75em;
  }

  #content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 3em 0;
  }
</style>