From b2d8c1bb2e425029fa2cbeb24fbf6c17573f0f47 Mon Sep 17 00:00:00 2001 From: thislight Date: Tue, 26 Nov 2024 15:30:39 +0800 Subject: [PATCH] AppTopBar: automatically switch toolbar variant --- src/material/AppTopBar.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/material/AppTopBar.tsx b/src/material/AppTopBar.tsx index b786646..dca5852 100644 --- a/src/material/AppTopBar.tsx +++ b/src/material/AppTopBar.tsx @@ -1,12 +1,15 @@ import { AppBar, Toolbar } from "@suid/material"; import { splitProps, type JSX, type ParentComponent } from "solid-js"; import "./AppTopBar.css"; +import { useWindowSize } from "@solid-primitives/resize-observer"; const AppTopBar: ParentComponent<{ class?: string; style?: JSX.HTMLAttributes["style"]; }> = (oprops) => { const [props, rest] = splitProps(oprops, ["children", "class"]); + const windowSize = useWindowSize(); + return ( windowSize.height ? "dense" : "regular"} class="toolbar" sx={{ paddingTop: "var(--safe-area-inset-top, 0px)" }} >