Skip to content

Commit

Permalink
Refactor #5682 - For Dock, Menubar
Browse files Browse the repository at this point in the history
  • Loading branch information
tugcekucukoglu committed May 6, 2024
1 parent 5353635 commit 89b4e1a
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 11 deletions.
15 changes: 13 additions & 2 deletions components/lib/dock/Dock.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,12 +274,23 @@ export interface DockSlots {
props: DockRouterBindProps;
}): VNode[];
/**
* @deprecated since v4.0. Use 'itemicon' slot.
* Custom icon content.
* @param {Object} scope - icon slot's params.
* @param {Object} scope - item icon slot's params.
*/
icon(scope: {
/**
* Custom content for icon.
* Custom content for item icon.
*/
item: MenuItem;
}): VNode[];
/**
* Custom icon content.
* @param {Object} scope - item icon slot's params.
*/
itemicon(scope: {
/**
* Custom content for item icon.
*/
item: MenuItem;
}): VNode[];
Expand Down
5 changes: 3 additions & 2 deletions components/lib/dock/DockSub.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@
aria-hidden="true"
v-bind="getPTOptions('itemLink', processedItem, index)"
>
<template v-if="!templates['icon']">
<!-- TODO: icon deprecated since v4.0-->
<template v-if="!templates['icon'] && !templates['itemicon']">
<span v-ripple :class="[cx('itemIcon'), processedItem.icon]" v-bind="getPTOptions('itemIcon', processedItem, index)"></span>
</template>
<component v-else :is="templates['icon']" :item="processedItem" :class="cx('itemIcon')"></component>
<component v-else :is="templates['icon'] || templates['itemicon']" :item="processedItem" :class="cx('itemIcon')"></component>
</a>
</template>
<component v-else :is="templates['item']" :item="processedItem" :index="index" :label="processedItem.label" :props="getMenuItemProps(processedItem, index)"></component>
Expand Down
32 changes: 28 additions & 4 deletions components/lib/menubar/Menubar.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export interface MenubarPassThroughOptions {
/**
* Used to pass attributes to the mobile menu button icon's DOM element.
*/
menubuttonicon?: MenubarPassThroughOptionType;
buttonicon?: MenubarPassThroughOptionType;
/**
* Used to pass attributes to the submenu's DOM element.
*/
Expand Down Expand Up @@ -318,6 +318,7 @@ export interface MenubarSlots {
hasSubmenu: boolean;
}): VNode[];
/**
* @deprecated since v4.0. use 'button' slot instead.
* Custom menu button template on responsive mode.
* @param {Object} scope - menu button slot's params.
*/
Expand All @@ -337,14 +338,37 @@ export interface MenubarSlots {
toggleCallback: () => void;
}): VNode[];
/**
* Custom popup icon template on responsive mode.
* @deprecated since v3.42.0. Use 'menubuttonicon' slot instead.
* Custom menu button template on responsive mode.
* @param {Object} scope - menu button slot's params.
*/
popupicon(): VNode[];
button(scope: {
/**
* Current id state as a string
*/
id: string;
/**
* Style class of component
*/
class: string;
/**
*
* Toggle event
*/
toggleCallback: () => void;
}): VNode[];
/**
* @deprecated since v4.0. use 'buttonicon' slot instead.
* Custom menu button icon template on responsive mode.
*/
menubuttonicon(): VNode[];
/**
* Custom submenu icon template.
* @param {Object} scope - submenuicon slot's params.
*/
/**
* Custom menu button icon template on responsive mode.
*/
buttonicon(): VNode[];
/**
* Custom submenu icon template.
* @param {Object} scope - submenuicon slot's params.
Expand Down
8 changes: 5 additions & 3 deletions components/lib/menubar/Menubar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
<div v-if="$slots.start" :class="cx('start')" v-bind="ptm('start')">
<slot name="start"></slot>
</div>
<slot :id="id" name="menubutton" :class="cx('button')" :toggleCallback="(event) => menuButtonClick(event)">
<slot :id="id" :name="$slots.button ? 'button' : 'menubutton'" :class="cx('button')" :toggleCallback="(event) => menuButtonClick(event)">
<!-- TODO: menubutton deprecated since v4.0-->
<a
v-if="model && model.length > 0"
ref="menubutton"
Expand All @@ -18,8 +19,9 @@
@keydown="menuButtonKeydown($event)"
v-bind="{ ...buttonProps, ...ptm('button') }"
>
<slot name="menubuttonicon">
<BarsIcon v-bind="ptm('menubuttonicon')" />
<!-- TODO: menubuttonicon deprecated since v4.0-->
<slot :name="$slots.buttonicon ? 'buttonicon' : 'menubuttonicon'">
<BarsIcon v-bind="ptm('buttonicon')" />
</slot>
</a>
</slot>
Expand Down

0 comments on commit 89b4e1a

Please sign in to comment.