Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions src/components/Tooltip/STooltip.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
:open-delay="openDelay"
:popper-class="computedPopperClass"
:manual="manual"
:hide-after="closeDelay"
:hide-after="hideAfter"
:tabindex="tabindex"
>
<slot slot="content" name="content"></slot>
Expand Down Expand Up @@ -105,6 +105,12 @@ export default class STooltip extends Mixins(BorderRadiusMixin, DesignSystemInje
* `0` by default
*/
@Prop({ default: 0, type: Number }) readonly closeDelay!: number
/**
* Timeout in milliseconds to hide tooltip after appearing.
*
* `0` by default
*/
@Prop({ default: 0, type: Number }) readonly hideAfter!: number
/**
* Tabindex of the tooltip.
*
Expand Down Expand Up @@ -142,12 +148,13 @@ export default class STooltip extends Mixins(BorderRadiusMixin, DesignSystemInje
this.$emit('change', value)
}

@Watch('closeDelay')
private handleChangeCloseDelay (value: number): void {
this.updateCloseDelay(value)
}

mounted (): void {
const tooltip = this.tooltip
if (!tooltip) {
return
}
tooltip.debounceClose = debounce(200, tooltip.handleClosePopper)
this.updateCloseDelay(this.closeDelay)
}

get computedTheme (): string {
Expand All @@ -160,5 +167,13 @@ export default class STooltip extends Mixins(BorderRadiusMixin, DesignSystemInje
}
return this.theme
}

updateCloseDelay (value: number): void {
const tooltip = this.tooltip
if (!tooltip) {
return
}
tooltip.debounceClose = debounce(value, tooltip.handleClosePopper)
}
}
</script>
10 changes: 9 additions & 1 deletion src/stories/STooltip.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ export const configurable = () => ({
:disabled="disabled"
:border-radius="borderRadius"
:offset="offset"
:openDelay="openDelay"
:open-delay="openDelay"
:close-delay="closeDelay"
:hide-after="hideAfter"
@change="handleChange"
>
<s-button style="margin: 40px">Custom tooltip</s-button>
Expand All @@ -48,6 +50,12 @@ export const configurable = () => ({
},
openDelay: {
default: number('Open delay', 0)
},
closeDelay: {
default: number('Close delay', 0)
},
hideAfter: {
default: number('Hide after', 0)
}
},
methods: {
Expand Down