aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/DarkToggle.svelte
blob: 78506c8845d65db70591588cf73966b5b24ed050 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<script lang="ts">
  import { t } from "$lib/translations";
  import { theme } from "$lib/store";
  let dark = () => {
    $theme = $theme === "dark" ? "light" : "dark";
    document.cookie = `theme=${$theme}; path=/; max-age=21000000`;
  };
</script>

<button class="flex justify-center items-center hover:opacity-80 gap-2 font-bold" onclick={dark}>
  <iconify-icon
    noobserver
    icon={$theme === "dark" ? "ph:sun-bold" : "ph:moon-stars-bold"}
    width="30"
  ></iconify-icon>

  {$t(`nav.${$theme === "dark" ? "light" : "dark"}`)}
</button>