diff --git a/apps/web/index.html b/apps/web/index.html index 4d0aff2..c9c8545 100644 --- a/apps/web/index.html +++ b/apps/web/index.html @@ -1,15 +1,29 @@ - + - + - Second Opinion — Enterprise Payment Guard for Alexa+ + + + + + Second Opinion — Enterprise Payment Guard · Alexa+ + + - - + + + +
diff --git a/apps/web/src/components/Layout.tsx b/apps/web/src/components/Layout.tsx index 1269985..c0cf276 100644 --- a/apps/web/src/components/Layout.tsx +++ b/apps/web/src/components/Layout.tsx @@ -1,21 +1,56 @@ -import { useEffect, useState, type ReactNode } from 'react'; +import { useCallback, useEffect, useState, type ReactNode } from 'react'; import { NavLink } from 'react-router-dom'; import { api } from '../api'; import { useAppState } from '../hooks/useAppState'; -import { IconActivity, IconServer, IconShieldCheck } from './icons'; +import { IconActivity, IconMoon, IconServer } from './icons'; +/* --------------------------------------------------------------- + Theme management — toggles [data-theme] on + ---------------------------------------------------------------- */ +type Theme = 'dark' | 'light'; + +function getInitialTheme(): Theme { + try { + const stored = localStorage.getItem('so-theme') as Theme | null; + if (stored === 'dark' || stored === 'light') return stored; + return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'; + } catch { + return 'dark'; + } +} + +function applyTheme(t: Theme) { + document.documentElement.setAttribute('data-theme', t); + try { localStorage.setItem('so-theme', t); } catch { /* ignore */ } +} + +function useTheme(): [Theme, () => void] { + const [theme, setTheme] = useState(getInitialTheme); + + useEffect(() => { applyTheme(theme); }, [theme]); + + const toggle = useCallback(() => { + setTheme((t) => (t === 'dark' ? 'light' : 'dark')); + }, []); + + return [theme, toggle]; +} + +/* --------------------------------------------------------------- + MCP / Live health pill + ---------------------------------------------------------------- */ function StatusDot({ ok }: { ok: boolean | null }) { - const color = ok === null ? 'var(--muted)' : ok ? 'var(--ok)' : 'var(--danger)'; + const c = ok === null ? 'var(--muted)' : ok ? 'var(--ok)' : 'var(--danger)'; return (