From 1c9835d7f149231cf2e3e053e5ea08eceeaaa61d Mon Sep 17 00:00:00 2001 From: Benjamin Canac Date: Tue, 12 Dec 2023 19:07:46 +0100 Subject: [PATCH] feat(Dropdown): handle `labelClass` and merge `iconClass` Resolves #716 --- docs/content/2.elements/6.dropdown.md | 3 ++- src/runtime/components/elements/Dropdown.vue | 9 ++++++--- src/runtime/types/dropdown.d.ts | 1 + 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/docs/content/2.elements/6.dropdown.md b/docs/content/2.elements/6.dropdown.md index 27a7a3196e..5787310c6c 100644 --- a/docs/content/2.elements/6.dropdown.md +++ b/docs/content/2.elements/6.dropdown.md @@ -14,8 +14,9 @@ links: Pass an array of arrays to the `items` prop of the Dropdown component. Each array represents a group of items. Each item can have the following properties: - `label` - The label of the item. +- `labelClass` - The class of the item label. :u-badge{label="New" class="!rounded-full" variant="subtle"} - `icon` - The icon of the item. -- `iconClass` - The class of the icon of the item. +- `iconClass` - The class of the item icon. - `avatar` - The avatar of the item. You can pass all the props of the [Avatar](/elements/avatar) component. - `shortcuts` - The shortcuts of the item. - `slot` - The slot of the item. diff --git a/src/runtime/components/elements/Dropdown.vue b/src/runtime/components/elements/Dropdown.vue index eda249380b..bc8f8129a9 100644 --- a/src/runtime/components/elements/Dropdown.vue +++ b/src/runtime/components/elements/Dropdown.vue @@ -21,7 +21,7 @@
- + - + - {{ item.label }} + {{ item.label }} {{ shortcut }} @@ -57,6 +57,7 @@ import { defineComponent, ref, computed, toRef, onMounted, resolveComponent } fr import type { PropType } from 'vue' import { Menu as HMenu, MenuButton as HMenuButton, MenuItems as HMenuItems, MenuItem as HMenuItem } from '@headlessui/vue' import { defu } from 'defu' +import { twMerge, twJoin } from 'tailwind-merge' import UIcon from '../elements/Icon.vue' import UAvatar from '../elements/Avatar.vue' import UKbd from '../elements/Kbd.vue' @@ -214,6 +215,8 @@ export default defineComponent({ onMouseLeave, onClick, omit, + twMerge, + twJoin, NuxtLink } } diff --git a/src/runtime/types/dropdown.d.ts b/src/runtime/types/dropdown.d.ts index 1177e1862d..eae46d016e 100644 --- a/src/runtime/types/dropdown.d.ts +++ b/src/runtime/types/dropdown.d.ts @@ -3,6 +3,7 @@ import type { Avatar } from './avatar' export interface DropdownItem extends NuxtLinkProps { label: string + labelClass?: string slot?: string icon?: string iconClass?: string