WIP/Experimental: Theme Switcher

This commit is contained in:
grimsi
2024-03-22 10:44:21 +01:00
parent ce9351f56b
commit 9424263c4a
10 changed files with 3092 additions and 1084 deletions
@@ -0,0 +1,24 @@
"use client"
import * as React from "react"
import {useConfig} from "@/hooks/use-config"
export function ThemeSwitcher() {
const [config] = useConfig()
React.useEffect(() => {
document.body.classList.forEach((className) => {
if (className.match(/^theme.*/)) {
document.body.classList.remove(className)
}
})
const theme = segment === "themes" ? config.theme : null
if (theme) {
return document.body.classList.add(`theme-${theme}`)
}
}, [segment, config])
return null
}