Skip to content

Commit

Permalink
feat(NavigationMenu): handle item.trailingIcon display
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamincanac committed Dec 5, 2024
1 parent 816bb69 commit 4b653ef
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion playground/app/pages/components/navigation-menu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ const items = [
label: 'NavigationMenu',
icon: 'i-lucide-file',
description: 'Display a list of links.',
to: '/components/navigation-menu'
to: '/components/navigation-menu',
trailingIcon: 'i-lucide-check'
}, {
label: 'Pagination',
icon: 'i-lucide-file',
Expand Down
3 changes: 2 additions & 1 deletion src/runtime/components/NavigationMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ const lists = computed(() => props.items?.length ? (Array.isArray(props.items[0]
<UIcon v-if="item.target === '_blank'" :name="appConfig.ui.icons.external" :class="ui.linkLabelExternalIcon({ class: props.ui?.linkLabelExternalIcon, active })" />
</span>

<span v-if="item.badge || item.children?.length || !!slots[item.slot ? `${item.slot}-trailing` : 'item-trailing']" :class="ui.linkTrailing({ class: props.ui?.linkTrailing })">
<span v-if="item.badge || (orientation === 'horizontal' && (item.children?.length || !!slots[item.slot ? `${item.slot}-content` : 'item-content'])) || (orientation === 'vertical' && item.children?.length) || item.trailingIcon || !!slots[item.slot ? `${item.slot}-trailing` : 'item-trailing']" :class="ui.linkTrailing({ class: props.ui?.linkTrailing })">
<slot :name="item.slot ? `${item.slot}-trailing` : 'item-trailing'" :item="(item as T)" :active="active" :index="index">
<UBadge
v-if="item.badge"
Expand All @@ -199,6 +199,7 @@ const lists = computed(() => props.items?.length ? (Array.isArray(props.items[0]
/>

<UIcon v-if="(orientation === 'horizontal' && (item.children?.length || !!slots[item.slot ? `${item.slot}-content` : 'item-content'])) || (orientation === 'vertical' && item.children?.length)" :name="item.trailingIcon || trailingIcon || appConfig.ui.icons.chevronDown" :class="ui.linkTrailingIcon({ class: props.ui?.linkTrailingIcon, active })" />
<UIcon v-else-if="item.trailingIcon" :name="item.trailingIcon" :class="ui.linkTrailingIcon({ class: props.ui?.linkTrailingIcon, active })" />
</slot>
</span>
</slot>
Expand Down

0 comments on commit 4b653ef

Please sign in to comment.