@justeattakeaway/pie-tooltip 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +202 -8
- package/custom-elements.json +292 -2
- package/dist/index.d.ts +45 -4
- package/dist/index.js +387 -160
- package/dist/react.d.ts +46 -4
- package/dist/react.js +16 -12
- package/package.json +6 -6
- package/src/defs.ts +17 -2
- package/src/index.ts +599 -39
- package/src/react.ts +3 -1
- package/src/tooltip.scss +46 -2
package/src/react.ts
CHANGED
|
@@ -11,13 +11,15 @@ const PieTooltipReact = createComponent({
|
|
|
11
11
|
react: React,
|
|
12
12
|
tagName: 'pie-tooltip',
|
|
13
13
|
events: {
|
|
14
|
-
|
|
14
|
+
onPieTooltipOpen: 'pie-tooltip-open' as EventName<Event>, // When a configured trigger asks for the panel. Set `isOpen` to `true` in response.
|
|
15
|
+
onPieTooltipClose: 'pie-tooltip-close' as EventName<Event>, // When the close button is clicked, or a configured trigger asks to dismiss the panel. Set `isOpen` to `false` in response.
|
|
15
16
|
},
|
|
16
17
|
});
|
|
17
18
|
|
|
18
19
|
type ReactBaseType = React.HTMLAttributes<HTMLElement>
|
|
19
20
|
|
|
20
21
|
type PieTooltipEvents = {
|
|
22
|
+
onPieTooltipOpen?: (event: Event) => void;
|
|
21
23
|
onPieTooltipClose?: (event: Event) => void;
|
|
22
24
|
};
|
|
23
25
|
|
package/src/tooltip.scss
CHANGED
|
@@ -65,7 +65,9 @@ $tooltip-alignments: ('', '-start', '-end');
|
|
|
65
65
|
visibility: hidden;
|
|
66
66
|
transition: visibility 0s linear 150ms;
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
// `is-anchorVisible` is false when the trigger has been scrolled entirely out of a clipping
|
|
69
|
+
// ancestor: there is nothing left to point at, so the panel hides rather than float free.
|
|
70
|
+
&.is-open.is-positioned.is-anchorVisible {
|
|
69
71
|
visibility: visible;
|
|
70
72
|
transition-delay: 0s;
|
|
71
73
|
}
|
|
@@ -168,7 +170,7 @@ $tooltip-alignments: ('', '-start', '-end');
|
|
|
168
170
|
transform var(--tooltip-motion-duration) var(--tooltip-motion-easing);
|
|
169
171
|
}
|
|
170
172
|
|
|
171
|
-
.c-tooltip-layer.is-open.is-positioned .c-tooltip {
|
|
173
|
+
.c-tooltip-layer.is-open.is-positioned.is-anchorVisible .c-tooltip {
|
|
172
174
|
--tooltip-motion-duration: 200ms;
|
|
173
175
|
|
|
174
176
|
opacity: 1;
|
|
@@ -367,3 +369,45 @@ $tooltip-alignments: ('', '-start', '-end');
|
|
|
367
369
|
inset-block-start: var(--dt-spacing-b);
|
|
368
370
|
inset-inline-end: var(--dt-spacing-b);
|
|
369
371
|
}
|
|
372
|
+
|
|
373
|
+
// Hover bridge: a transparent pseudo-element extending from each panel edge toward its
|
|
374
|
+
// trigger, covering the --tooltip-layer-offset gap. Keeps the hover region intact so
|
|
375
|
+
// the pointer can travel from the trigger into the panel without the close timer firing.
|
|
376
|
+
// Sized from --tooltip-layer-offset so widening --tooltip-offset cannot open a hole.
|
|
377
|
+
@each $alignment in $tooltip-alignments {
|
|
378
|
+
.c-tooltip--top#{$alignment}::before {
|
|
379
|
+
content: '';
|
|
380
|
+
position: absolute;
|
|
381
|
+
inset-block-start: 100%;
|
|
382
|
+
block-size: var(--tooltip-layer-offset);
|
|
383
|
+
inset-inline-start: 0;
|
|
384
|
+
inline-size: 100%;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
.c-tooltip--bottom#{$alignment}::before {
|
|
388
|
+
content: '';
|
|
389
|
+
position: absolute;
|
|
390
|
+
inset-block-end: 100%;
|
|
391
|
+
block-size: var(--tooltip-layer-offset);
|
|
392
|
+
inset-inline-start: 0;
|
|
393
|
+
inline-size: 100%;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
.c-tooltip--left#{$alignment}::before {
|
|
397
|
+
content: '';
|
|
398
|
+
position: absolute;
|
|
399
|
+
inset-inline-start: 100%;
|
|
400
|
+
inline-size: var(--tooltip-layer-offset);
|
|
401
|
+
inset-block-start: 0;
|
|
402
|
+
block-size: 100%;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
.c-tooltip--right#{$alignment}::before {
|
|
406
|
+
content: '';
|
|
407
|
+
position: absolute;
|
|
408
|
+
inset-inline-end: 100%;
|
|
409
|
+
inline-size: var(--tooltip-layer-offset);
|
|
410
|
+
inset-block-start: 0;
|
|
411
|
+
block-size: 100%;
|
|
412
|
+
}
|
|
413
|
+
}
|