From 0af19ed7ea3ebd6504b0818ee469228a075ae7be Mon Sep 17 00:00:00 2001 From: Sam Chau Date: Mon, 29 Dec 2025 00:55:40 +1030 Subject: [PATCH] feat(accent): implement accent color store and picker for app theming --- src/lib/client/stores/accent.ts | 39 +++++++++++++ .../ui/navigation/navbar/accentPicker.svelte | 55 +++++++++++++++++++ .../client/ui/navigation/navbar/navbar.svelte | 10 +++- .../ui/navigation/navbar/themeToggle.svelte | 6 +- 4 files changed, 104 insertions(+), 6 deletions(-) create mode 100644 src/lib/client/stores/accent.ts create mode 100644 src/lib/client/ui/navigation/navbar/accentPicker.svelte diff --git a/src/lib/client/stores/accent.ts b/src/lib/client/stores/accent.ts new file mode 100644 index 0000000..e48574f --- /dev/null +++ b/src/lib/client/stores/accent.ts @@ -0,0 +1,39 @@ +/** + * Accent color store for app theming + */ + +import { writable } from 'svelte/store'; +import { browser } from '$app/environment'; + +export type AccentColor = 'blue' | 'yellow'; + +export const accentColors: { value: AccentColor; label: string; color: string }[] = [ + { value: 'blue', label: 'Blue', color: '#2563eb' }, + { value: 'yellow', label: 'Yellow', color: '#eab308' } +]; + +function createAccentStore() { + let initialAccent: AccentColor = 'blue'; + if (browser) { + const stored = localStorage.getItem('accent') as AccentColor | null; + if (stored && accentColors.some((c) => c.value === stored)) { + initialAccent = stored; + } + } + + const { subscribe, set } = writable(initialAccent); + + function setAccent(accent: AccentColor) { + set(accent); + if (browser) { + localStorage.setItem('accent', accent); + } + } + + return { + subscribe, + set: setAccent + }; +} + +export const accentStore = createAccentStore(); diff --git a/src/lib/client/ui/navigation/navbar/accentPicker.svelte b/src/lib/client/ui/navigation/navbar/accentPicker.svelte new file mode 100644 index 0000000..8348eaa --- /dev/null +++ b/src/lib/client/ui/navigation/navbar/accentPicker.svelte @@ -0,0 +1,55 @@ + + + + +
+ + + {#if open} + +
+ {#each accentColors as accent} + + {/each} +
+
+ {/if} +
diff --git a/src/lib/client/ui/navigation/navbar/navbar.svelte b/src/lib/client/ui/navigation/navbar/navbar.svelte index 8fc563a..5c455ea 100644 --- a/src/lib/client/ui/navigation/navbar/navbar.svelte +++ b/src/lib/client/ui/navigation/navbar/navbar.svelte @@ -1,10 +1,11 @@ diff --git a/src/lib/client/ui/navigation/navbar/themeToggle.svelte b/src/lib/client/ui/navigation/navbar/themeToggle.svelte index b6d8a34..254bb36 100644 --- a/src/lib/client/ui/navigation/navbar/themeToggle.svelte +++ b/src/lib/client/ui/navigation/navbar/themeToggle.svelte @@ -1,6 +1,6 @@ @@ -16,7 +16,7 @@ ? 'scale-100 rotate-0 opacity-100' : 'scale-75 rotate-180 opacity-0'}" > - + @@ -25,6 +25,6 @@ ? 'scale-75 -rotate-180 opacity-0' : 'scale-100 rotate-0 opacity-100'}" > - +