Compare commits

..

5 commits

Author SHA1 Message Date
thislight
530a89755c
Profile: use AppTopBar
All checks were successful
/ depoly (push) Successful in 1m22s
2024-12-01 23:28:23 +08:00
thislight
cf985f05ca
AppTopBar: add gap 2024-12-01 23:28:13 +08:00
thislight
5d1cf347a4
AppTopBar: support app bar props 2024-12-01 23:27:49 +08:00
thislight
12718930db
Scaffold: remove toolbar button hack 2024-12-01 23:27:16 +08:00
thislight
c260027c9c
add isPointNotInRect 2024-12-01 22:50:29 +08:00
7 changed files with 39 additions and 57 deletions

View file

@ -1,5 +1,6 @@
.AppTopBar {
& > .toolbar {
padding-top: var(--safe-area-inset-top, 0px);
gap: 8px;
}
}

View file

@ -2,11 +2,12 @@ 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";
import type { AppBarProps } from "@suid/material/AppBar";
const AppTopBar: ParentComponent<{
class?: string;
style?: JSX.HTMLAttributes<HTMLElement>["style"];
}> = (oprops) => {
} & AppBarProps> = (oprops) => {
const [props, rest] = splitProps(oprops, ["children", "class"]);
const windowSize = useWindowSize();

View file

@ -13,6 +13,7 @@ import {
animateSlideInFromRight,
animateSlideOutToRight,
} from "~platform/anim";
import { isPointNotInRect } from "~platform/dom";
export type BottomSheetProps = {
open?: boolean;
@ -120,12 +121,7 @@ const BottomSheet: ParentComponent<BottomSheetProps> = (props) => {
event.stopPropagation();
if (event.target !== event.currentTarget) return;
const rect = event.currentTarget.getBoundingClientRect();
const isNotInDialog =
event.clientY < rect.top ||
event.clientY > rect.bottom ||
event.clientX < rect.left ||
event.clientX > rect.right;
if (isNotInDialog) {
if (isPointNotInRect(rect, event.clientX, event.clientY)) {
props.onClose?.("backdrop");
}
};

View file

@ -6,19 +6,6 @@
.MuiToolbar-root {
margin-left: var(--safe-area-inset-left);
margin-right: var(--safe-area-inset-right);
>.MuiButtonBase-root {
&:first-child {
margin-left: -0.5em;
margin-right: 24px;
}
&:last-child {
margin-right: -0.5em;
margin-left: 24px;
}
}
}
}
@ -40,5 +27,6 @@
.Scaffold {
height: 100%;
width: 100%;
display: contents;
background-color: var(--tutu-color-surface);
}

View file

@ -19,6 +19,7 @@ import { animateSlideInFromRight, animateSlideOutToRight } from "./anim";
import { ANIM_CURVE_DECELERATION, ANIM_CURVE_STD } from "~material/theme";
import { makeEventListener } from "@solid-primitives/event-listener";
import { useWindowSize } from "@solid-primitives/resize-observer";
import { isPointNotInRect } from "./dom";
export type StackedRouterProps = Omit<RouterProps, "url">;
@ -173,12 +174,7 @@ function onDialogClick(
) {
if (event.target !== event.currentTarget) return;
const rect = event.currentTarget.getBoundingClientRect();
const isNotInDialog =
event.clientY < rect.top ||
event.clientY > rect.bottom ||
event.clientX < rect.left ||
event.clientX > rect.right;
if (isNotInDialog) {
if (isPointNotInRect(rect, event.clientX, event.clientY)) {
onClose();
}
}

5
src/platform/dom.ts Normal file
View file

@ -0,0 +1,5 @@
export function isPointNotInRect(rect: DOMRect, ptX: number, ptY: number) {
return (
ptY < rect.top || ptY > rect.bottom || ptX < rect.left || ptX > rect.right
);
}

View file

@ -62,6 +62,7 @@ import {
createSingluarItemSelection,
default as ItemSelectionProvider,
} from "../timelines/toots/ItemSelectionProvider";
import AppTopBar from "~material/AppTopBar";
const Profile: Component = () => {
const { pop } = useNavigator();
@ -195,20 +196,15 @@ const Profile: Component = () => {
return (
<Scaffold
topbar={
<AppBar
<AppTopBar
role="navigation"
position="static"
color={scrolledPastBanner() ? "primary" : "transparent"}
elevation={scrolledPastBanner() ? undefined : 0}
>
<Toolbar
variant="dense"
sx={{
display: "flex",
style={{
color: scrolledPastBanner()
? undefined
: bannerSampledColors()?.text,
paddingTop: "var(--safe-area-inset-top)",
}}
>
<IconButton color="inherit" onClick={[pop, 1]} aria-label="Close">
@ -231,8 +227,7 @@ const Profile: Component = () => {
>
<MoreVert />
</IconButton>
</Toolbar>
</AppBar>
</AppTopBar>
}
class="Profile"
>