mirror of
https://github.com/ProjectSegfault/website.git
synced 2024-12-25 14:39:56 +05:30
32 lines
621 B
Svelte
32 lines
621 B
Svelte
<script lang="ts">
|
|
import { afterUpdate } from "svelte";
|
|
import DarkMode from "svelte-dark-mode";
|
|
import type { Theme } from "svelte-dark-mode/types/DarkMode.svelte";
|
|
|
|
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} class="i-fa6-solid:sun" />
|
|
{:else if theme === "light"}
|
|
<div on:click={toggle} class="i-fa6-solid:moon" />
|
|
{/if}
|
|
|
|
<style>
|
|
div {
|
|
cursor: pointer;
|
|
display: flex;
|
|
align-items: center;
|
|
}
|
|
</style>
|