@rogieking/figui3 1.6.7 → 1.6.8
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/example.html +31 -4
- package/fig.js +26 -10
- package/glitch.html +70 -0
- package/package.json +1 -1
package/example.html
CHANGED
|
@@ -26,15 +26,42 @@
|
|
|
26
26
|
<h2><label>Effects/</label>UI3 Components</h2>
|
|
27
27
|
</fig-header>
|
|
28
28
|
|
|
29
|
-
<fig-popover action="
|
|
29
|
+
<fig-popover action="manual"
|
|
30
|
+
open="true"
|
|
30
31
|
size="large">
|
|
31
32
|
<fig-button>
|
|
32
33
|
Hover me
|
|
33
34
|
</fig-button>
|
|
34
35
|
<div popover>
|
|
35
|
-
<fig-
|
|
36
|
-
|
|
37
|
-
</fig-
|
|
36
|
+
<fig-header>
|
|
37
|
+
<h2>Slider</h2>
|
|
38
|
+
</fig-header>
|
|
39
|
+
<fig-dropdown>
|
|
40
|
+
<option>One</option>
|
|
41
|
+
<option>Two</option>
|
|
42
|
+
</fig-dropdown>
|
|
43
|
+
<fig-field direction="horizontal">
|
|
44
|
+
<label>Slider</label>
|
|
45
|
+
<fig-slider min="1"
|
|
46
|
+
max="100"
|
|
47
|
+
value="50"
|
|
48
|
+
step="1"
|
|
49
|
+
units="%"
|
|
50
|
+
transform="100">
|
|
51
|
+
</fig-slider>
|
|
52
|
+
</fig-field>
|
|
53
|
+
<br />
|
|
54
|
+
<fig-field direction="horizontal">
|
|
55
|
+
<label>Slider</label>
|
|
56
|
+
<fig-slider min="1"
|
|
57
|
+
max="100"
|
|
58
|
+
value="50"
|
|
59
|
+
step="1"
|
|
60
|
+
units="%"
|
|
61
|
+
transform="100">
|
|
62
|
+
</fig-slider>
|
|
63
|
+
|
|
64
|
+
</fig-field>
|
|
38
65
|
</div>
|
|
39
66
|
</fig-popover>
|
|
40
67
|
|
package/fig.js
CHANGED
|
@@ -225,7 +225,6 @@ class FigTooltip extends HTMLElement {
|
|
|
225
225
|
this.action = this.getAttribute("action") || "hover";
|
|
226
226
|
let delay = parseInt(this.getAttribute("delay"));
|
|
227
227
|
this.delay = !isNaN(delay) ? delay : 500;
|
|
228
|
-
this.isOpen = false;
|
|
229
228
|
|
|
230
229
|
// Bind methods that will be used as event listeners
|
|
231
230
|
this.#boundHideOnChromeOpen = this.#hideOnChromeOpen.bind(this);
|
|
@@ -366,7 +365,13 @@ class FigTooltip extends HTMLElement {
|
|
|
366
365
|
}
|
|
367
366
|
}
|
|
368
367
|
static get observedAttributes() {
|
|
369
|
-
return ["action", "delay"];
|
|
368
|
+
return ["action", "delay", "open"];
|
|
369
|
+
}
|
|
370
|
+
get open() {
|
|
371
|
+
return this.hasAttribute("open") && this.getAttribute("open") === "true";
|
|
372
|
+
}
|
|
373
|
+
set open(value) {
|
|
374
|
+
this.setAttribute("open", value);
|
|
370
375
|
}
|
|
371
376
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
372
377
|
if (name === "action") {
|
|
@@ -376,6 +381,17 @@ class FigTooltip extends HTMLElement {
|
|
|
376
381
|
let delay = parseInt(newValue);
|
|
377
382
|
this.delay = !isNaN(delay) ? delay : 500;
|
|
378
383
|
}
|
|
384
|
+
if (name === "open") {
|
|
385
|
+
if (newValue === "true") {
|
|
386
|
+
requestAnimationFrame(() => {
|
|
387
|
+
this.showDelayedPopup();
|
|
388
|
+
});
|
|
389
|
+
} else {
|
|
390
|
+
requestAnimationFrame(() => {
|
|
391
|
+
this.hidePopup();
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
}
|
|
379
395
|
}
|
|
380
396
|
|
|
381
397
|
#hideOnChromeOpen(e) {
|
|
@@ -383,11 +399,16 @@ class FigTooltip extends HTMLElement {
|
|
|
383
399
|
|
|
384
400
|
// Check if the clicked element is a select or opens a dialog
|
|
385
401
|
const target = e.target;
|
|
402
|
+
|
|
403
|
+
// If the target is a child of this.popup, return early
|
|
404
|
+
if (this.popup && this.popup.contains(target)) {
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
|
|
386
408
|
if (
|
|
387
409
|
target.tagName === "SELECT" ||
|
|
388
410
|
target.hasAttribute("popover") ||
|
|
389
|
-
target.closest("dialog")
|
|
390
|
-
target.onclick?.toString().includes("alert")
|
|
411
|
+
target.closest("dialog")
|
|
391
412
|
) {
|
|
392
413
|
this.hidePopup();
|
|
393
414
|
}
|
|
@@ -403,15 +424,12 @@ customElements.define("fig-tooltip", FigTooltip);
|
|
|
403
424
|
* @attr {string} size - The size of the popover
|
|
404
425
|
*/
|
|
405
426
|
class FigPopover extends FigTooltip {
|
|
406
|
-
static observedAttributes = ["action", "size"];
|
|
407
|
-
|
|
408
427
|
constructor() {
|
|
409
428
|
super();
|
|
410
429
|
this.action = this.getAttribute("action") || "click";
|
|
411
430
|
this.delay = parseInt(this.getAttribute("delay")) || 0;
|
|
412
431
|
}
|
|
413
432
|
render() {
|
|
414
|
-
this.destroy();
|
|
415
433
|
this.popup = this.popup || this.querySelector("[popover]");
|
|
416
434
|
this.popup.setAttribute("class", "fig-popover");
|
|
417
435
|
this.popup.style.position = "fixed";
|
|
@@ -419,8 +437,6 @@ class FigPopover extends FigTooltip {
|
|
|
419
437
|
this.popup.style.display = "inline-flex";
|
|
420
438
|
document.body.append(this.popup);
|
|
421
439
|
}
|
|
422
|
-
|
|
423
|
-
destroy() {}
|
|
424
440
|
}
|
|
425
441
|
customElements.define("fig-popover", FigPopover);
|
|
426
442
|
|
|
@@ -669,6 +685,7 @@ class FigSlider extends HTMLElement {
|
|
|
669
685
|
|
|
670
686
|
constructor() {
|
|
671
687
|
super();
|
|
688
|
+
this.initialInnerHTML = this.innerHTML;
|
|
672
689
|
|
|
673
690
|
// Bind the event handlers
|
|
674
691
|
this.#boundHandleInput = (e) => {
|
|
@@ -798,7 +815,6 @@ class FigSlider extends HTMLElement {
|
|
|
798
815
|
}
|
|
799
816
|
|
|
800
817
|
connectedCallback() {
|
|
801
|
-
this.initialInnerHTML = this.innerHTML;
|
|
802
818
|
this.#regenerateInnerHTML();
|
|
803
819
|
}
|
|
804
820
|
|
package/glitch.html
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="UTF-8">
|
|
6
|
+
<meta name="viewport"
|
|
7
|
+
content="width=device-width, initial-scale=1.0">
|
|
8
|
+
<title>Figma UI3 Web Components</title>
|
|
9
|
+
<link rel="stylesheet"
|
|
10
|
+
type="text/css"
|
|
11
|
+
href="fig.css">
|
|
12
|
+
<script src="fig.js"></script>
|
|
13
|
+
<style>
|
|
14
|
+
body {
|
|
15
|
+
width: 480px;
|
|
16
|
+
margin: 0 auto;
|
|
17
|
+
}
|
|
18
|
+
</style>
|
|
19
|
+
</head>
|
|
20
|
+
|
|
21
|
+
<body>
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
<fig-header>
|
|
25
|
+
|
|
26
|
+
<h2><label>Effects/</label>UI3 Components</h2>
|
|
27
|
+
</fig-header>
|
|
28
|
+
|
|
29
|
+
<fig-popover action="manual"
|
|
30
|
+
open="true"
|
|
31
|
+
size="large">
|
|
32
|
+
<fig-button>
|
|
33
|
+
Hover me
|
|
34
|
+
</fig-button>
|
|
35
|
+
<div popover>
|
|
36
|
+
<fig-header>
|
|
37
|
+
<h2>Slider</h2>
|
|
38
|
+
</fig-header>
|
|
39
|
+
<fig-dropdown>
|
|
40
|
+
<option>One</option>
|
|
41
|
+
<option>Two</option>
|
|
42
|
+
</fig-dropdown>
|
|
43
|
+
<fig-field direction="horizontal">
|
|
44
|
+
<label>Slider</label>
|
|
45
|
+
<fig-slider min="1"
|
|
46
|
+
max="100"
|
|
47
|
+
value="50"
|
|
48
|
+
step="1"
|
|
49
|
+
units="%"
|
|
50
|
+
transform="100">
|
|
51
|
+
</fig-slider>
|
|
52
|
+
</fig-field>
|
|
53
|
+
<br />
|
|
54
|
+
<fig-field direction="horizontal">
|
|
55
|
+
<label>Slider</label>
|
|
56
|
+
<fig-slider min="1"
|
|
57
|
+
max="100"
|
|
58
|
+
value="50"
|
|
59
|
+
step="1"
|
|
60
|
+
units="%"
|
|
61
|
+
transform="100">
|
|
62
|
+
</fig-slider>
|
|
63
|
+
|
|
64
|
+
</fig-field>
|
|
65
|
+
</div>
|
|
66
|
+
</fig-popover>
|
|
67
|
+
|
|
68
|
+
</body>
|
|
69
|
+
|
|
70
|
+
</html>
|