2022-08-06 10:56:25 +03:00
|
|
|
<script lang="ts">
|
|
|
|
import { afterUpdate } from "svelte";
|
|
|
|
import DarkMode from "svelte-dark-mode";
|
|
|
|
import type { Theme } from "svelte-dark-mode/types/DarkMode.svelte";
|
2022-08-08 08:20:03 +03:00
|
|
|
import IconSun from "~icons/fa6-solid/sun";
|
|
|
|
import IconMoon from "~icons/fa6-solid/moon";
|
2022-08-06 10:56:25 +03:00
|
|
|
|
|
|
|
let theme: Theme;
|
|
|
|
|
|
|
|
afterUpdate(() => {
|
|
|
|
document.documentElement.className = theme;
|
|
|
|
});
|
|
|
|
|
|
|
|
let toggle = () => {
|
|
|
|
theme = theme === "dark" ? "light" : "dark";
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<DarkMode bind:theme />
|
|
|
|
|
|
|
|
{#if theme === "dark"}
|
|
|
|
<div on:click={toggle}>
|
2022-08-08 08:20:03 +03:00
|
|
|
<IconSun />
|
|
|
|
</div>
|
2022-08-06 10:56:25 +03:00
|
|
|
{:else if theme === "light"}
|
2022-08-08 08:20:03 +03:00
|
|
|
<div on:click={toggle}>
|
|
|
|
<IconMoon />
|
|
|
|
</div>
|
2022-08-06 10:56:25 +03:00
|
|
|
{/if}
|
|
|
|
|
|
|
|
<style>
|
2022-08-08 08:20:03 +03:00
|
|
|
div {
|
|
|
|
cursor: pointer;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
}
|
|
|
|
</style>
|