expria-frontend/src/shared/lib/theme.ts
Hermann_Kitio b68f160bce feat(design-system): reskin Charcoal — tokens dark-default + sidebar navy permanent
- Remplacement intégral index.css par palette Charcoal (DESIGN_SYSTEM.md v2.0)
- Dark = thème par défaut, .light = override via @custom-variant light
- Sidebar navy #0C1528 permanent (identique dark+light)
- Script anti-FOUC inline dans index.html
- Layout : radial-gradient sur <main>, sidebar 230px, max-w-[1100px]
- Renommage tokens Boréal→Charcoal sur ~45 composants
- Inversion dark: → baseline + light: sur primitives shadcn
- Fix logo blanc forcé dans sidebar
- ADR 006 mis à jour

Typecheck: OK · Tests: 122/122 

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-24 23:09:15 +03:00

27 lines
749 B
TypeScript

import { createContext } from 'react'
export type Theme = 'light' | 'dark'
export interface ThemeContextValue {
theme: Theme
setTheme: (t: Theme) => void
}
export const ThemeContext = createContext<ThemeContextValue | null>(null)
const STORAGE_KEY = 'expria-theme'
export function getInitialTheme(): Theme {
const stored = localStorage.getItem(STORAGE_KEY)
if (stored === 'light' || stored === 'dark') return stored
if (window.matchMedia('(prefers-color-scheme: light)').matches) return 'light'
return 'dark'
}
export function applyTheme(theme: Theme): void {
document.documentElement.classList.toggle('light', theme === 'light')
}
export function persistTheme(theme: Theme): void {
localStorage.setItem(STORAGE_KEY, theme)
}