Compare commits
No commits in common. "4190b8847d2ad4732d48179bc686ce8ef2bbf66c" and "4d3f5c911b36acdbe10d9d85cd3116896628c9f1" have entirely different histories.
4190b8847d
...
4d3f5c911b
3 changed files with 34 additions and 15 deletions
|
@ -14,7 +14,6 @@ import {
|
||||||
animateGrowFromTopRight,
|
animateGrowFromTopRight,
|
||||||
animateShrinkToTopRight,
|
animateShrinkToTopRight,
|
||||||
} from "../platform/anim";
|
} from "../platform/anim";
|
||||||
import type { MenuListProps } from "@suid/material/MenuList";
|
|
||||||
|
|
||||||
export type Anchor = Pick<DOMRect, "top" | "left" | "right"> & { e?: number };
|
export type Anchor = Pick<DOMRect, "top" | "left" | "right"> & { e?: number };
|
||||||
|
|
||||||
|
@ -23,7 +22,6 @@ export type MenuProps = ParentProps<
|
||||||
open?: boolean;
|
open?: boolean;
|
||||||
onClose?: JSX.EventHandlerUnion<HTMLDialogElement, Event>;
|
onClose?: JSX.EventHandlerUnion<HTMLDialogElement, Event>;
|
||||||
anchor: () => Anchor;
|
anchor: () => Anchor;
|
||||||
MenuListProps?: MenuListProps;
|
|
||||||
|
|
||||||
id?: string;
|
id?: string;
|
||||||
} & JSX.AriaAttributes
|
} & JSX.AriaAttributes
|
||||||
|
@ -215,8 +213,11 @@ const Menu: Component<MenuProps> = (props) => {
|
||||||
tabIndex={-1}
|
tabIndex={-1}
|
||||||
{...rest}
|
{...rest}
|
||||||
>
|
>
|
||||||
<div class="container" role="presentation">
|
<div
|
||||||
<MenuList {...props.MenuListProps}>{props.children}</MenuList>
|
class="container"
|
||||||
|
role="presentation"
|
||||||
|
>
|
||||||
|
<MenuList>{props.children}</MenuList>
|
||||||
</div>
|
</div>
|
||||||
</dialog>
|
</dialog>
|
||||||
);
|
);
|
||||||
|
|
|
@ -259,10 +259,7 @@ const StackedRouter: Component<StackedRouterProps> = (oprops) => {
|
||||||
|
|
||||||
createRenderEffect(() => {
|
createRenderEffect(() => {
|
||||||
if (stack.length === 0) {
|
if (stack.length === 0) {
|
||||||
mutStack(0, {
|
pushFrame(window.location.pathname);
|
||||||
path: window.location.pathname,
|
|
||||||
rootId: createUniqueId(),
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,13 @@ import {
|
||||||
ListItemAvatar,
|
ListItemAvatar,
|
||||||
ListItemIcon,
|
ListItemIcon,
|
||||||
ListItemText,
|
ListItemText,
|
||||||
|
Menu,
|
||||||
MenuItem,
|
MenuItem,
|
||||||
} from "@suid/material";
|
} from "@suid/material";
|
||||||
import {
|
import {
|
||||||
|
ErrorBoundary,
|
||||||
Show,
|
Show,
|
||||||
|
createSignal,
|
||||||
createUniqueId,
|
createUniqueId,
|
||||||
type ParentComponent,
|
type ParentComponent,
|
||||||
} from "solid-js";
|
} from "solid-js";
|
||||||
|
@ -19,7 +22,6 @@ import {
|
||||||
FeaturedPlayList as ListIcon,
|
FeaturedPlayList as ListIcon,
|
||||||
} from "@suid/icons-material";
|
} from "@suid/icons-material";
|
||||||
import A from "../platform/A";
|
import A from "../platform/A";
|
||||||
import Menu, { createManagedMenuState } from "../material/Menu";
|
|
||||||
|
|
||||||
const ProfileMenuButton: ParentComponent<{
|
const ProfileMenuButton: ParentComponent<{
|
||||||
profile?: {
|
profile?: {
|
||||||
|
@ -33,20 +35,29 @@ const ProfileMenuButton: ParentComponent<{
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
onClick?: () => void;
|
||||||
|
onClose?: () => void;
|
||||||
}> = (props) => {
|
}> = (props) => {
|
||||||
const menuId = createUniqueId();
|
const menuId = createUniqueId();
|
||||||
const buttonId = createUniqueId();
|
const buttonId = createUniqueId();
|
||||||
|
|
||||||
const [open, state] = createManagedMenuState();
|
let [anchor, setAnchor] = createSignal<HTMLButtonElement | null>(null);
|
||||||
|
const open = () => !!anchor();
|
||||||
|
|
||||||
const onClick = (
|
const onClick = (
|
||||||
event: MouseEvent & { currentTarget: HTMLButtonElement },
|
event: MouseEvent & { currentTarget: HTMLButtonElement },
|
||||||
) => {
|
) => {
|
||||||
open(event.currentTarget.getBoundingClientRect());
|
setAnchor(event.currentTarget);
|
||||||
|
props.onClick?.();
|
||||||
};
|
};
|
||||||
|
|
||||||
const inf = () => props.profile?.account.inf;
|
const inf = () => props.profile?.account.inf;
|
||||||
|
|
||||||
|
const onClose = () => {
|
||||||
|
props.onClick?.();
|
||||||
|
setAnchor(null);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ButtonBase
|
<ButtonBase
|
||||||
|
@ -64,13 +75,23 @@ const ProfileMenuButton: ParentComponent<{
|
||||||
</ButtonBase>
|
</ButtonBase>
|
||||||
<Menu
|
<Menu
|
||||||
id={menuId}
|
id={menuId}
|
||||||
|
anchorEl={anchor()}
|
||||||
|
open={open()}
|
||||||
|
onClose={onClose}
|
||||||
MenuListProps={{
|
MenuListProps={{
|
||||||
"aria-labelledby": menuId,
|
"aria-labelledby": buttonId,
|
||||||
style: {
|
sx: {
|
||||||
"min-width": "220px",
|
minWidth: "220px",
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
{...state}
|
anchorOrigin={{
|
||||||
|
vertical: "top",
|
||||||
|
horizontal: "right",
|
||||||
|
}}
|
||||||
|
transformOrigin={{
|
||||||
|
vertical: "top",
|
||||||
|
horizontal: "right",
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<MenuItem
|
<MenuItem
|
||||||
component={A}
|
component={A}
|
||||||
|
|
Loading…
Reference in a new issue