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