Skip to content

Commit

Permalink
Refactor #3832 Refactor #3833 - For TabMenu
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Apr 17, 2023
1 parent 3ed2355 commit 4858a1f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
4 changes: 4 additions & 0 deletions api-generator/components/tabmenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ const TabMenuSlots = [
{
name: 'item',
description: 'Template of a menuitem.'
},
{
name: 'itemicon',
description: 'Custom item icon template.'
}
];

Expand Down
14 changes: 14 additions & 0 deletions components/lib/tabmenu/TabMenu.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,20 @@ export interface TabMenuSlots {
*/
item: MenuItem;
}): VNode[];
/**
* Custom item icon template.
* @param {Object} scope - item icon slot's params.
*/
itemicon(scope: {
/**
* Menuitem instance
*/
item: MenuItem;
/**
* Style class of the item icon element.
*/
class: any;
}): VNode[];
}

/**
Expand Down
4 changes: 2 additions & 2 deletions components/lib/tabmenu/TabMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
@click="onItemClick($event, item, i, navigate)"
@keydown="onKeydownItem($event, item, i, navigate)"
>
<span v-if="item.icon" :class="getItemIcon(item)"></span>
<component :is="$slots.itemicon || (item.icon ? 'span' : undefined)" :item="item" :class="getItemIcon(item)" />
<span class="p-menuitem-text">{{ label(item) }}</span>
</a>
</template>
Expand All @@ -27,7 +27,7 @@
<li v-else-if="visible(item)" ref="tab" :class="getItemClass(item, i)" role="presentation" @click="onItemClick($event, item, i)" @keydown="onKeydownItem($event, item, i)">
<template v-if="!$slots.item">
<a ref="tabLink" v-ripple role="menuitem" :href="item.url" class="p-menuitem-link" :target="item.target" :aria-label="label(item)" :aria-disabled="disabled(item)" :tabindex="setTabIndex(i)">
<span v-if="item.icon" :class="getItemIcon(item)"></span>
<component :is="$slots.itemicon || (item.icon ? 'span' : undefined)" :item="item" :class="getItemIcon(item)" />
<span class="p-menuitem-text">{{ label(item) }}</span>
</a>
</template>
Expand Down

0 comments on commit 4858a1f

Please sign in to comment.