import React, { useState } from 'react'; import { Monitor, Moon, Sun } from 'lucide-react'; import { AVAILABLE_THEMES, getFollowSystem, resolveTheme, setFollowSystem, THEME_FAMILIES, ThemeId, ThemeOption, } from '../lib/theme'; interface ThemeQuickPickerProps { activeTheme: ThemeId; /** All themes including the user's own (shown as small chips) */ themes: ThemeOption[]; onChange: (id: ThemeId) => void; /** Bigger touch targets in the phone sheet */ touch?: boolean; } // Compact switcher for the user menu: one dot per colour family plus light/dark; own themes below export const ThemeQuickPicker: React.FC = ({ activeTheme, themes, onChange, touch = false }) => { const active = AVAILABLE_THEMES.find((t) => t.id === activeTheme); const mode = active?.mode ?? 'dark'; const customThemes = themes.filter((t) => t.isCustom); const dot = touch ? 'w-9 h-9' : 'w-7 h-7'; // Kept in state: choosing "System" may not change the theme, but the selection must still show const [followSystem, setFollow] = useState(getFollowSystem); const pick = (id: ThemeId) => onChange(resolveTheme(id)); return (
{THEME_FAMILIES.map((f) => { const preview = AVAILABLE_THEMES.find((t) => t.id === (mode === 'light' ? f.light : f.dark)); const selected = active?.family === f.id; return ( ); })}
{/* Own row: three labelled segments, so it fits narrow menus */}
{(['light', 'dark', 'auto'] as const).map((m) => { const family = active?.family ? THEME_FAMILIES.find((f) => f.id === active.family) : undefined; const selected = m === 'auto' ? followSystem : !followSystem && !!active && mode === m; const disabled = !family; return ( ); })}
{customThemes.length > 0 && (
{customThemes.map((t) => ( ))}
)}
); };