import type { ReactNode } from "react"; import { createPortal } from "react-dom"; import type { Tone } from "./Panel"; const TITLE_TONES: Partial> = { amber: "text-amber-300", emerald: "text-emerald-300", cyan: "text-cyan-200", }; const BORDER_TONES: Partial> = { amber: "border-amber-400/50", emerald: "border-emerald-400/40", cyan: "border-cyan-400/40", }; /** * A modal dialog: a bottom sheet on phones, a centred card from `sm` up. * Labelled by its title, which it renders as an `h2` with `titleId`. Portalled * to `body`: a transformed ancestor (the screens' rise-in) would otherwise * become the containing block of `position: fixed`. */ export function Sheet({ titleId, title, eyebrow, subtitle, tone = "default", layer = "z-20", children, }: { titleId: string; title: ReactNode; eyebrow?: ReactNode; subtitle?: ReactNode; tone?: Tone; /** Stacking layer, e.g. `z-30` for a sheet over other sheets. */ layer?: string; children: ReactNode; }) { return createPortal(
, document.body, ); }