Adds a theme selector

This commit is contained in:
2023-08-14 15:40:35 +02:00
parent 7bcc221bbb
commit 6f6178b066
4 changed files with 56 additions and 4 deletions

View File

@@ -0,0 +1,20 @@
<script lang="ts">
import { themeVariant, type ThemeVariant } from '$lib/themeVariant';
const variants: Array<ThemeVariant> = ['default', 'dark', 'light'];
function next() {
const newVariant = (variants.findIndex((v) => v == $themeVariant) + 1) % 3;
themeVariant.set(variants[newVariant]);
}
</script>
<button on:click={next}>
{#if $themeVariant == 'default'}
<i class="fa fa-circle-half-stroke" />
{:else if $themeVariant == 'light'}
<i class="fa-regular fa-circle" />
{:else if $themeVariant == 'dark'}
<i class="fa-solid fa-circle" />
{/if}
</button>

5
src/lib/themeVariant.ts Normal file
View File

@@ -0,0 +1,5 @@
import { persistentWritable } from './persistentStore';
export type ThemeVariant = 'default' | 'dark' | 'light';
export const themeVariant = persistentWritable<ThemeVariant>('theme-variant', 'default');