|
71 | 71 | import { createEventDispatcher, afterUpdate, setContext } from "svelte";
|
72 | 72 | import { writable } from "svelte/store";
|
73 | 73 | import Information from "../icons/Information.svelte";
|
| 74 | + import Popover from "../Popover/Popover.svelte"; |
| 75 | + import PopoverContent from "../Popover/PopoverContent.svelte"; |
74 | 76 |
|
75 | 77 | const dispatch = createEventDispatcher();
|
76 | 78 | const tooltipOpen = writable(open);
|
|
204 | 206 | style:z-index="{open ? 1 : undefined}"
|
205 | 207 | {...$$restProps}
|
206 | 208 | >
|
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> |
210 | 212 | <!-- svelte-ignore a11y-no-static-element-interactions -->
|
211 | 213 | <div
|
212 | 214 | bind:this="{refIcon}"
|
|
220 | 222 | <svelte:component this="{icon}" name="{iconName}" />
|
221 | 223 | </slot>
|
222 | 224 | </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> |
265 | 226 | <slot />
|
266 |
| - </div> |
267 |
| - </div> |
268 |
| - {/if} |
| 227 | + </PopoverContent> |
| 228 | + </Popover> |
| 229 | + </div> |
269 | 230 | </div>
|
0 commit comments