feat: migrate Menu and Dropdown with selection and submenus

Port HeroUI menu family and Dropdown from ce90ea3: Reka DropdownMenu base,
MenuKey[] selection with section owners, 17 official demos, dropdown docs
and B01 tests. Long-press stays demo-level; submenu close is level-scoped.
This commit is contained in:
maoyingjie
2026-10-24 20:43:04 +08:00
parent 1c4ecc3def
commit 06ddb6662a
48 changed files with 3091 additions and 5 deletions
+119
View File
@@ -0,0 +1,119 @@
/* Adapted from HeroUI ce90ea3. Copyright 2025 NextUI Inc.
* Apache-2.0; see third-party/HEROUI-LICENSE. hv- namespace and Vue adapters. */
/* ==========================================================================
Base dropdown styles
========================================================================== */
.hv-dropdown {
@apply flex flex-col gap-1;
}
.hv-dropdown__trigger {
@apply inline-block;
/* Custom trigger (not a library Button) gets button-like affordances */
@apply outline-none;
transition:
transform 250ms var(--ease-out-quart),
background-color 150ms var(--ease-smooth),
box-shadow 150ms var(--ease-out);
@apply transform-gpu motion-reduce:transition-none;
cursor: var(--cursor-interactive);
&:focus-visible:not([data-focused]),
&[data-focus-visible="true"] {
@apply status-focused;
}
&:disabled,
&[aria-disabled="true"] {
@apply status-disabled;
}
&[data-pending="true"] {
@apply status-pending;
}
&:active,
&[data-pressed="true"] {
transform: scale(0.97);
}
}
/* Similar to select popover styles */
.hv-dropdown__popover {
@apply max-w-[48svw] origin-(--trigger-anchor-point) scroll-py-1 scrollbar overflow-y-auto overscroll-contain bg-overlay p-0 text-sm md:min-w-55;
border-radius: min(32px, var(--radius-3xl));
box-shadow: var(--overlay-shadow);
&:focus-visible:not([data-focused]),
&[data-focus-visible="true"] {
@apply outline-none;
}
/* Entering animations */
&[data-entering="true"] {
@apply animate-in duration-150 ease-smooth fade-in-0 zoom-in-90;
&[data-placement="top"] {
@apply slide-in-from-bottom-1;
}
&[data-placement="bottom"] {
@apply slide-in-from-top-1;
}
&[data-placement="left"] {
@apply slide-in-from-right-1;
}
&[data-placement="right"] {
@apply slide-in-from-left-1;
}
}
/* Exiting animations */
&[data-exiting="true"] {
@apply animate-out duration-100 ease-smooth zoom-out-95 fade-out;
@apply pointer-events-none;
}
&[data-exiting="true"],
&[data-entering="true"] {
@apply transition-[opacity,transform] will-change-[opacity,transform];
}
/* Arrow styling */
& [data-slot="popover-overlay-arrow"] {
fill: var(--overlay);
}
&[data-placement="bottom"] [data-slot="popover-overlay-arrow"] {
rotate: 180deg;
}
&[data-placement="left"] [data-slot="popover-overlay-arrow"] {
rotate: -90deg;
}
&[data-placement="right"] [data-slot="popover-overlay-arrow"] {
rotate: 90deg;
}
/* Menu styles */
[data-slot="dropdown-menu"] {
@apply p-1.5 outline-none;
}
[data-slot="menu-item"] {
@apply px-2.5;
}
}
.hv-dropdown__menu {
@apply relative flex w-full flex-col gap-0.5 overflow-clip p-1;
[data-slot="separator"] {
@apply ms-[3%] w-[94%];
}
}
+142
View File
@@ -0,0 +1,142 @@
/* Adapted from HeroUI ce90ea3. Copyright 2025 NextUI Inc.
* Apache-2.0; see third-party/HEROUI-LICENSE. hv- namespace and Vue adapters. */
/* ==========================================================================
Base menu item styles
========================================================================== */
.hv-menu-item {
@apply relative flex min-h-9 w-full items-center justify-start gap-3 rounded-2xl px-2 py-1.5 outline-none no-highlight;
/**
* Transitions
* CRITICAL: motion-reduce must be AFTER transition for correct override specificity
*/
transition:
transform 250ms var(--ease-out-quart),
box-shadow 150ms var(--ease-out);
@apply motion-reduce:transition-none;
/* Cursor */
cursor: var(--cursor-interactive);
[data-slot="label"] {
@apply pointer-events-none w-fit select-none;
}
[data-slot="description"] {
@apply pointer-events-none text-wrap select-none;
}
[data-slot="submenu-indicator"] svg {
@apply size-3.5;
}
/* Add inline-start padding when indicator is present */
&:has(.hv-menu-item__indicator) {
@apply ps-7;
}
/* Add inline-end padding when indicator is present and has submenu */
&[data-has-submenu="true"]:has(.hv-menu-item__indicator) {
@apply ps-2 pe-7;
}
/* Focus visible state (keyboard focus only). */
&:focus-visible:not([data-focused]),
&[data-focus-visible="true"] {
@apply status-focused;
}
/* Pressed state */
&:active,
&[data-pressed="true"] {
@apply will-change-transform;
transform: scale(0.98);
}
/* Hover state */
@media (hover: hover) {
&:hover,
&[data-hovered="true"] {
@apply bg-default;
}
}
/* Selected state */
&[aria-checked="true"],
&[aria-selected="true"],
&[data-selected="true"] {
[data-slot="menu-item-indicator--checkmark"] {
transition: stroke-dashoffset 100ms linear;
@apply motion-reduce:transition-none;
}
[data-slot="menu-item-indicator--dot"] {
@apply scale-100 opacity-100;
}
}
/* Disabled state */
&[data-disabled="true"] {
@apply status-disabled;
}
}
/* ==========================================================================
Menu item indicator
========================================================================== */
.hv-menu-item__indicator {
@apply absolute start-2 top-1/2 flex size-4 shrink-0 -translate-y-1/2 items-center justify-center text-muted;
@apply transition duration-250 motion-reduce:transition-none;
/* Position on the inline-end when menu item has submenu */
.hv-menu-item[data-has-submenu="true"] & {
@apply start-auto end-2;
}
/* Checkmark SVG indicator */
[data-slot="menu-item-indicator--checkmark"] {
@apply size-2.5;
.hv-menu-item[data-selection-mode="multiple"] & {
@apply transition-all duration-300 motion-reduce:transition-none;
}
}
/* Dot SVG indicator */
[data-slot="menu-item-indicator--dot"] {
@apply size-2;
.hv-menu-item[data-selection-mode="multiple"] & {
@apply transition-all duration-250 motion-reduce:transition-none;
}
@apply scale-70 opacity-0;
}
}
/* Submenu indicator (chevron-right) */
.hv-menu-item__indicator--submenu {
@apply text-muted;
svg {
@apply size-3;
}
}
/* Default variant */
.hv-menu-item--default {
}
/* Danger variant */
.hv-menu-item--danger {
.hv-menu-item__indicator {
@apply text-danger;
}
[data-slot="label"] {
@apply text-danger;
}
}
@@ -0,0 +1,9 @@
/* Adapted from HeroUI ce90ea3. Copyright 2025 NextUI Inc.
* Apache-2.0; see third-party/HEROUI-LICENSE. hv- namespace and Vue adapters. */
/* ==========================================================================
Base menu section styles
========================================================================== */
.hv-menu-section {
@apply flex flex-col items-start gap-0;
}
+14
View File
@@ -0,0 +1,14 @@
/* Adapted from HeroUI ce90ea3. Copyright 2025 NextUI Inc.
* Apache-2.0; see third-party/HEROUI-LICENSE. hv- namespace and Vue adapters. */
/* ==========================================================================
Base menu styles
========================================================================== */
.hv-menu {
@apply relative flex w-full flex-col gap-1 overflow-clip p-1;
/* This makes the separator take up 94% of the width and be centered */
[data-slot="separator"] {
@apply ms-[3%] w-[94%];
}
}