feat(ui): add app shell, router, and base path handling
Base path comes from BUN_PUBLIC_BASE_PATH so the same bundle serves both a root Docker deploy and a GitHub Pages subpath. Deviation from the task-16 brief: does not install @happy-dom/global-registrator, does not create test/setup.ts, and does not add a [test] preload to bunfig.toml. A global DOM preload would make src/domain/smoke.test.ts's "importable without a DOM" assertion vacuously true, silently retiring the check that guards the domain-layer-stays-pure invariant. Nothing in this task needs a DOM: basePath.test.ts is pure string logic, and the shell render test was intentionally omitted by the brief itself. A later task will register happy-dom per-file where a DOM is genuinely required.
This commit is contained in:
1 parent
69bf4393fb
commit
7edcc7f31e
14 files changed
+168
-14
No files matched your search
@@ -0,0 +1,52 @@
|
||||
import { BrowserRouter, Navigate, Route, Routes, NavLink } from "react-router";
|
||||
import { ROUTER_BASENAME } from "./basePath.ts";
|
||||
import { currentMonth } from "../store/index.ts";
|
||||
import { MonthRoute } from "./routes/MonthRoute.tsx";
|
||||
import { YearRoute } from "./routes/YearRoute.tsx";
|
||||
import { PostMonthRoute } from "./routes/PostMonthRoute.tsx";
|
||||
import { PostYearRoute } from "./routes/PostYearRoute.tsx";
|
||||
import { SummaryRoute } from "./routes/SummaryRoute.tsx";
|
||||
import { SettingsRoute } from "./routes/SettingsRoute.tsx";
|
||||
|
||||
export function AppRoutes() {
|
||||
const year = currentMonth.slice(0, 4);
|
||||
return (
|
||||
<div className="min-h-screen bg-background text-foreground">
|
||||
<nav className="flex gap-4 border-b px-6 py-3 text-sm">
|
||||
<NavLink to={`/month/${currentMonth}`} className="hover:underline">
|
||||
Month
|
||||
</NavLink>
|
||||
<NavLink to={`/year/${year}`} className="hover:underline">
|
||||
Year
|
||||
</NavLink>
|
||||
<NavLink to="/summary" className="hover:underline">
|
||||
Summary
|
||||
</NavLink>
|
||||
<NavLink to="/settings" className="ml-auto hover:underline">
|
||||
Settings
|
||||
</NavLink>
|
||||
</nav>
|
||||
<main className="p-6">
|
||||
<Routes>
|
||||
<Route path="/month/:monthId" element={<MonthRoute />} />
|
||||
<Route path="/year/:year" element={<YearRoute />} />
|
||||
<Route path="/post/:postId/month/:monthId" element={<PostMonthRoute />} />
|
||||
<Route path="/post/:postId/year/:year" element={<PostYearRoute />} />
|
||||
<Route path="/summary" element={<SummaryRoute />} />
|
||||
<Route path="/settings" element={<SettingsRoute />} />
|
||||
<Route path="*" element={<Navigate to={`/month/${currentMonth}`} replace />} />
|
||||
</Routes>
|
||||
</main>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function App() {
|
||||
return (
|
||||
<BrowserRouter basename={ROUTER_BASENAME}>
|
||||
<AppRoutes />
|
||||
</BrowserRouter>
|
||||
);
|
||||
}
|
||||
|
||||
export default App;
|
||||
Reference in new issue
Block a user