import { Eye, Image as ImageIcon, Leaf, Moon, Package, Pill, Sun } from 'lucide-react' import { useEffect, useState } from 'react' import About from './pages/About' import Caption from './pages/Caption' import FoodLabel from './pages/FoodLabel' import Home from './pages/Home' import Plant from './pages/Plant' import Prescription from './pages/Prescription' // Hash routes, so a page can be linked and survives a reload (no router needed). const ROUTES = { '#/caption': 'caption', '#/prescription': 'prescription', '#/product-label': 'label', '#/plant': 'plant', '#/about': 'about', } const pageFromHash = () => ROUTES[window.location.hash] ?? 'home' const TOOLS = [ { page: 'caption', href: '#/caption', label: 'Caption a photo', short: 'Caption', icon: ImageIcon }, { page: 'prescription', href: '#/prescription', label: 'Read a prescription', short: 'Prescription', icon: Pill }, { page: 'label', href: '#/product-label', label: 'Check a food label', short: 'Food label', icon: Package }, { page: 'plant', href: '#/plant', label: 'Identify a plant', short: 'Plant', icon: Leaf }, ] function useTheme() { const [theme, setTheme] = useState(() => (document.documentElement.dataset.theme === 'dark' ? 'dark' : 'light')) useEffect(() => { if (theme === 'dark') document.documentElement.dataset.theme = 'dark' else delete document.documentElement.dataset.theme try { localStorage.setItem('theme', theme) } catch { // storage blocked: the choice lasts for this visit only } }, [theme]) return [theme, () => setTheme((t) => (t === 'dark' ? 'light' : 'dark'))] } function Header({ page, theme, onToggleTheme }) { return (
Vision AI
About
) } function Footer() { return ( ) } export default function App() { const [page, setPage] = useState(pageFromHash) const [theme, toggleTheme] = useTheme() useEffect(() => { const onHash = () => { setPage(pageFromHash()) window.scrollTo(0, 0) } window.addEventListener('hashchange', onHash) return () => window.removeEventListener('hashchange', onHash) }, []) return (
{/* A button, not href="#main": the hash is the router */}
{page === 'home' && } {page === 'caption' && } {page === 'prescription' && } {page === 'label' && } {page === 'plant' && } {page === 'about' && }
) }