|
4 | 4 | * @event {null} close
|
5 | 5 | */
|
6 | 6 |
|
7 |
| - /** Specify the tooltip text */ |
8 |
| - export let tooltipText = ""; |
| 7 | + /** Specify the term definition. */ |
| 8 | + export let definition = ""; |
9 | 9 |
|
10 | 10 | /**
|
11 | 11 | * Set to `true` to open the tooltip
|
|
14 | 14 |
|
15 | 15 | /**
|
16 | 16 | * Set the alignment of the tooltip relative to the icon
|
17 |
| - * @type {"start" | "center" | "end"} |
| 17 | + * @type {"top" | "top-left" | "top-right" | "bottom" | "bottom-left" | "bottom-right" | "left" | "left-bottom" | "left-top" | "right" | "right-bottom" | "right-top"} |
18 | 18 | */
|
19 |
| - export let align = "center"; |
20 |
| -
|
21 |
| - /** |
22 |
| - * Set the direction of the tooltip relative to the icon |
23 |
| - * @type {"top" | "bottom"} |
24 |
| - */ |
25 |
| - export let direction = "bottom"; |
| 19 | + export let align = "bottom-left"; |
26 | 20 |
|
27 | 21 | /** Set an id for the tooltip div element */
|
28 | 22 | export let id = "ccs-" + Math.random().toString(36);
|
|
31 | 25 | export let ref = null;
|
32 | 26 |
|
33 | 27 | import { createEventDispatcher } from "svelte";
|
| 28 | + import Popover from "../Popover/Popover.svelte"; |
| 29 | + import PopoverContent from "../Popover/PopoverContent.svelte"; |
34 | 30 |
|
35 | 31 | const dispatch = createEventDispatcher();
|
36 | 32 |
|
|
48 | 44 | />
|
49 | 45 |
|
50 | 46 | <!-- svelte-ignore a11y-no-static-element-interactions -->
|
51 |
| -<span |
52 |
| - class:bx--tooltip--definition="{true}" |
53 |
| - class:bx--tooltip--a11y="{true}" |
54 |
| - {...$$restProps} |
55 |
| - on:mouseenter="{show}" |
56 |
| - on:mouseleave="{hide}" |
57 |
| -> |
| 47 | +<Popover highContrast dropShadow="{false}" bind:open align="{align}"> |
58 | 48 | <button
|
59 | 49 | bind:this="{ref}"
|
60 | 50 | type="button"
|
61 | 51 | aria-describedby="{id}"
|
62 |
| - class:bx--tooltip--a11y="{true}" |
63 |
| - class:bx--tooltip__trigger="{true}" |
64 |
| - class:bx--tooltip__trigger--definition="{true}" |
65 |
| - class:bx--tooltip--hidden="{!open}" |
66 |
| - class:bx--tooltip--visible="{open}" |
67 |
| - class:bx--tooltip--top="{direction === 'top'}" |
68 |
| - class:bx--tooltip--bottom="{direction === 'bottom'}" |
69 |
| - class:bx--tooltip--align-start="{align === 'start'}" |
70 |
| - class:bx--tooltip--align-center="{align === 'center'}" |
71 |
| - class:bx--tooltip--align-end="{align === 'end'}" |
| 52 | + class:bx--definition-term="{true}" |
72 | 53 | on:click
|
73 | 54 | on:mouseover
|
74 | 55 | on:mouseenter
|
75 | 56 | on:mouseleave
|
76 | 57 | on:focus
|
77 | 58 | on:focus="{show}"
|
78 | 59 | on:blur="{hide}"
|
| 60 | + on:mouseenter="{show}" |
| 61 | + on:mouseleave="{hide}" |
79 | 62 | >
|
80 | 63 | <slot />
|
81 | 64 | </button>
|
82 |
| - <div role="tooltip" id="{id}" class:bx--assistive-text="{true}"> |
83 |
| - <slot name="tooltip">{tooltipText}</slot> |
84 |
| - </div> |
85 |
| -</span> |
| 65 | + <PopoverContent className="{'bx--definition-tooltip'}"> |
| 66 | + <slot name="definition">{definition}</slot> |
| 67 | + </PopoverContent> |
| 68 | +</Popover> |
0 commit comments