feat(VerticalNavigation)!: use Badge component for consistency

This commit is contained in:
Benjamin Canac
2024-01-24 17:03:25 +01:00
parent 5ff566f0a4
commit 3e81eee6e6
4 changed files with 19 additions and 8 deletions

View File

@@ -16,7 +16,7 @@ Pass an array to the `links` prop of the VerticalNavigation component. Each link
- `icon` - The icon of the link.
- `iconClass` - The class of the link icon.
- `avatar` - The avatar of the link. You can pass all the props of the [Avatar](/elements/avatar) component.
- `badge` - A badge to display next to the label.
- `badge` - A badge to display next to the label. You can pass all the props of the [Badge](/elements/badge) component.
- `click` - The click handler of the link.
You can also pass any property from the [NuxtLink](https://nuxt.com/docs/api/components/nuxt-link#props) component such as `to`, `exact`, etc.

View File

@@ -34,9 +34,16 @@
</span>
</slot>
<slot name="badge" :link="link" :is-active="isActive">
<span v-if="link.badge" :class="[ui.badge.base, isActive ? ui.badge.active : ui.badge.inactive]">
{{ link.badge }}
</span>
<UBadge
v-if="link.badge"
v-bind="{
size: ui.badge.size,
color: ui.badge.color,
variant: ui.badge.variant,
...((typeof link.badge === 'string' || typeof link.badge === 'number') ? { label: link.badge } : link.badge)
}"
:class="ui.badge.base"
/>
</slot>
</ULink>
</li>
@@ -51,6 +58,7 @@ import type { PropType } from 'vue'
import { twMerge, twJoin } from 'tailwind-merge'
import UIcon from '../elements/Icon.vue'
import UAvatar from '../elements/Avatar.vue'
import UBadge from '../elements/Badge.vue'
import ULink from '../elements/Link.vue'
import UDivider from '../layout/Divider.vue'
import { useUI } from '../../composables/useUI'
@@ -66,6 +74,7 @@ export default defineComponent({
components: {
UIcon,
UAvatar,
UBadge,
ULink,
UDivider
},

View File

@@ -1,5 +1,6 @@
import type { Link } from './link'
import type { Avatar } from './avatar'
import type { Badge } from './badge'
export interface VerticalNavigationLink extends Link {
label: string
@@ -8,5 +9,5 @@ export interface VerticalNavigationLink extends Link {
iconClass?: string
avatar?: Avatar
click?: Function
badge?: string | number
badge?: string | number | Badge
}

View File

@@ -20,9 +20,10 @@ export default {
size: '3xs' as const
},
badge: {
base: 'relative ms-auto inline-block py-0.5 px-2 text-xs rounded-md -me-1 -my-0.5',
active: 'bg-white dark:bg-gray-900',
inactive: 'bg-gray-100 dark:bg-gray-800 text-gray-900 dark:text-white group-hover:bg-white dark:group-hover:bg-gray-900'
base: 'flex-shrink-0 ml-auto relative rounded',
color: 'gray' as const,
variant: 'solid' as const,
size: 'xs' as const
},
divider: {
wrapper: {