Skip to content

Commit

Permalink
Refactor #4679
Browse files Browse the repository at this point in the history
  • Loading branch information
tugcekucukoglu committed Oct 24, 2023
1 parent 5c7c744 commit 7a4690a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 18 deletions.
18 changes: 17 additions & 1 deletion api-generator/components/accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,27 @@ const AccordionEvents = [
}
];

const AccordioneSlots = [
{
name: 'default',
description: 'Custom template.'
},
{
name: 'collapseicon',
description: 'Custom collapse icon template.'
},
{
name: 'expandicon',
description: 'Custom expand icon template.'
}
];

module.exports = {
accordion: {
name: 'Accordion',
description: 'Accordion groups a collection of contents in tabs.',
props: AccordionProps,
events: AccordionEvents
events: AccordionEvents,
slots: AccordioneSlots
}
};
21 changes: 7 additions & 14 deletions components/lib/accordion/Accordion.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,20 +175,13 @@ export interface AccordionSlots {
*/
default(): VNode[];
/**
* Custom toggler icon template.
* @param {Object} scope - togglericon slot's params.
*/
togglericon(scope: {
/**
* Current index of the tab
*/
index: number;
/**
* Whether the current tab is active
* @param {number} index - Current index of the tab
*/
isTabActive: (index: number) => void;
}): VNode[];
* Custom collapse icon template.
*/
collapseicon(): VNode[];
/**
* Custom expand icon template.
*/
expandicon(): VNode[];
}

/**
Expand Down
11 changes: 8 additions & 3 deletions components/lib/accordion/Accordion.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,14 @@
v-bind="{ ...getTabProp(tab, 'headeractionprops'), ...getTabPT(tab, 'headeraction', i) }"
>
<component v-if="tab.children && tab.children.headericon" :is="tab.children.headericon" :isTabActive="isTabActive(i)" :index="i"></component>
<component v-else-if="$slots.toggleicon" :is="$slots.toggleicon" :isTabActive="isTabActive(i)" :index="i"></component>
<component v-else-if="isTabActive(i)" :is="collapseIcon ? 'span' : 'ChevronDownIcon'" :class="[cx('tab.headerIcon'), collapseIcon]" aria-hidden="true" v-bind="getTabPT(tab, 'headericon', i)" />
<component v-else :is="expandIcon ? 'span' : 'ChevronRightIcon'" :class="[cx('tab.headerIcon'), expandIcon]" aria-hidden="true" v-bind="getTabPT(tab, 'headericon', i)" />
<component
v-else-if="isTabActive(i)"
:is="$slots.collapseicon ? $slots.collapseicon : collapseIcon ? 'span' : 'ChevronDownIcon'"
:class="[cx('tab.headerIcon'), collapseIcon]"
aria-hidden="true"
v-bind="getTabPT(tab, 'headericon', i)"
/>
<component v-else :is="$slots.expandicon ? $slots.expandicon : expandIcon ? 'span' : 'ChevronRightIcon'" :class="[cx('tab.headerIcon'), expandIcon]" aria-hidden="true" v-bind="getTabPT(tab, 'headericon', i)" />
<span v-if="tab.props && tab.props.header" :class="cx('tab.headerTitle')" v-bind="getTabPT(tab, 'headertitle', i)">{{ tab.props.header }}</span>
<component v-if="tab.children && tab.children.header" :is="tab.children.header"></component>
</a>
Expand Down

0 comments on commit 7a4690a

Please sign in to comment.