mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-14 21:41:09 +02:00
refactor: consolidate codebase — remove archived code, deduplicate packages, standardize middleware
- Delete 17 server-archived/ directories (consolidated into apps/api/) - Delete apps-archived/ (clock, wisekeep) and services-archived/ (it-landing, ollama-metrics-proxy) - Fix type safety: replace all `any` casts in cross-app-queries.ts with proper Local* types - Remove duplicate shared-auth-stores package (identical copy of shared-auth-ui/stores/) - Remove duplicate theme store from shared-stores (canonical version in shared-theme) - Migrate memoro-server rate-limiter to shared-hono/rateLimitMiddleware - Migrate uload-server JWT auth + error handler to shared-hono (authMiddleware, errorHandler) - Migrate arcade-server error handling to shared-hono - Merge shared-profile-ui and shared-app-onboarding into shared-ui - Unify /clock route into /times/clock, remove redirect stubs Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
7ee57b7afd
commit
d8ce4eaf34
309 changed files with 172 additions and 21667 deletions
|
|
@ -9,7 +9,6 @@ export {
|
|||
type NavigationItem,
|
||||
type NavigationStore,
|
||||
} from './navigation.svelte';
|
||||
export { createThemeStore, type ThemeStore, type ThemeMode } from './theme.svelte';
|
||||
export {
|
||||
createAppSettingsStore,
|
||||
type AppSettingsStore,
|
||||
|
|
|
|||
|
|
@ -1,125 +0,0 @@
|
|||
/**
|
||||
* Theme Store Factory
|
||||
* Creates a theme state store with Svelte 5 runes.
|
||||
*/
|
||||
|
||||
export type ThemeMode = 'light' | 'dark' | 'system';
|
||||
|
||||
export interface ThemeStore {
|
||||
readonly isDark: boolean;
|
||||
readonly mode: ThemeMode;
|
||||
readonly variant: string;
|
||||
initialize: () => () => void;
|
||||
setMode: (mode: ThemeMode) => void;
|
||||
setVariant: (variant: string) => void;
|
||||
toggle: () => void;
|
||||
}
|
||||
|
||||
export interface ThemeStoreConfig {
|
||||
/** Storage key prefix (default: 'theme') */
|
||||
storagePrefix?: string;
|
||||
/** Default theme mode */
|
||||
defaultMode?: ThemeMode;
|
||||
/** Default theme variant */
|
||||
defaultVariant?: string;
|
||||
/** CSS class to add/remove for dark mode */
|
||||
darkClass?: string;
|
||||
/** Data attribute for variant */
|
||||
variantAttribute?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a theme store with Svelte 5 runes.
|
||||
*/
|
||||
export function createThemeStore(config: ThemeStoreConfig = {}): ThemeStore {
|
||||
const {
|
||||
storagePrefix = 'theme',
|
||||
defaultMode = 'system',
|
||||
defaultVariant = 'default',
|
||||
darkClass = 'dark',
|
||||
variantAttribute = 'data-theme',
|
||||
} = config;
|
||||
|
||||
let isDark = $state(false);
|
||||
let mode = $state<ThemeMode>(defaultMode);
|
||||
let variant = $state(defaultVariant);
|
||||
|
||||
function updateTheme() {
|
||||
if (typeof window === 'undefined') return;
|
||||
|
||||
let shouldBeDark = false;
|
||||
if (mode === 'dark') {
|
||||
shouldBeDark = true;
|
||||
} else if (mode === 'system') {
|
||||
shouldBeDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
||||
}
|
||||
|
||||
isDark = shouldBeDark;
|
||||
document.documentElement.classList.toggle(darkClass, isDark);
|
||||
}
|
||||
|
||||
function initialize(): () => void {
|
||||
if (typeof window === 'undefined') return () => {};
|
||||
|
||||
// Load from localStorage
|
||||
const savedMode = localStorage.getItem(`${storagePrefix}-mode`) as ThemeMode | null;
|
||||
const savedVariant = localStorage.getItem(`${storagePrefix}-variant`);
|
||||
|
||||
if (savedMode) mode = savedMode;
|
||||
if (savedVariant) {
|
||||
variant = savedVariant;
|
||||
document.documentElement.setAttribute(variantAttribute, variant);
|
||||
}
|
||||
|
||||
updateTheme();
|
||||
|
||||
// Listen for system theme changes
|
||||
const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
|
||||
const handleChange = () => {
|
||||
if (mode === 'system') {
|
||||
updateTheme();
|
||||
}
|
||||
};
|
||||
|
||||
mediaQuery.addEventListener('change', handleChange);
|
||||
return () => mediaQuery.removeEventListener('change', handleChange);
|
||||
}
|
||||
|
||||
function setMode(newMode: ThemeMode) {
|
||||
mode = newMode;
|
||||
if (typeof localStorage !== 'undefined') {
|
||||
localStorage.setItem(`${storagePrefix}-mode`, newMode);
|
||||
}
|
||||
updateTheme();
|
||||
}
|
||||
|
||||
function setVariant(newVariant: string) {
|
||||
variant = newVariant;
|
||||
if (typeof localStorage !== 'undefined') {
|
||||
localStorage.setItem(`${storagePrefix}-variant`, newVariant);
|
||||
}
|
||||
if (typeof document !== 'undefined') {
|
||||
document.documentElement.setAttribute(variantAttribute, newVariant);
|
||||
}
|
||||
}
|
||||
|
||||
function toggle() {
|
||||
setMode(isDark ? 'light' : 'dark');
|
||||
}
|
||||
|
||||
return {
|
||||
get isDark() {
|
||||
return isDark;
|
||||
},
|
||||
get mode() {
|
||||
return mode;
|
||||
},
|
||||
get variant() {
|
||||
return variant;
|
||||
},
|
||||
initialize,
|
||||
setMode,
|
||||
setVariant,
|
||||
toggle,
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue