diff --git a/src/material/Menu.css b/src/material/Menu.css index 2be4bcf..5c88653 100644 --- a/src/material/Menu.css +++ b/src/material/Menu.css @@ -7,6 +7,22 @@ width: max-content; box-shadow: var(--tutu-shadow-e8); contain: content; + + &.e1 { + box-shadow: var(--tutu-shadow-e9); + } + + &.e2 { + box-shadow: var(--tutu-shadow-e10); + } + + &.e3 { + box-shadow: var(--tutu-shadow-e11); + } + + &.e4 { + box-shadow: var(--tutu-shadow-e12); + } } dialog.Menu::backdrop { diff --git a/src/material/Menu.tsx b/src/material/Menu.tsx index a80a423..916fc76 100644 --- a/src/material/Menu.tsx +++ b/src/material/Menu.tsx @@ -3,8 +3,9 @@ import { MenuList } from "@suid/material"; import { createEffect, createSignal, + type Component, type JSX, - type ParentComponent, + type ParentProps, } from "solid-js"; import { ANIM_CURVE_STD } from "./theme"; import "./Menu.css"; @@ -13,13 +14,13 @@ import { animateShrinkToTopRight, } from "../platform/anim"; -type Anchor = Pick +export type Anchor = Pick & { e?: number }; -type Props = { +export type MenuProps = ParentProps<{ open?: boolean; onClose?: JSX.EventHandlerUnion; anchor: () => Anchor; -}; +}>; function px(n?: number) { if (n) { @@ -29,15 +30,71 @@ function px(n?: number) { } } -const Menu: ParentComponent = (props) => { +/** + * Create managed state for {@link Menu}. This function + * expose an "open" closure for you to open the menu. The + * opening and closing is automatically managed internally. + * + * @returns The first element is the "open" closure, calls + * with anchor infomation to open the menu. + * The second element is the state props for {@link Menu}, use + * spread syntax to set the props. + * @example + * ````tsx + * const [openMenu, menuState] = createManagedMenuState(); + * + * + * + *