managarten/apps/zitare/packages/web-ui/src/stores/theme.ts
Till-JS 75a2527b60 feat(zitare): rename quote project to zitare and add global search
- Rename entire quote project to zitare (German name)
- Add global search page with quote and author search
- Add search to navigation with Cmd/Ctrl+K shortcut
- Add missing icons to PillNavigation (heart, list, compass)
- Update all package names from @quote/* to @zitare/*
- Update env variables from QUOTE_* to ZITARE_*
- Update CLAUDE.md documentation
- Fix layout with flex container structure

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 20:14:19 +01:00

35 lines
937 B
TypeScript

import { writable } from 'svelte/store';
import { browser } from '$app/environment';
export type Theme = 'light' | 'dark';
function createThemeStore() {
const { subscribe, set, update } = writable<Theme>('light');
return {
subscribe,
set,
toggle: () => {
update((current) => {
const newTheme = current === 'light' ? 'dark' : 'light';
if (browser) {
localStorage.setItem('theme', newTheme);
document.documentElement.setAttribute('data-theme', newTheme);
}
return newTheme;
});
},
init: () => {
if (browser) {
const savedTheme = localStorage.getItem('theme') as Theme | null;
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
const initialTheme = savedTheme || (prefersDark ? 'dark' : 'light');
document.documentElement.setAttribute('data-theme', initialTheme);
set(initialTheme);
}
},
};
}
export const theme = createThemeStore();