import type { FC, PropsWithChildren } from "hono/jsx"; import { tokensToCss } from "../lib/theme.js"; import { sanitizeCss } from "@atbb/css-sanitizer"; import type { ResolvedTheme } from "../lib/theme-resolution.js"; import type { WebSession } from "../lib/session.js"; const NavContent: FC<{ auth?: WebSession }> = ({ auth }) => ( <> {auth?.authenticated ? ( <> {auth.handle}
) : ( Log in )} ); export const BaseLayout: FC< PropsWithChildren<{ title?: string; auth?: WebSession; resolvedTheme: ResolvedTheme; }> > = (props) => { const { auth, resolvedTheme } = props; let rootCss = ""; try { rootCss = sanitizeCss(`:root { ${tokensToCss(resolvedTheme.tokens)} }`); } catch (err) { console.error("Failed to sanitize root CSS tokens — rendering without tokens", { error: String(err), }); } let overridesCss: string | null = null; if (resolvedTheme.cssOverrides) { try { overridesCss = sanitizeCss(resolvedTheme.cssOverrides); } catch (err) { console.error("Failed to sanitize CSS overrides — rendering without overrides", { error: String(err), }); } } return ( {props.title ?? "atBB Forum"}