Files
floci-ui/packages/frontend/src/lib/useTheme.ts
T
Zakaria ba90eff5db feat(frontend): add a terminal theme and three-way theme switcher
Adds the cyber theme to the console and login page, replaces the dark/light toggle with a theme switcher, and moves the login page script to /login.js so it is served under the existing CSP.
2026-10-23 10:12:41 -04:00

20 lines
504 B
TypeScript

import {useEffect, useState} from 'react'
export type Theme = 'dark' | 'light' | 'cyber'
function getStored(): Theme {
const v = localStorage.getItem('floci-theme')
return v === 'light' || v === 'cyber' ? v : 'dark'
}
export function useTheme() {
const [theme, setTheme] = useState<Theme>(getStored)
useEffect(() => {
document.documentElement.setAttribute('data-theme', theme)
localStorage.setItem('floci-theme', theme)
}, [theme])
return {theme, setTheme}
}