feat: layout components (Sidebar, Header, MobileNav, TabBar, AppLayout) with routing

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
enzo
2026-07-22 16:33:42 +08:00
co-authored by Claude
parent bd3d0147f5
commit 7441546804
18 changed files with 589 additions and 3 deletions
+23
View File
@@ -0,0 +1,23 @@
import { useState, useEffect } from 'react'
type Theme = 'dark' | 'light' | 'system'
export function useTheme() {
const [theme, setTheme] = useState<Theme>(() => {
return (localStorage.getItem('hive-theme') as Theme) || 'system'
})
useEffect(() => {
const root = document.documentElement
if (theme === 'system') {
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches
root.setAttribute('data-theme', prefersDark ? 'dark' : 'light')
} else {
root.setAttribute('data-theme', theme)
}
localStorage.setItem('hive-theme', theme)
}, [theme])
const toggle = () => setTheme(t => (t === 'dark' ? 'light' : 'dark'))
return { theme, setTheme, toggle }
}