Skip to content

Commit

Permalink
Adding slot for arrow icon riophae#473
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Vermeersch committed Jan 18, 2023
1 parent 41d77a8 commit 6b2ce7e
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 8 deletions.
4 changes: 4 additions & 0 deletions docs/components/DocSlots.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
name: 'after-list',
props: '-',
description: `Slot showed after the menu list.`,
}, {
name: 'arrow-icon',
props: '-',
description: `Slot for a custom arrow icon.`,
} ],
}),
}
Expand Down
17 changes: 15 additions & 2 deletions src/components/Control.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,31 @@
)
},
renderArrow() {
getArrow() {
const { instance } = this
const arrowIconRenderer = instance.$scopedSlots['arrow-icon']
const arrowClass = {
'vue-treeselect__control-arrow': true,
'vue-treeselect__control-arrow--rotated': instance.menu.isOpen,
'vue-treeselect__control-arrow--custom': arrowIconRenderer,
}
if (arrowIconRenderer) {
return (
<div class={arrowClass}> { arrowIconRenderer() }</div>
)
}
return <ArrowIcon class={arrowClass} />
},
renderArrow() {
if (!this.shouldShowArrow) return null
return (
<div class="vue-treeselect__control-arrow-container" onMousedown={this.handleMouseDownOnArrow}>
<ArrowIcon class={arrowClass} />
{ this.getArrow() }
</div>
)
},
Expand Down
26 changes: 20 additions & 6 deletions src/components/Option.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,25 @@
)
},
getArrow() {
const { instance } = this
const arrowIconRenderer = instance.$scopedSlots['arrow-icon']
const arrowClass = {
'vue-treeselect__option-arrow': true,
'vue-treeselect__option-arrow--rotated': this.shouldExpand,
'vue-treeselect__option-arrow--custom': arrowIconRenderer,
}
if (arrowIconRenderer) {
return (
<div class={arrowClass}> { arrowIconRenderer() }</div>
)
}
return <ArrowIcon class={arrowClass} />
},
renderArrow() {
const { instance, node } = this
Expand All @@ -81,15 +100,11 @@
appear: true,
},
}
const arrowClass = {
'vue-treeselect__option-arrow': true,
'vue-treeselect__option-arrow--rotated': this.shouldExpand,
}
return (
<div class="vue-treeselect__option-arrow-container" onMousedown={this.handleMouseDownOnArrow}>
<transition {...transitionProps}>
<ArrowIcon class={arrowClass} />
{ this.getArrow() }
</transition>
</div>
)
Expand Down Expand Up @@ -134,7 +149,6 @@
const { instance, node } = this
const checkedState = instance.forest.checkedStateMap[node.id]
const checkboxClass = {
'uk-checkbox': true,
'vue-treeselect__checkbox': true,
'vue-treeselect__checkbox--checked': checkedState === CHECKED,
'vue-treeselect__checkbox--indeterminate': checkedState === INDETERMINATE,
Expand Down

0 comments on commit 6b2ce7e

Please sign in to comment.