Files
aoc-srv/web/src/footer.tsx
2026-11-24 23:45:37 +01:00

49 lines
990 B
TypeScript

import { render } from 'preact'
import { SOURCE_LINK } from '@/consts'
import { nextTheme, theme } from '@/lib/state/theme'
import * as Lucide from 'lucide-preact'
import '@/styles/theme-toggle.scss'
const icons = {
light: Lucide.Sun,
dark: Lucide.Moon,
auto: Lucide.SunMoon,
}
function ThemeToggle() {
const setNextTheme = () => {
theme.value = nextTheme(theme.value)
}
const Icon = icons[theme.value]
return (
<button
class="theme-toggle"
onClick={setNextTheme}
aria-label={`Theme: ${theme.value}. Change theme`}
title={`Theme: ${theme.value}`}
>
<Icon size="1.2em" strokeWidth={1.8} />
</button>
)
}
function Footer() {
return (
<>
<span>Source code at {SOURCE_LINK}</span>
<div>
<span>locale: TODO</span>
<ThemeToggle />
</div>
</>
)
}
const root = document.getElementsByTagName('footer')[0]
if (!root) throw new Error('Missing footer element')
render(<Footer />, root)