2022-08-06 13:26:25 +05:30
|
|
|
<script lang="ts">
|
|
|
|
import { afterUpdate } from "svelte";
|
|
|
|
import DarkMode from "svelte-dark-mode";
|
|
|
|
|
2022-09-16 19:35:27 +05:30
|
|
|
let theme: "dark" | "light";
|
2022-08-06 13:26:25 +05:30
|
|
|
|
|
|
|
afterUpdate(() => {
|
|
|
|
document.documentElement.className = theme;
|
|
|
|
});
|
|
|
|
|
|
|
|
let toggle = () => {
|
|
|
|
theme = theme === "dark" ? "light" : "dark";
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<DarkMode bind:theme />
|
|
|
|
|
2022-10-01 18:41:54 +05:30
|
|
|
<button
|
|
|
|
on:click={toggle}
|
|
|
|
class="cursor-pointer flex items-center py-1 px-0 bg-transparent border-0 font-[var(--font-primary)] color-[var(--text)]"
|
|
|
|
>
|
|
|
|
<div class="i-fa6-solid:{theme === 'dark' ? 'sun' : 'moon'}" />
|
2022-10-01 14:16:36 +05:30
|
|
|
<span class="ml-2">Toggle theme</span>
|
|
|
|
</button>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
@media screen and (min-width: 900px) {
|
|
|
|
span {
|
|
|
|
display: none;
|
|
|
|
margin-left: 0.25rem;
|
|
|
|
}
|
|
|
|
}
|
2022-10-01 18:41:54 +05:30
|
|
|
</style>
|