Skip to content

Commit

Permalink
select+
Browse files Browse the repository at this point in the history
  • Loading branch information
hyl committed May 17, 2024
1 parent a527992 commit e867698
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/components/Select/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
</template>
</div>
<div :class="ns('select-suffix')">
<IconDropUp v-if="visible" />
<IconDropDown v-else />
<IconDropDown />
</div>
</div>
</e-dropdown>
Expand Down
10 changes: 10 additions & 0 deletions src/components/Tooltip/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ const dismiss = _.debounce((event: MouseEvent) => {
}
}, 50)
const resizeObserver = new ResizeObserver(() => {
if (visible.value) {
updatePosition()
}
})
watch(visible, (newValue) => {
if (newValue) {
nextTick(() => {
Expand All @@ -91,9 +97,13 @@ watch(visible, (newValue) => {
onMounted(() => {
window.addEventListener(triggerName.value, dismiss)
resizeObserver.observe(referenceSlot.value)
})
onUnmounted(() => {
window.removeEventListener(triggerName.value, dismiss)
resizeObserver.disconnect()
})
</script>
5 changes: 5 additions & 0 deletions src/style/select.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@include ns(select) {
$name: &;
border-radius: getVar('border', 'radius');
border: 1px solid getVar('border', 'color');
padding: 5px 10px;
Expand Down Expand Up @@ -26,9 +27,13 @@
right: 10px;
top: 50%;
transform: translateY(-50%);
transition: transform 0.2s;
}

&.is-focus {
border-color: getVar('primary', 'color');
#{$name}-suffix {
transform: translateY(-50%) rotate(180deg);
}
}
}

0 comments on commit e867698

Please sign in to comment.