import { createElementSize } from "@solid-primitives/resize-observer"; import { JSX, Show, createRenderEffect, createSignal, splitProps, type Component, type ParentProps, } from "solid-js"; import "./Scaffold.css"; type ScaffoldProps = ParentProps< { topbar?: JSX.Element; fab?: JSX.Element; bottom?: JSX.Element; } & JSX.HTMLElementTags["div"] >; /** * The passthrough props are passed to the content container. */ const Scaffold: Component = (props) => { const [managed, rest] = splitProps(props, [ "topbar", "fab", "bottom", "children", "ref", ]); const [topbarElement, setTopbarElement] = createSignal(); const topbarSize = createElementSize(topbarElement); return ( <>
{props.topbar}
{props.fab}
{ createRenderEffect(() => { e.style.setProperty( "--scaffold-topbar-height", (topbarSize.height?.toString() ?? 0) + "px", ); }); if (managed.ref) { (managed.ref as (val: typeof e) => void)(e); } }} {...rest} > {managed.children}
{props.bottom}
); }; export default Scaffold;