do frontend (preact)
This commit is contained in:
48
web/src/footer.tsx
Normal file
48
web/src/footer.tsx
Normal file
@@ -0,0 +1,48 @@
|
||||
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)
|
||||
Reference in New Issue
Block a user