ba90eff5db
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.
20 lines
504 B
TypeScript
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}
|
|
}
|