@rogieking/figui3 1.6.7 → 1.6.9
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 +50 -19
- package/glitch.html +70 -0
- package/package.json +1 -1
- package/charli.jpeg +0 -0
- package/end-points/chevron.svg +0 -9
- package/end-points/end-points.html +0 -114
- package/end-points/icon.24.stroke-diamond-arrow.svg +0 -3
- package/end-points/icon.24.stroke.cap-round.svg +0 -4
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
|
|
|
@@ -1015,7 +1031,6 @@ class FigInputText extends HTMLElement {
|
|
|
1015
1031
|
if (this.type === "number") {
|
|
1016
1032
|
value = value / (this.transform || 1);
|
|
1017
1033
|
value = this.#sanitizeInput(value, false);
|
|
1018
|
-
console.log("sanitizeInput", value);
|
|
1019
1034
|
valueTransformed = value * (this.transform || 1);
|
|
1020
1035
|
}
|
|
1021
1036
|
this.value = value;
|
|
@@ -1780,6 +1795,7 @@ window.customElements.define("fig-chit", FigChit);
|
|
|
1780
1795
|
* @attr {string} size - Size of the image preview
|
|
1781
1796
|
*/
|
|
1782
1797
|
class FigImage extends HTMLElement {
|
|
1798
|
+
#src = null;
|
|
1783
1799
|
constructor() {
|
|
1784
1800
|
super();
|
|
1785
1801
|
}
|
|
@@ -1822,9 +1838,6 @@ class FigImage extends HTMLElement {
|
|
|
1822
1838
|
this.#handleFileInput.bind(this)
|
|
1823
1839
|
);
|
|
1824
1840
|
}
|
|
1825
|
-
if (this.src) {
|
|
1826
|
-
this.#loadImage(this.src);
|
|
1827
|
-
}
|
|
1828
1841
|
});
|
|
1829
1842
|
}
|
|
1830
1843
|
async #loadImage(src) {
|
|
@@ -1832,13 +1845,23 @@ class FigImage extends HTMLElement {
|
|
|
1832
1845
|
await new Promise((resolve) => {
|
|
1833
1846
|
this.image = new Image();
|
|
1834
1847
|
this.image.crossOrigin = "Anonymous";
|
|
1835
|
-
|
|
1848
|
+
console.log("loading image", this.src);
|
|
1836
1849
|
this.image.onload = async () => {
|
|
1837
1850
|
this.aspectRatio = this.image.width / this.image.height;
|
|
1838
1851
|
this.style.setProperty(
|
|
1839
1852
|
"--aspect-ratio",
|
|
1840
1853
|
`${this.image.width}/${this.image.height}`
|
|
1841
1854
|
);
|
|
1855
|
+
this.dispatchEvent(
|
|
1856
|
+
new CustomEvent("loaded", {
|
|
1857
|
+
bubbles: true,
|
|
1858
|
+
cancelable: true,
|
|
1859
|
+
detail: {
|
|
1860
|
+
blob: this.blob,
|
|
1861
|
+
base64: this.base64,
|
|
1862
|
+
},
|
|
1863
|
+
})
|
|
1864
|
+
);
|
|
1842
1865
|
resolve();
|
|
1843
1866
|
|
|
1844
1867
|
// Create canvas to extract blob and base64 from image
|
|
@@ -1889,18 +1912,26 @@ class FigImage extends HTMLElement {
|
|
|
1889
1912
|
cancelable: true,
|
|
1890
1913
|
})
|
|
1891
1914
|
);
|
|
1892
|
-
this.src
|
|
1893
|
-
this.setAttribute("src", this.src);
|
|
1894
|
-
this.chit.setAttribute("src", this.src);
|
|
1915
|
+
this.setAttribute("src", this.blob);
|
|
1895
1916
|
}
|
|
1896
1917
|
static get observedAttributes() {
|
|
1897
1918
|
return ["src", "upload"];
|
|
1898
1919
|
}
|
|
1920
|
+
get src() {
|
|
1921
|
+
return this.#src;
|
|
1922
|
+
}
|
|
1923
|
+
set src(value) {
|
|
1924
|
+
this.#src = value;
|
|
1925
|
+
}
|
|
1926
|
+
|
|
1899
1927
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
1900
1928
|
if (name === "src") {
|
|
1901
1929
|
this.src = newValue;
|
|
1902
1930
|
if (this.chit) {
|
|
1903
|
-
this.chit.setAttribute("src", this
|
|
1931
|
+
this.chit.setAttribute("src", this.#src);
|
|
1932
|
+
}
|
|
1933
|
+
if (this.#src) {
|
|
1934
|
+
this.#loadImage(this.#src);
|
|
1904
1935
|
}
|
|
1905
1936
|
}
|
|
1906
1937
|
if (name === "upload") {
|
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>
|
package/package.json
CHANGED
package/charli.jpeg
DELETED
|
Binary file
|
package/end-points/chevron.svg
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
<svg width="24"
|
|
2
|
-
height="24"
|
|
3
|
-
viewBox="0 0 24 24"
|
|
4
|
-
fill="none"
|
|
5
|
-
xmlns="http://www.w3.org/2000/svg">
|
|
6
|
-
<path d="M13.6465 11.1465C13.8417 10.9512 14.1583 10.9512 14.3535 11.1465C14.5488 11.3417 14.5488 11.6583 14.3535 11.8535L12.3535 13.8535C12.1583 14.0488 11.8417 14.0488 11.6465 13.8535L9.64648 11.8535C9.45122 11.6583 9.45122 11.3417 9.64648 11.1465C9.84175 10.9512 10.1583 10.9512 10.3535 11.1465L12 12.793L13.6465 11.1465Z"
|
|
7
|
-
fill="black"
|
|
8
|
-
fill-opacity="0.9" />
|
|
9
|
-
</svg>
|
|
@@ -1,114 +0,0 @@
|
|
|
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="https://unpkg.com/@rogieking/figui3@latest/fig.css">
|
|
12
|
-
<style>
|
|
13
|
-
/* Ignore these styles. They are mostly used to recreate the look of a dropdown */
|
|
14
|
-
body {
|
|
15
|
-
width: 480px;
|
|
16
|
-
margin: 0 auto;
|
|
17
|
-
padding: 0 2rem;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.dropdown {
|
|
21
|
-
|
|
22
|
-
height: var(--spacer-4);
|
|
23
|
-
padding: 0;
|
|
24
|
-
border-radius: var(--radius-medium);
|
|
25
|
-
display: inline-flex;
|
|
26
|
-
appearance: none;
|
|
27
|
-
align-items: center;
|
|
28
|
-
width: 40vw;
|
|
29
|
-
flex: 1 0 0;
|
|
30
|
-
border: 0;
|
|
31
|
-
color: var(--figma-color-text);
|
|
32
|
-
background-color: var(--figma-color-bg);
|
|
33
|
-
box-shadow: inset 0 0 0 1px var(--figma-color-border);
|
|
34
|
-
accent-color: var(--figma-color-bg-brand);
|
|
35
|
-
overflow: hidden;
|
|
36
|
-
white-space: nowrap;
|
|
37
|
-
text-overflow: ellipsis;
|
|
38
|
-
background-image: url(chevron.svg);
|
|
39
|
-
background-repeat: no-repeat;
|
|
40
|
-
background-position: right center;
|
|
41
|
-
background-size: 24px;
|
|
42
|
-
padding-right: 24px;
|
|
43
|
-
margin: 0.5rem 0;
|
|
44
|
-
|
|
45
|
-
label {
|
|
46
|
-
display: block;
|
|
47
|
-
flex-grow: 1;
|
|
48
|
-
flex-shrink: 1;
|
|
49
|
-
text-align: left;
|
|
50
|
-
overflow: hidden;
|
|
51
|
-
padding: 0;
|
|
52
|
-
color: var(--figma-color-text);
|
|
53
|
-
text-overflow: ellipsis;
|
|
54
|
-
white-space: nowrap;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/* Style to reference */
|
|
59
|
-
.stretch-icon {
|
|
60
|
-
display: block;
|
|
61
|
-
flex-shrink: 0;
|
|
62
|
-
flex-basis: 24px;
|
|
63
|
-
width: 24px;
|
|
64
|
-
border: 12px solid black;
|
|
65
|
-
box-sizing: border-box;
|
|
66
|
-
/* top | right | bottom | left */
|
|
67
|
-
border-image-slice: 12;
|
|
68
|
-
border-image-repeat: repeat;
|
|
69
|
-
|
|
70
|
-
&.cap-diamond {
|
|
71
|
-
border-image-source: url(icon.24.stroke-diamond-arrow.svg);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
&.cap-round {
|
|
75
|
-
border-image-source: url(icon.24.stroke.cap-round.svg);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
&.grow {
|
|
79
|
-
flex-grow: 1;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
</style>
|
|
83
|
-
</head>
|
|
84
|
-
|
|
85
|
-
<body>
|
|
86
|
-
<fig-content>
|
|
87
|
-
|
|
88
|
-
<div class="dropdown">
|
|
89
|
-
<div class="stretch-icon cap-diamond"></div>
|
|
90
|
-
<label>Diamond arrow with a label</label>
|
|
91
|
-
</div>
|
|
92
|
-
<br />
|
|
93
|
-
<div class="dropdown">
|
|
94
|
-
<div class="stretch-icon cap-diamond grow"></div>
|
|
95
|
-
</div>
|
|
96
|
-
<br />
|
|
97
|
-
<div class="dropdown">
|
|
98
|
-
<div class="stretch-icon cap-round">
|
|
99
|
-
</div>
|
|
100
|
-
<label>Round with a label</label>
|
|
101
|
-
</div>
|
|
102
|
-
<br />
|
|
103
|
-
<div class="dropdown">
|
|
104
|
-
<div class="stretch-icon cap-round grow">
|
|
105
|
-
</div>
|
|
106
|
-
</div>
|
|
107
|
-
|
|
108
|
-
</fig-content>
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
</body>
|
|
113
|
-
|
|
114
|
-
</html>
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
<svg width="32" height="24" viewBox="0 0 32 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
-
<path d="M6.79297 7.29297C7.18349 6.90244 7.81651 6.90244 8.20703 7.29297L11.9141 11H28.5C28.7761 11 28.9999 11.2239 29 11.5C29 11.7761 28.7761 12 28.5 12H11.9141L8.20703 15.707C7.81651 16.0976 7.18349 16.0976 6.79297 15.707L3.29297 12.207L3.22461 12.1309C2.90426 11.7381 2.92685 11.1591 3.29297 10.793L6.79297 7.29297ZM4 11.5L7.5 15L11 11.5L7.5 8L4 11.5Z" fill="black" fill-opacity="0.9"/>
|
|
3
|
-
</svg>
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
<svg width="32" height="24" viewBox="0 0 32 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
-
<path d="M10 7C7.23858 7 5 9.23858 5 12C5 14.7614 7.23858 17 10 17H26.5C26.7761 17 27 16.7761 27 16.5C27 16.2239 26.7761 16 26.5 16H10C7.79086 16 6 14.2091 6 12C6 9.79086 7.79086 8 10 8H26.5C26.7761 8 27 7.77614 27 7.5C27 7.22386 26.7761 7 26.5 7H10Z" fill="black" fill-opacity="0.9"/>
|
|
3
|
-
<path d="M25.7734 11.5C25.4973 11.5 25.2734 11.7239 25.2734 12C25.2734 12.2761 25.4973 12.5 25.7734 12.5H26.5C26.7761 12.5 27 12.2761 27 12C27 11.7239 26.7761 11.5 26.5 11.5H25.7734ZM21.8984 11.5C21.6223 11.5 21.3984 11.7239 21.3984 12C21.3984 12.2761 21.6223 12.5 21.8984 12.5H23.3516C23.6277 12.5 23.8516 12.2761 23.8516 12C23.8516 11.7239 23.6277 11.5 23.3516 11.5H21.8984ZM18.0234 11.5C17.7473 11.5 17.5234 11.7239 17.5234 12C17.5234 12.2761 17.7473 12.5 18.0234 12.5H19.4766C19.7527 12.5 19.9766 12.2761 19.9766 12C19.9766 11.7239 19.7527 11.5 19.4766 11.5H18.0234ZM14.1484 11.5C13.8723 11.5 13.6484 11.7239 13.6484 12C13.6484 12.2761 13.8723 12.5 14.1484 12.5H15.6016C15.8777 12.5 16.1016 12.2761 16.1016 12C16.1016 11.7239 15.8777 11.5 15.6016 11.5H14.1484ZM11 11.5C10.7239 11.5 10.5 11.7239 10.5 12C10.5 12.2761 10.7239 12.5 11 12.5H11.7266C12.0027 12.5 12.2266 12.2761 12.2266 12C12.2266 11.7239 12.0027 11.5 11.7266 11.5H11Z" fill="black" fill-opacity="0.3"/>
|
|
4
|
-
</svg>
|