@rogieking/figui3 1.7.9 → 1.8.1
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/components.css +0 -26
- package/example.html +7 -0
- package/fig.js +54 -5
- package/package.json +1 -1
package/components.css
CHANGED
|
@@ -1877,20 +1877,6 @@ fig-slider {
|
|
|
1877
1877
|
position: relative;
|
|
1878
1878
|
display: block;
|
|
1879
1879
|
width: 100%;
|
|
1880
|
-
box-shadow: none;
|
|
1881
|
-
background: var(--figma-color-bg-tertiary);
|
|
1882
|
-
|
|
1883
|
-
/* Track */
|
|
1884
|
-
&::before {
|
|
1885
|
-
box-shadow: none;
|
|
1886
|
-
background: var(--figma-color-text-tertiary);
|
|
1887
|
-
}
|
|
1888
|
-
|
|
1889
|
-
input[type="range"] {
|
|
1890
|
-
&::-webkit-slider-runnable-track {
|
|
1891
|
-
box-shadow: none;
|
|
1892
|
-
}
|
|
1893
|
-
}
|
|
1894
1880
|
}
|
|
1895
1881
|
fig-input-text {
|
|
1896
1882
|
height: calc(var(--slider-height) * 2);
|
|
@@ -1899,18 +1885,6 @@ fig-slider {
|
|
|
1899
1885
|
|
|
1900
1886
|
&:hover,
|
|
1901
1887
|
&:focus-within {
|
|
1902
|
-
.fig-slider-input-container {
|
|
1903
|
-
background: var(--figma-color-bg-secondary);
|
|
1904
|
-
&::before {
|
|
1905
|
-
box-shadow: inset 0 0 0 1px var(--figma-color-bordertranslucent);
|
|
1906
|
-
background: var(--figma-color-bg-brand);
|
|
1907
|
-
}
|
|
1908
|
-
}
|
|
1909
|
-
input[type="range"] {
|
|
1910
|
-
&::-webkit-slider-runnable-track {
|
|
1911
|
-
box-shadow: inset 0 0 0 1px var(--figma-color-bordertranslucent);
|
|
1912
|
-
}
|
|
1913
|
-
}
|
|
1914
1888
|
fig-input-text {
|
|
1915
1889
|
height: auto;
|
|
1916
1890
|
}
|
package/example.html
CHANGED
|
@@ -493,6 +493,7 @@
|
|
|
493
493
|
is="fig-dialog">
|
|
494
494
|
<fig-header>
|
|
495
495
|
<h3>Dialog</h3>
|
|
496
|
+
|
|
496
497
|
<fig-button variant="ghost"
|
|
497
498
|
icon="true"
|
|
498
499
|
close-dialog>
|
|
@@ -511,6 +512,12 @@
|
|
|
511
512
|
</fig-button>
|
|
512
513
|
</fig-header>
|
|
513
514
|
<fig-content>
|
|
515
|
+
<fig-tooltip text="Close dialog">
|
|
516
|
+
<fig-button variant="ghost"
|
|
517
|
+
close-dialog>
|
|
518
|
+
Close
|
|
519
|
+
</fig-button>
|
|
520
|
+
</fig-tooltip>
|
|
514
521
|
<p>Some content here</p>
|
|
515
522
|
<fig-field direction="horizontal">
|
|
516
523
|
<label for="colorLevels">Color Levels</label>
|
package/fig.js
CHANGED
|
@@ -252,7 +252,9 @@ class FigTooltip extends HTMLElement {
|
|
|
252
252
|
clearTimeout(this.#touchTimeout);
|
|
253
253
|
if (this.action === "hover") {
|
|
254
254
|
this.removeEventListener("touchstart", this.#handleTouchStart);
|
|
255
|
+
this.removeEventListener("touchmove", this.#handleTouchMove);
|
|
255
256
|
this.removeEventListener("touchend", this.#handleTouchEnd);
|
|
257
|
+
this.removeEventListener("touchcancel", this.#handleTouchCancel);
|
|
256
258
|
} else if (this.action === "click") {
|
|
257
259
|
this.removeEventListener("touchstart", this.showDelayedPopup);
|
|
258
260
|
}
|
|
@@ -290,11 +292,23 @@ class FigTooltip extends HTMLElement {
|
|
|
290
292
|
}
|
|
291
293
|
document.body.addEventListener("click", this.hidePopupOutsideClick);
|
|
292
294
|
}
|
|
295
|
+
isTouchDevice() {
|
|
296
|
+
return (
|
|
297
|
+
"ontouchstart" in window ||
|
|
298
|
+
navigator.maxTouchPoints > 0 ||
|
|
299
|
+
navigator.msMaxTouchPoints > 0
|
|
300
|
+
);
|
|
301
|
+
}
|
|
293
302
|
|
|
294
303
|
setupEventListeners() {
|
|
295
304
|
if (this.action === "hover") {
|
|
296
|
-
|
|
297
|
-
|
|
305
|
+
if (!this.isTouchDevice()) {
|
|
306
|
+
this.addEventListener("pointerenter", this.showDelayedPopup.bind(this));
|
|
307
|
+
this.addEventListener(
|
|
308
|
+
"pointerleave",
|
|
309
|
+
this.#handlePointerLeave.bind(this)
|
|
310
|
+
);
|
|
311
|
+
}
|
|
298
312
|
// Add mousedown listener instead of dragstart
|
|
299
313
|
this.addEventListener("mousedown", this.#boundHideOnDragStart);
|
|
300
314
|
|
|
@@ -302,9 +316,15 @@ class FigTooltip extends HTMLElement {
|
|
|
302
316
|
this.addEventListener("touchstart", this.#handleTouchStart.bind(this), {
|
|
303
317
|
passive: true,
|
|
304
318
|
});
|
|
319
|
+
this.addEventListener("touchmove", this.#handleTouchMove.bind(this), {
|
|
320
|
+
passive: true,
|
|
321
|
+
});
|
|
305
322
|
this.addEventListener("touchend", this.#handleTouchEnd.bind(this), {
|
|
306
323
|
passive: true,
|
|
307
324
|
});
|
|
325
|
+
this.addEventListener("touchcancel", this.#handleTouchCancel.bind(this), {
|
|
326
|
+
passive: true,
|
|
327
|
+
});
|
|
308
328
|
} else if (this.action === "click") {
|
|
309
329
|
this.addEventListener("click", this.showDelayedPopup.bind(this));
|
|
310
330
|
document.body.addEventListener(
|
|
@@ -390,23 +410,52 @@ class FigTooltip extends HTMLElement {
|
|
|
390
410
|
}
|
|
391
411
|
}
|
|
392
412
|
|
|
413
|
+
// Pointer event handlers
|
|
414
|
+
#handlePointerLeave(event) {
|
|
415
|
+
// Don't hide immediately if we're in a touch interaction
|
|
416
|
+
if (!this.#isTouching) {
|
|
417
|
+
this.hidePopup();
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
|
|
393
421
|
// Touch event handlers for mobile support
|
|
394
422
|
#handleTouchStart(event) {
|
|
395
423
|
if (this.action === "hover") {
|
|
396
424
|
this.#isTouching = true;
|
|
425
|
+
// Clear any existing touch timeout
|
|
426
|
+
clearTimeout(this.#touchTimeout);
|
|
397
427
|
// Show popup on touch start for hover action
|
|
398
428
|
this.showDelayedPopup();
|
|
399
429
|
}
|
|
400
430
|
}
|
|
401
431
|
|
|
432
|
+
#handleTouchMove(event) {
|
|
433
|
+
if (this.action === "hover" && this.#isTouching) {
|
|
434
|
+
// If user is scrolling/moving, cancel the tooltip after a delay
|
|
435
|
+
clearTimeout(this.#touchTimeout);
|
|
436
|
+
this.#touchTimeout = setTimeout(() => {
|
|
437
|
+
this.#isTouching = false;
|
|
438
|
+
this.hidePopup();
|
|
439
|
+
}, 150);
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
|
|
402
443
|
#handleTouchEnd(event) {
|
|
403
444
|
if (this.action === "hover" && this.#isTouching) {
|
|
404
|
-
|
|
405
|
-
// Hide popup after a short delay to allow for taps
|
|
445
|
+
// Delay setting isTouching to false to prevent pointerleave from hiding immediately
|
|
406
446
|
clearTimeout(this.#touchTimeout);
|
|
407
447
|
this.#touchTimeout = setTimeout(() => {
|
|
448
|
+
this.#isTouching = false;
|
|
408
449
|
this.hidePopup();
|
|
409
|
-
},
|
|
450
|
+
}, 300); // Increased delay for better mobile UX
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
#handleTouchCancel(event) {
|
|
455
|
+
if (this.action === "hover" && this.#isTouching) {
|
|
456
|
+
this.#isTouching = false;
|
|
457
|
+
clearTimeout(this.#touchTimeout);
|
|
458
|
+
this.hidePopup();
|
|
410
459
|
}
|
|
411
460
|
}
|
|
412
461
|
|