Files
crowdlending-app/frontend/src/components/ThemeSwitcher.jsx
T
Olivier CROGUENNEC 48ed7fe65e Initial commit
2026-06-13 14:57:15 +02:00

29 lines
797 B
React

import { useTheme } from '../context/ThemeContext.jsx';
const OPTIONS = [
{ mode: 'light', icon: '☀', label: 'Clair' },
{ mode: 'dark', icon: '☾', label: 'Sombre' },
{ mode: 'system', icon: '◐', label: 'Système' },
];
export default function ThemeSwitcher() {
const { mode, setMode } = useTheme();
return (
<div className="theme-switcher" role="group" aria-label="Thème">
{OPTIONS.map(o => (
<button
key={o.mode}
type="button"
className={mode === o.mode ? 'active' : ''}
onClick={() => setMode(o.mode)}
title={o.label}
aria-pressed={mode === o.mode}
>
<span aria-hidden="true">{o.icon}</span>
<span>{o.label}</span>
</button>
))}
</div>
);
}