mirror of
https://github.com/recklessop/zroc.git
synced 2026-07-03 13:23:15 -04:00
b7b9f6191d
- Add zroc-planner UI page with VM selector, journal retention slider (1h-30d), WAN compression input, and live bandwidth/journal/mirror storage estimates - Add CSV and PDF export for planning reports - Add light/dark mode toggle in TopBar with localStorage persistence - Wire theme via CSS custom properties for full Tailwind opacity support - Add Planner route and sidebar entry Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
30 lines
789 B
React
30 lines
789 B
React
// src/auth/ThemeContext.jsx
|
|
import { createContext, useContext, useState, useEffect } from 'react';
|
|
|
|
const ThemeContext = createContext(null);
|
|
|
|
export function ThemeProvider({ children }) {
|
|
const [theme, setTheme] = useState(() =>
|
|
localStorage.getItem('zroc-theme') || 'dark'
|
|
);
|
|
|
|
useEffect(() => {
|
|
document.documentElement.setAttribute('data-theme', theme);
|
|
localStorage.setItem('zroc-theme', theme);
|
|
}, [theme]);
|
|
|
|
const toggle = () => setTheme((t) => t === 'dark' ? 'light' : 'dark');
|
|
|
|
return (
|
|
<ThemeContext.Provider value={{ theme, toggle }}>
|
|
{children}
|
|
</ThemeContext.Provider>
|
|
);
|
|
}
|
|
|
|
export function useTheme() {
|
|
const ctx = useContext(ThemeContext);
|
|
if (!ctx) throw new Error('useTheme must be used within ThemeProvider');
|
|
return ctx;
|
|
}
|