2021-05-23 16:40:00 +02:00
|
|
|
<script>
|
|
|
|
import "@spectrum-css/tooltip/dist/index-vars.css"
|
|
|
|
|
|
|
|
export let direction = "top"
|
|
|
|
export let text = ""
|
2021-11-12 14:31:55 +01:00
|
|
|
export let textWrapping = false
|
2021-05-23 16:40:00 +02:00
|
|
|
</script>
|
|
|
|
|
2021-11-12 14:31:55 +01:00
|
|
|
<!-- Showing / Hiding a text wrapped tooltip should be handled outside the component -->
|
|
|
|
{#if textWrapping}
|
2022-04-12 16:34:34 +02:00
|
|
|
<span class="spectrum-Tooltip spectrum-Tooltip--{direction} is-open tooltip">
|
2021-05-23 16:40:00 +02:00
|
|
|
<span class="spectrum-Tooltip-label">{text}</span>
|
|
|
|
<span class="spectrum-Tooltip-tip" />
|
2021-11-12 14:31:55 +01:00
|
|
|
</span>
|
|
|
|
{:else}
|
|
|
|
<!-- The default show on hover tooltip does not support text wrapping -->
|
|
|
|
<span class="u-tooltip-showOnHover tooltip">
|
|
|
|
<slot />
|
|
|
|
<div class={`spectrum-Tooltip spectrum-Tooltip--${direction}`}>
|
|
|
|
<span class="spectrum-Tooltip-label">{text}</span>
|
|
|
|
<span class="spectrum-Tooltip-tip" />
|
|
|
|
</div>
|
|
|
|
</span>
|
|
|
|
{/if}
|
2022-04-12 16:34:34 +02:00
|
|
|
|
|
|
|
<style>
|
|
|
|
.tooltip {
|
|
|
|
pointer-events: none;
|
|
|
|
}
|
|
|
|
</style>
|