Files
fabdash/frontend/src/App.jsx

60 lines
2.5 KiB
React
Raw Normal View History

2026-03-05 15:39:21 -06:00
import { useEffect, useRef } from 'react'
2026-03-05 12:13:22 -06:00
import ProjectList from './components/Projects/ProjectList'
import MainCalendar from './components/Calendar/MainCalendar'
import FocusDrawer from './components/FocusView/FocusDrawer'
2026-03-05 15:39:21 -06:00
import ToastContainer from './components/UI/Toast'
2026-03-05 12:13:22 -06:00
import { fetchProjects } from './api/projects'
import useProjectStore from './store/useProjectStore'
2026-03-05 15:39:21 -06:00
import useUIStore from './store/useUIStore'
2026-03-05 12:13:22 -06:00
export default function App() {
const { setProjects, setLoading } = useProjectStore()
2026-03-05 15:39:21 -06:00
const { sidebarOpen, toggleSidebar } = useUIStore()
const calApiRef = useRef(null)
const newProjectFn = useRef(null)
2026-03-05 12:13:22 -06:00
useEffect(() => {
setLoading(true)
fetchProjects()
.then(data => { setProjects(data); setLoading(false) })
.catch(() => setLoading(false))
}, [])
2026-03-05 15:39:21 -06:00
// Global keyboard shortcuts
useEffect(() => {
const handler = (e) => {
if (['INPUT','TEXTAREA','SELECT'].includes(e.target.tagName)) return
if (e.key === 'n' || e.key === 'N') { e.preventDefault(); newProjectFn.current?.() }
if (e.key === 'b' || e.key === 'B') toggleSidebar()
if (e.key === 'ArrowLeft' && calApiRef.current) calApiRef.current.prev()
if (e.key === 'ArrowRight' && calApiRef.current) calApiRef.current.next()
if ((e.key === 't' || e.key === 'T') && calApiRef.current) calApiRef.current.today()
}
document.addEventListener('keydown', handler)
return () => document.removeEventListener('keydown', handler)
}, [toggleSidebar])
2026-03-05 12:13:22 -06:00
return (
<div className="flex h-screen bg-surface overflow-hidden">
2026-03-05 15:39:21 -06:00
{/* Sidebar */}
<aside className={`flex-shrink-0 bg-surface-raised border-r border-surface-border flex flex-col h-full transition-[width] duration-300 overflow-hidden ${sidebarOpen ? 'w-72' : 'w-0'}`}>
<ProjectList onRegisterNewProject={fn => { newProjectFn.current = fn }} />
2026-03-05 12:13:22 -06:00
</aside>
2026-03-05 15:39:21 -06:00
{/* Sidebar toggle tab */}
<button onClick={toggleSidebar} title={`${sidebarOpen ? 'Collapse' : 'Expand'} sidebar [B]`}
className={`absolute top-4 z-30 bg-surface-elevated border border-surface-border hover:border-gold/50 text-text-muted hover:text-gold rounded-r-lg px-1 py-3 transition-all duration-300 text-xs ${sidebarOpen ? 'left-72' : 'left-0'}`}>
{sidebarOpen ? '◀' : '▶'}
</button>
{/* Main content */}
2026-03-05 12:13:22 -06:00
<main className="flex-1 overflow-hidden">
2026-03-05 15:39:21 -06:00
<MainCalendar onCalendarReady={api => { calApiRef.current = api }} />
2026-03-05 12:13:22 -06:00
</main>
2026-03-05 15:39:21 -06:00
2026-03-05 12:13:22 -06:00
<FocusDrawer />
2026-03-05 15:39:21 -06:00
<ToastContainer />
2026-03-05 12:13:22 -06:00
</div>
)
}