Compare commits
5 commits
d6c717a73e
...
530a89755c
Author | SHA1 | Date | |
---|---|---|---|
|
530a89755c | ||
|
cf985f05ca | ||
|
5d1cf347a4 | ||
|
12718930db | ||
|
c260027c9c |
7 changed files with 39 additions and 57 deletions
|
@ -1,5 +1,6 @@
|
||||||
.AppTopBar {
|
.AppTopBar {
|
||||||
& > .toolbar {
|
& > .toolbar {
|
||||||
padding-top: var(--safe-area-inset-top, 0px);
|
padding-top: var(--safe-area-inset-top, 0px);
|
||||||
|
gap: 8px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,11 +2,12 @@ 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";
|
import { useWindowSize } from "@solid-primitives/resize-observer";
|
||||||
|
import type { AppBarProps } from "@suid/material/AppBar";
|
||||||
|
|
||||||
const AppTopBar: ParentComponent<{
|
const AppTopBar: ParentComponent<{
|
||||||
class?: string;
|
class?: string;
|
||||||
style?: JSX.HTMLAttributes<HTMLElement>["style"];
|
style?: JSX.HTMLAttributes<HTMLElement>["style"];
|
||||||
}> = (oprops) => {
|
} & AppBarProps> = (oprops) => {
|
||||||
const [props, rest] = splitProps(oprops, ["children", "class"]);
|
const [props, rest] = splitProps(oprops, ["children", "class"]);
|
||||||
const windowSize = useWindowSize();
|
const windowSize = useWindowSize();
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ import {
|
||||||
animateSlideInFromRight,
|
animateSlideInFromRight,
|
||||||
animateSlideOutToRight,
|
animateSlideOutToRight,
|
||||||
} from "~platform/anim";
|
} from "~platform/anim";
|
||||||
|
import { isPointNotInRect } from "~platform/dom";
|
||||||
|
|
||||||
export type BottomSheetProps = {
|
export type BottomSheetProps = {
|
||||||
open?: boolean;
|
open?: boolean;
|
||||||
|
@ -120,12 +121,7 @@ const BottomSheet: ParentComponent<BottomSheetProps> = (props) => {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
if (event.target !== event.currentTarget) return;
|
if (event.target !== event.currentTarget) return;
|
||||||
const rect = event.currentTarget.getBoundingClientRect();
|
const rect = event.currentTarget.getBoundingClientRect();
|
||||||
const isNotInDialog =
|
if (isPointNotInRect(rect, event.clientX, event.clientY)) {
|
||||||
event.clientY < rect.top ||
|
|
||||||
event.clientY > rect.bottom ||
|
|
||||||
event.clientX < rect.left ||
|
|
||||||
event.clientX > rect.right;
|
|
||||||
if (isNotInDialog) {
|
|
||||||
props.onClose?.("backdrop");
|
props.onClose?.("backdrop");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,19 +6,6 @@
|
||||||
.MuiToolbar-root {
|
.MuiToolbar-root {
|
||||||
margin-left: var(--safe-area-inset-left);
|
margin-left: var(--safe-area-inset-left);
|
||||||
margin-right: var(--safe-area-inset-right);
|
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 {
|
.Scaffold {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
display: contents;
|
||||||
background-color: var(--tutu-color-surface);
|
background-color: var(--tutu-color-surface);
|
||||||
}
|
}
|
|
@ -19,6 +19,7 @@ import { animateSlideInFromRight, animateSlideOutToRight } from "./anim";
|
||||||
import { ANIM_CURVE_DECELERATION, ANIM_CURVE_STD } from "~material/theme";
|
import { ANIM_CURVE_DECELERATION, ANIM_CURVE_STD } from "~material/theme";
|
||||||
import { makeEventListener } from "@solid-primitives/event-listener";
|
import { makeEventListener } from "@solid-primitives/event-listener";
|
||||||
import { useWindowSize } from "@solid-primitives/resize-observer";
|
import { useWindowSize } from "@solid-primitives/resize-observer";
|
||||||
|
import { isPointNotInRect } from "./dom";
|
||||||
|
|
||||||
export type StackedRouterProps = Omit<RouterProps, "url">;
|
export type StackedRouterProps = Omit<RouterProps, "url">;
|
||||||
|
|
||||||
|
@ -173,12 +174,7 @@ function onDialogClick(
|
||||||
) {
|
) {
|
||||||
if (event.target !== event.currentTarget) return;
|
if (event.target !== event.currentTarget) return;
|
||||||
const rect = event.currentTarget.getBoundingClientRect();
|
const rect = event.currentTarget.getBoundingClientRect();
|
||||||
const isNotInDialog =
|
if (isPointNotInRect(rect, event.clientX, event.clientY)) {
|
||||||
event.clientY < rect.top ||
|
|
||||||
event.clientY > rect.bottom ||
|
|
||||||
event.clientX < rect.left ||
|
|
||||||
event.clientX > rect.right;
|
|
||||||
if (isNotInDialog) {
|
|
||||||
onClose();
|
onClose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
5
src/platform/dom.ts
Normal file
5
src/platform/dom.ts
Normal 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
|
||||||
|
);
|
||||||
|
}
|
|
@ -62,6 +62,7 @@ import {
|
||||||
createSingluarItemSelection,
|
createSingluarItemSelection,
|
||||||
default as ItemSelectionProvider,
|
default as ItemSelectionProvider,
|
||||||
} from "../timelines/toots/ItemSelectionProvider";
|
} from "../timelines/toots/ItemSelectionProvider";
|
||||||
|
import AppTopBar from "~material/AppTopBar";
|
||||||
|
|
||||||
const Profile: Component = () => {
|
const Profile: Component = () => {
|
||||||
const { pop } = useNavigator();
|
const { pop } = useNavigator();
|
||||||
|
@ -195,44 +196,38 @@ const Profile: Component = () => {
|
||||||
return (
|
return (
|
||||||
<Scaffold
|
<Scaffold
|
||||||
topbar={
|
topbar={
|
||||||
<AppBar
|
<AppTopBar
|
||||||
role="navigation"
|
role="navigation"
|
||||||
position="static"
|
position="static"
|
||||||
color={scrolledPastBanner() ? "primary" : "transparent"}
|
color={scrolledPastBanner() ? "primary" : "transparent"}
|
||||||
elevation={scrolledPastBanner() ? undefined : 0}
|
elevation={scrolledPastBanner() ? undefined : 0}
|
||||||
|
style={{
|
||||||
|
color: scrolledPastBanner()
|
||||||
|
? undefined
|
||||||
|
: bannerSampledColors()?.text,
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<Toolbar
|
<IconButton color="inherit" onClick={[pop, 1]} aria-label="Close">
|
||||||
variant="dense"
|
<Close />
|
||||||
sx={{
|
</IconButton>
|
||||||
display: "flex",
|
<Title
|
||||||
color: scrolledPastBanner()
|
class="Profile__page-title"
|
||||||
? undefined
|
style={{
|
||||||
: bannerSampledColors()?.text,
|
visibility: scrolledPastBanner() ? undefined : "hidden",
|
||||||
paddingTop: "var(--safe-area-inset-top)",
|
|
||||||
}}
|
}}
|
||||||
>
|
innerHTML={displayName()}
|
||||||
<IconButton color="inherit" onClick={[pop, 1]} aria-label="Close">
|
></Title>
|
||||||
<Close />
|
|
||||||
</IconButton>
|
|
||||||
<Title
|
|
||||||
class="Profile__page-title"
|
|
||||||
style={{
|
|
||||||
visibility: scrolledPastBanner() ? undefined : "hidden",
|
|
||||||
}}
|
|
||||||
innerHTML={displayName()}
|
|
||||||
></Title>
|
|
||||||
|
|
||||||
<IconButton
|
<IconButton
|
||||||
id={menuButId}
|
id={menuButId}
|
||||||
aria-controls={optMenuId}
|
aria-controls={optMenuId}
|
||||||
color="inherit"
|
color="inherit"
|
||||||
onClick={[setMenuOpen, true]}
|
onClick={[setMenuOpen, true]}
|
||||||
aria-label="Open Options for the Profile"
|
aria-label="Open Options for the Profile"
|
||||||
>
|
>
|
||||||
<MoreVert />
|
<MoreVert />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</Toolbar>
|
</AppTopBar>
|
||||||
</AppBar>
|
|
||||||
}
|
}
|
||||||
class="Profile"
|
class="Profile"
|
||||||
>
|
>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue