mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-31 04:07:56 +01:00
feat(VerticalNavigation)!: use Badge component for consistency
This commit is contained in:
@@ -16,7 +16,7 @@ Pass an array to the `links` prop of the VerticalNavigation component. Each link
|
|||||||
- `icon` - The icon of the link.
|
- `icon` - The icon of the link.
|
||||||
- `iconClass` - The class of the link icon.
|
- `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.
|
- `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.
|
- `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.
|
You can also pass any property from the [NuxtLink](https://nuxt.com/docs/api/components/nuxt-link#props) component such as `to`, `exact`, etc.
|
||||||
|
|||||||
@@ -34,9 +34,16 @@
|
|||||||
</span>
|
</span>
|
||||||
</slot>
|
</slot>
|
||||||
<slot name="badge" :link="link" :is-active="isActive">
|
<slot name="badge" :link="link" :is-active="isActive">
|
||||||
<span v-if="link.badge" :class="[ui.badge.base, isActive ? ui.badge.active : ui.badge.inactive]">
|
<UBadge
|
||||||
{{ link.badge }}
|
v-if="link.badge"
|
||||||
</span>
|
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>
|
</slot>
|
||||||
</ULink>
|
</ULink>
|
||||||
</li>
|
</li>
|
||||||
@@ -51,6 +58,7 @@ import type { PropType } from 'vue'
|
|||||||
import { twMerge, twJoin } from 'tailwind-merge'
|
import { twMerge, twJoin } from 'tailwind-merge'
|
||||||
import UIcon from '../elements/Icon.vue'
|
import UIcon from '../elements/Icon.vue'
|
||||||
import UAvatar from '../elements/Avatar.vue'
|
import UAvatar from '../elements/Avatar.vue'
|
||||||
|
import UBadge from '../elements/Badge.vue'
|
||||||
import ULink from '../elements/Link.vue'
|
import ULink from '../elements/Link.vue'
|
||||||
import UDivider from '../layout/Divider.vue'
|
import UDivider from '../layout/Divider.vue'
|
||||||
import { useUI } from '../../composables/useUI'
|
import { useUI } from '../../composables/useUI'
|
||||||
@@ -66,6 +74,7 @@ export default defineComponent({
|
|||||||
components: {
|
components: {
|
||||||
UIcon,
|
UIcon,
|
||||||
UAvatar,
|
UAvatar,
|
||||||
|
UBadge,
|
||||||
ULink,
|
ULink,
|
||||||
UDivider
|
UDivider
|
||||||
},
|
},
|
||||||
|
|||||||
3
src/runtime/types/vertical-navigation.d.ts
vendored
3
src/runtime/types/vertical-navigation.d.ts
vendored
@@ -1,5 +1,6 @@
|
|||||||
import type { Link } from './link'
|
import type { Link } from './link'
|
||||||
import type { Avatar } from './avatar'
|
import type { Avatar } from './avatar'
|
||||||
|
import type { Badge } from './badge'
|
||||||
|
|
||||||
export interface VerticalNavigationLink extends Link {
|
export interface VerticalNavigationLink extends Link {
|
||||||
label: string
|
label: string
|
||||||
@@ -8,5 +9,5 @@ export interface VerticalNavigationLink extends Link {
|
|||||||
iconClass?: string
|
iconClass?: string
|
||||||
avatar?: Avatar
|
avatar?: Avatar
|
||||||
click?: Function
|
click?: Function
|
||||||
badge?: string | number
|
badge?: string | number | Badge
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,9 +20,10 @@ export default {
|
|||||||
size: '3xs' as const
|
size: '3xs' as const
|
||||||
},
|
},
|
||||||
badge: {
|
badge: {
|
||||||
base: 'relative ms-auto inline-block py-0.5 px-2 text-xs rounded-md -me-1 -my-0.5',
|
base: 'flex-shrink-0 ml-auto relative rounded',
|
||||||
active: 'bg-white dark:bg-gray-900',
|
color: 'gray' as const,
|
||||||
inactive: 'bg-gray-100 dark:bg-gray-800 text-gray-900 dark:text-white group-hover:bg-white dark:group-hover:bg-gray-900'
|
variant: 'solid' as const,
|
||||||
|
size: 'xs' as const
|
||||||
},
|
},
|
||||||
divider: {
|
divider: {
|
||||||
wrapper: {
|
wrapper: {
|
||||||
|
|||||||
Reference in New Issue
Block a user