AppTopBar: automatically switch toolbar variant
All checks were successful
/ depoly (push) Successful in 1m21s
All checks were successful
/ depoly (push) Successful in 1m21s
This commit is contained in:
parent
bece50643f
commit
b2d8c1bb2e
1 changed files with 4 additions and 1 deletions
|
@ -1,12 +1,15 @@
|
||||||
import { AppBar, Toolbar } from "@suid/material";
|
import { AppBar, Toolbar } from "@suid/material";
|
||||||
import { splitProps, type JSX, type ParentComponent } from "solid-js";
|
import { splitProps, type JSX, type ParentComponent } from "solid-js";
|
||||||
import "./AppTopBar.css";
|
import "./AppTopBar.css";
|
||||||
|
import { useWindowSize } from "@solid-primitives/resize-observer";
|
||||||
|
|
||||||
const AppTopBar: ParentComponent<{
|
const AppTopBar: ParentComponent<{
|
||||||
class?: string;
|
class?: string;
|
||||||
style?: JSX.HTMLAttributes<HTMLElement>["style"];
|
style?: JSX.HTMLAttributes<HTMLElement>["style"];
|
||||||
}> = (oprops) => {
|
}> = (oprops) => {
|
||||||
const [props, rest] = splitProps(oprops, ["children", "class"]);
|
const [props, rest] = splitProps(oprops, ["children", "class"]);
|
||||||
|
const windowSize = useWindowSize();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AppBar
|
<AppBar
|
||||||
class={`AppTopBar ${props.class || ""}`}
|
class={`AppTopBar ${props.class || ""}`}
|
||||||
|
@ -15,7 +18,7 @@ const AppTopBar: ParentComponent<{
|
||||||
{...rest}
|
{...rest}
|
||||||
>
|
>
|
||||||
<Toolbar
|
<Toolbar
|
||||||
variant="dense"
|
variant={windowSize.width > windowSize.height ? "dense" : "regular"}
|
||||||
class="toolbar"
|
class="toolbar"
|
||||||
sx={{ paddingTop: "var(--safe-area-inset-top, 0px)" }}
|
sx={{ paddingTop: "var(--safe-area-inset-top, 0px)" }}
|
||||||
>
|
>
|
||||||
|
|
Loading…
Reference in a new issue