|
1 | 1 | <script> |
2 | 2 | import { useTooltip } from '../../src' |
3 | 3 |
|
| 4 | + let tooltipPosition = 'top' |
4 | 5 | let useCustomTooltipClass = false |
5 | | - let animateTooltip = false |
| 6 | + let isTooltipDisabled = false |
6 | 7 |
|
7 | 8 | const _onTooltipClick = (arg, event) => { |
8 | 9 | console.log(arg) |
|
12 | 13 | <main> |
13 | 14 | <div class="container"> |
14 | 15 | <div use:useTooltip={{ |
15 | | - contentSelector: '.tooltip__content', |
| 16 | + position: tooltipPosition, |
| 17 | + contentSelector: '.tooltip__button', |
16 | 18 | contentClone: false, |
17 | 19 | contentActions: { |
18 | | - '#button1': { |
19 | | - eventType: 'mouseenter', |
20 | | - callback: (arg) => console.log(arg), |
21 | | - callbackParams: ['Haha you\'re hovering the button 1'], |
22 | | - closeOnCallback: false |
23 | | - }, |
24 | | - '#button2': { |
25 | | - eventType: 'mouseenter', |
26 | | - callback: (arg1, arg2) => console.log(arg1, arg2), |
27 | | - callbackParams: ['Haha you\'re hovering the', 'button 2'], |
28 | | - closeOnCallback: false |
29 | | - }, |
30 | | - '#button2': { |
31 | | - eventType: 'click', |
32 | | - callback: (arg1, arg2) => console.log(arg1, arg2), |
33 | | - callbackParams: ['Haha you\'ve clicked the', 'button 2'], |
34 | | - closeOnCallback: true |
35 | | - }, |
| 20 | + '*': { |
| 21 | + eventType: 'click', |
| 22 | + callback: _onTooltipClick, |
| 23 | + callbackParams: ['ok'], |
| 24 | + closeOnCallback: true |
| 25 | + }, |
36 | 26 | }, |
37 | 27 | contentClassName: useCustomTooltipClass ? 'tooltip' : null, |
38 | | - disabled: false, |
39 | | - animated: animateTooltip |
40 | | - }} class="tooltip__target">Hover me</div> |
41 | | - <span class="tooltip__content"> |
42 | | - <button id="button1">Action 1</button> |
43 | | - <button id="button2">Action 2</button> |
44 | | - </span> |
| 28 | + disabled: isTooltipDisabled, |
| 29 | + }} class="target">Hover me</div> |
| 30 | + <span class="tooltip__button">Hi! I'm a fancy tooltip!</span> |
45 | 31 | <form class="settings__form"> |
46 | 32 | <h1>Settings</h1> |
| 33 | + <fieldset> |
| 34 | + <label> |
| 35 | + Use Custom Tooltip Class: |
| 36 | + <input type="checkbox" bind:checked={useCustomTooltipClass} /> |
| 37 | + </label> |
| 38 | + </fieldset> |
47 | 39 | <fieldset> |
48 | 40 | <label> |
49 | | - Use Custom Tooltip Class: |
50 | | - <input type="checkbox" bind:checked={useCustomTooltipClass} /> |
51 | | - </label> |
52 | | - </fieldset> |
53 | | - <fieldset> |
54 | | - <label> |
55 | | - Animate tooltip: |
56 | | - <input type="checkbox" bind:checked={animateTooltip} /> |
| 41 | + Tooltip Position: |
| 42 | + <select bind:value={tooltipPosition}> |
| 43 | + <option value="left">Left</option> |
| 44 | + <option value="right">Right</option> |
| 45 | + <option value="top">Top</option> |
| 46 | + <option value="bottom">Bottom</option> |
| 47 | + </select> |
57 | 48 | </label> |
58 | 49 | </fieldset> |
| 50 | + <fieldset> |
| 51 | + <label> |
| 52 | + Disable Tooltip: |
| 53 | + <input type="checkbox" bind:checked={isTooltipDisabled} /> |
| 54 | + </label> |
| 55 | + </fieldset> |
59 | 56 | </form> |
60 | 57 | </div> |
61 | 58 | </main> |
|
76 | 73 | row-gap: 1rem; |
77 | 74 | } |
78 | 75 |
|
79 | | - .tooltip__target { |
| 76 | + .target { |
80 | 77 | width: 10rem; |
81 | 78 | height: 3rem; |
82 | 79 | background-color: white; |
|
87 | 84 | box-shadow: 0 0 5px 0 rgba(0,0,0,0.5); |
88 | 85 | } |
89 | 86 |
|
90 | | - .tooltip__target:hover { |
| 87 | + .target:hover { |
91 | 88 | cursor: pointer; |
92 | 89 | background-color: black; |
93 | 90 | color: white; |
94 | 91 | } |
95 | 92 |
|
96 | | - .tooltip__content { |
97 | | - color: white |
98 | | - } |
99 | | -
|
100 | 93 | .settings__form { |
101 | 94 | display: flex; |
102 | 95 | flex-direction: column; |
|
0 commit comments