fix: align Dropdown/Menu with the HeroUI baseline after fidelity audit
- menu-item.css keys disabled styling off the presence attribute Reka emits. - Dropdown surfaces drive the ported enter/exit animations and use data-side for placement-specific motion. - One role=menu per popup; items render their key as DOM id; submenu surfaces point aria-labelledby at the real trigger; MenuSection names its group from a nested Header. - Custom (asChild) triggers stay keyboard focusable; library Button/Avatar keep their own layout instead of the custom-trigger rules. - Items emit data-focused/data-hovered/data-pressed, expose the upstream render props to slots, and merge caller classes through tailwind-variants. - Submenu triggers declare hasSubmenu explicitly and forward class/ARIA; the default submenu indicator uses the baseline chevron artwork. - Demos restore Kbd slot="keyboard" (27x), IconSquarePlus, and remove the added comment, stray space and duplicated indicator SVGs. - Document the page after the official structure and API tables, including renamed props, Vue extensions and remaining gaps.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import { defineComponent, h, ref } from "vue";
|
||||
import {
|
||||
DropdownRoot,
|
||||
DropdownTrigger,
|
||||
@@ -15,6 +15,30 @@ import {
|
||||
import type { MenuKey } from "@heroui-vue/components";
|
||||
|
||||
const selected = ref<MenuKey[]>(["apple"]);
|
||||
|
||||
// 官方示例用一个自定义图标常量复用给每个条目;Vue 端用同名组件保持单一来源。
|
||||
const CustomCheckmarkIcon = defineComponent({
|
||||
name: "CustomCheckmarkIcon",
|
||||
setup: () => () =>
|
||||
h(
|
||||
"svg",
|
||||
{
|
||||
height: "16",
|
||||
viewBox: "0 0 16 16",
|
||||
width: "16",
|
||||
xmlns: "http://www.w3.org/2000/svg",
|
||||
},
|
||||
[
|
||||
h("path", {
|
||||
class: "text-accent",
|
||||
"clip-rule": "evenodd",
|
||||
d: "M8 15A7 7 0 1 0 8 1a7 7 0 0 0 0 14m3.1-8.55a.75.75 0 1 0-1.2-.9L7.419 8.858L6.03 7.47a.75.75 0 0 0-1.06 1.06l2 2a.75.75 0 0 0 1.13-.08z",
|
||||
fill: "currentColor",
|
||||
"fill-rule": "evenodd",
|
||||
}),
|
||||
],
|
||||
),
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<DropdownRoot>
|
||||
@@ -31,102 +55,32 @@ const selected = ref<MenuKey[]>(["apple"]);
|
||||
<Header>选择水果</Header>
|
||||
<DropdownItem id="apple" text-value="苹果">
|
||||
<DropdownItemIndicator v-slot="{ isSelected }">
|
||||
<svg
|
||||
v-if="isSelected"
|
||||
height="16"
|
||||
viewBox="0 0 16 16"
|
||||
width="16"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
class="text-accent"
|
||||
clip-rule="evenodd"
|
||||
d="M8 15A7 7 0 1 0 8 1a7 7 0 0 0 0 14m3.1-8.55a.75.75 0 1 0-1.2-.9L7.419 8.858L6.03 7.47a.75.75 0 0 0-1.06 1.06l2 2a.75.75 0 0 0 1.13-.08z"
|
||||
fill="currentColor"
|
||||
fill-rule="evenodd"
|
||||
/>
|
||||
</svg>
|
||||
<CustomCheckmarkIcon v-if="isSelected" />
|
||||
</DropdownItemIndicator>
|
||||
<Label>苹果</Label>
|
||||
</DropdownItem>
|
||||
<DropdownItem id="banana" text-value="香蕉">
|
||||
<DropdownItemIndicator v-slot="{ isSelected }">
|
||||
<svg
|
||||
v-if="isSelected"
|
||||
height="16"
|
||||
viewBox="0 0 16 16"
|
||||
width="16"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
class="text-accent"
|
||||
clip-rule="evenodd"
|
||||
d="M8 15A7 7 0 1 0 8 1a7 7 0 0 0 0 14m3.1-8.55a.75.75 0 1 0-1.2-.9L7.419 8.858L6.03 7.47a.75.75 0 0 0-1.06 1.06l2 2a.75.75 0 0 0 1.13-.08z"
|
||||
fill="currentColor"
|
||||
fill-rule="evenodd"
|
||||
/>
|
||||
</svg>
|
||||
<CustomCheckmarkIcon v-if="isSelected" />
|
||||
</DropdownItemIndicator>
|
||||
<Label>香蕉</Label>
|
||||
</DropdownItem>
|
||||
<DropdownItem id="cherry" text-value="樱桃">
|
||||
<DropdownItemIndicator v-slot="{ isSelected }">
|
||||
<svg
|
||||
v-if="isSelected"
|
||||
height="16"
|
||||
viewBox="0 0 16 16"
|
||||
width="16"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
class="text-accent"
|
||||
clip-rule="evenodd"
|
||||
d="M8 15A7 7 0 1 0 8 1a7 7 0 0 0 0 14m3.1-8.55a.75.75 0 1 0-1.2-.9L7.419 8.858L6.03 7.47a.75.75 0 0 0-1.06 1.06l2 2a.75.75 0 0 0 1.13-.08z"
|
||||
fill="currentColor"
|
||||
fill-rule="evenodd"
|
||||
/>
|
||||
</svg>
|
||||
<CustomCheckmarkIcon v-if="isSelected" />
|
||||
</DropdownItemIndicator>
|
||||
<Label>樱桃</Label>
|
||||
</DropdownItem>
|
||||
</DropdownSection>
|
||||
<DropdownItem id="orange" text-value="橙子">
|
||||
<DropdownItemIndicator v-slot="{ isSelected }">
|
||||
<svg
|
||||
v-if="isSelected"
|
||||
height="16"
|
||||
viewBox="0 0 16 16"
|
||||
width="16"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
class="text-accent"
|
||||
clip-rule="evenodd"
|
||||
d="M8 15A7 7 0 1 0 8 1a7 7 0 0 0 0 14m3.1-8.55a.75.75 0 1 0-1.2-.9L7.419 8.858L6.03 7.47a.75.75 0 0 0-1.06 1.06l2 2a.75.75 0 0 0 1.13-.08z"
|
||||
fill="currentColor"
|
||||
fill-rule="evenodd"
|
||||
/>
|
||||
</svg>
|
||||
<CustomCheckmarkIcon v-if="isSelected" />
|
||||
</DropdownItemIndicator>
|
||||
<Label>橙子</Label>
|
||||
</DropdownItem>
|
||||
<DropdownItem id="pear" text-value="梨">
|
||||
<DropdownItemIndicator v-slot="{ isSelected }">
|
||||
<svg
|
||||
v-if="isSelected"
|
||||
height="16"
|
||||
viewBox="0 0 16 16"
|
||||
width="16"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
class="text-accent"
|
||||
clip-rule="evenodd"
|
||||
d="M8 15A7 7 0 1 0 8 1a7 7 0 0 0 0 14m3.1-8.55a.75.75 0 1 0-1.2-.9L7.419 8.858L6.03 7.47a.75.75 0 0 0-1.06 1.06l2 2a.75.75 0 0 0 1.13-.08z"
|
||||
fill="currentColor"
|
||||
fill-rule="evenodd"
|
||||
/>
|
||||
</svg>
|
||||
<CustomCheckmarkIcon v-if="isSelected" />
|
||||
</DropdownItemIndicator>
|
||||
<Label>梨</Label>
|
||||
</DropdownItem>
|
||||
|
||||
Reference in New Issue
Block a user