chore(Tooltip): improve slots

This commit is contained in:
Benjamin Canac
2024-03-21 12:55:49 +01:00
parent 89ab141376
commit 7e1196c62c

View File

@@ -25,6 +25,8 @@ export interface TooltipEmits extends TooltipRootEmits {}
export interface TooltipSlots {
default(): any
content(): any
text(): any
shortcuts(): any
}
</script>
@@ -55,10 +57,14 @@ const ui = computed(() => tv({ extend: tooltip, slots: props.ui })())
<TooltipPortal :disabled="!portal">
<TooltipContent v-bind="contentProps" :class="ui.content({ class: props.class })">
<slot name="content">
<span :class="ui.text()">{{ text }}</span>
<span v-if="text" :class="ui.text()">
<slot name="text">{{ text }}</slot>
</span>
<span v-if="shortcuts?.length" :class="ui.shortcuts()">
<UKbd v-for="(shortcut, index) in shortcuts" :key="index" size="xs" v-bind="typeof shortcut === 'string' ? { value: shortcut } : shortcut" />
<slot name="shortcuts">
<UKbd v-for="(shortcut, index) in shortcuts" :key="index" size="xs" v-bind="typeof shortcut === 'string' ? { value: shortcut } : shortcut" />
</slot>
</span>
</slot>