Skip to content

Commit 2275ed3

Browse files
committed
tooltip
1 parent 386d330 commit 2275ed3

File tree

1 file changed

+9
-48
lines changed

1 file changed

+9
-48
lines changed

src/Tooltip/Tooltip.svelte

+9-48
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@
7171
import { createEventDispatcher, afterUpdate, setContext } from "svelte";
7272
import { writable } from "svelte/store";
7373
import Information from "../icons/Information.svelte";
74+
import Popover from "../Popover/Popover.svelte";
75+
import PopoverContent from "../Popover/PopoverContent.svelte";
7476
7577
const dispatch = createEventDispatcher();
7678
const tooltipOpen = writable(open);
@@ -204,9 +206,9 @@
204206
style:z-index="{open ? 1 : undefined}"
205207
{...$$restProps}
206208
>
207-
{#if !hideIcon}
208-
<div bind:this="{ref}" id="{triggerId}" class:bx--tooltip__label="{true}">
209-
<slot name="triggerText">{triggerText}</slot>
209+
<div bind:this="{ref}" id="{triggerId}" class:bx--tooltip__label="{true}">
210+
<slot name="triggerText">{triggerText}</slot> <!-- todo: remove this. it’s only kept for legacy. -->
211+
<Popover bind:open highContrast>
210212
<!-- svelte-ignore a11y-no-static-element-interactions -->
211213
<div
212214
bind:this="{refIcon}"
@@ -220,50 +222,9 @@
220222
<svelte:component this="{icon}" name="{iconName}" />
221223
</slot>
222224
</div>
223-
</div>
224-
{:else}
225-
<!-- svelte-ignore a11y-no-static-element-interactions -->
226-
<div
227-
bind:this="{ref}"
228-
{...buttonProps}
229-
aria-describedby="{tooltipId}"
230-
on:mousedown="{onMousedown}"
231-
on:focus="{onFocus}"
232-
on:blur="{onBlur}"
233-
on:keydown="{onKeydown}"
234-
>
235-
<slot name="triggerText">{triggerText}</slot>
236-
</div>
237-
{/if}
238-
{#if open}
239-
<!-- svelte-ignore a11y-no-static-element-interactions -->
240-
<div
241-
bind:this="{refTooltip}"
242-
id="{tooltipId}"
243-
data-floating-menu-direction="{direction}"
244-
class:bx--tooltip="{true}"
245-
class:bx--tooltip--shown="{open}"
246-
class:bx--tooltip--top="{direction === 'top'}"
247-
class:bx--tooltip--right="{direction === 'right'}"
248-
class:bx--tooltip--bottom="{direction === 'bottom'}"
249-
class:bx--tooltip--left="{direction === 'left'}"
250-
class:bx--tooltip--align-center="{align === 'center'}"
251-
class:bx--tooltip--align-start="{align === 'start'}"
252-
class:bx--tooltip--align-end="{align === 'end'}"
253-
on:keydown="{onKeydown}"
254-
>
255-
<span class:bx--tooltip__caret="{true}"></span>
256-
<!-- svelte-ignore a11y-click-events-have-key-events -->
257-
<!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
258-
<div
259-
on:click|stopPropagation
260-
on:mousedown|stopPropagation
261-
class:bx--tooltip__content="{true}"
262-
tabindex="-1"
263-
role="dialog"
264-
>
225+
<PopoverContent>
265226
<slot />
266-
</div>
267-
</div>
268-
{/if}
227+
</PopoverContent>
228+
</Popover>
229+
</div>
269230
</div>

0 commit comments

Comments
 (0)