Skip to content

Commit

Permalink
Adding slot for arrow icon
Browse files Browse the repository at this point in the history
Will give the flexibility to change the arrow icon of the select box (many design teams ask for it) closing issue riophae#322 in a more elegant way than the other PR suggested.
  • Loading branch information
avivday committed Sep 7, 2021
1 parent 9ae16b6 commit 6a771ff
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
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
4 changes: 4 additions & 0 deletions src/style.less
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,10 @@
}
}

.vue-treeselect__control-arrow--custom {
height: unset;
}

.vue-treeselect__control-arrow--rotated {
transform: rotateZ(180deg);
}
Expand Down

0 comments on commit 6a771ff

Please sign in to comment.