import React, { useEffect, useState } from 'react'; import { copy } from '../content/copy'; type Theme = 'light' | 'dark'; // Small line icons for the header buttons, drawn with the text colour. const icons: Record = { Source: ( <> ), Evidence: ( <> ), dark: , light: ( <> ), }; const Icon: React.FC<{ name: string }> = ({ name }) => ( ); // Light by default, like a reference page; the reader's choice is remembered. function initialTheme(): Theme { try { const stored = localStorage.getItem('ovl-theme'); if (stored === 'light' || stored === 'dark') return stored; } catch { // localStorage unavailable } return 'light'; } export const Header: React.FC = () => { const [theme, setTheme] = useState(initialTheme); useEffect(() => { try { if (theme === 'dark') { document.documentElement.setAttribute('data-theme', 'dark'); } else { document.documentElement.removeAttribute('data-theme'); } localStorage.setItem('ovl-theme', theme); } catch { // ignore localStorage errors } }, [theme]); return (
{copy.header.title} {copy.header.suffix} {copy.header.tagline}
); };