Adds a theme selector
This commit is contained in:
20
src/lib/components/ThemeVariantButton.svelte
Normal file
20
src/lib/components/ThemeVariantButton.svelte
Normal 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
5
src/lib/themeVariant.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { persistentWritable } from './persistentStore';
|
||||
|
||||
export type ThemeVariant = 'default' | 'dark' | 'light';
|
||||
|
||||
export const themeVariant = persistentWritable<ThemeVariant>('theme-variant', 'default');
|
||||
Reference in New Issue
Block a user