2024-07-14 12:28:44 +00:00
|
|
|
import { createElementSize } from "@solid-primitives/resize-observer";
|
|
|
|
import {
|
|
|
|
Show,
|
|
|
|
createRenderEffect,
|
|
|
|
createSignal,
|
|
|
|
onCleanup,
|
|
|
|
type JSX,
|
|
|
|
type ParentComponent,
|
|
|
|
} from "solid-js";
|
|
|
|
import { css } from "solid-styled";
|
|
|
|
|
|
|
|
interface ScaffoldProps {
|
|
|
|
topbar?: JSX.Element;
|
|
|
|
fab?: JSX.Element;
|
2024-09-25 11:30:05 +00:00
|
|
|
bottom?: JSX.Element;
|
2024-07-14 12:28:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const Scaffold: ParentComponent<ScaffoldProps> = (props) => {
|
|
|
|
const [topbarElement, setTopbarElement] = createSignal<HTMLElement>();
|
|
|
|
|
|
|
|
const topbarSize = createElementSize(topbarElement);
|
|
|
|
|
|
|
|
css`
|
|
|
|
.scaffold-content {
|
|
|
|
--scaffold-topbar-height: ${(topbarSize.height?.toString() ?? 0) + "px"};
|
|
|
|
}
|
|
|
|
|
|
|
|
.topbar {
|
|
|
|
position: sticky;
|
|
|
|
top: 0px;
|
|
|
|
z-index: var(--tutu-zidx-nav, auto);
|
|
|
|
}
|
|
|
|
|
|
|
|
.fab-dock {
|
|
|
|
position: fixed;
|
|
|
|
bottom: 40px;
|
|
|
|
right: 40px;
|
|
|
|
z-index: var(--tutu-zidx-nav, auto);
|
|
|
|
}
|
2024-09-25 11:30:05 +00:00
|
|
|
|
|
|
|
.bottom-dock {
|
|
|
|
position: sticky;
|
|
|
|
bottom: 0;
|
|
|
|
left: 0;
|
|
|
|
right: 0;
|
|
|
|
z-index: var(--tutu-zidx-nav, auto);
|
|
|
|
padding-bottom: var(--safe-area-inset-bottom, 0);
|
|
|
|
|
|
|
|
}
|
2024-07-14 12:28:44 +00:00
|
|
|
`;
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<Show when={props.topbar}>
|
|
|
|
<div class="topbar" ref={setTopbarElement}>
|
|
|
|
{props.topbar}
|
|
|
|
</div>
|
|
|
|
</Show>
|
|
|
|
<Show when={props.fab}>
|
|
|
|
<div class="fab-dock">{props.fab}</div>
|
|
|
|
</Show>
|
|
|
|
<div class="scaffold-content">{props.children}</div>
|
2024-09-25 11:30:05 +00:00
|
|
|
<Show when={props.bottom}>
|
|
|
|
<div class="bottom-dock">{props.bottom}</div>
|
|
|
|
</Show>
|
2024-07-14 12:28:44 +00:00
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Scaffold;
|