@rogieking/figui3 1.6.8 → 1.7.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/components.css +26 -0
- package/example.html +4 -19
- package/fig.js +25 -12
- package/package.json +1 -1
- package/bun.lockb +0 -0
- 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/components.css
CHANGED
|
@@ -437,6 +437,8 @@
|
|
|
437
437
|
/* Icons */
|
|
438
438
|
--icon-chevron: url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 16 16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5.87868 7.12132L8 9.24264L10.1213 7.12132' stroke='rgb(0 0 0 / 90%)' stroke-linecap='round'/%3E%3C/svg%3E%0A");
|
|
439
439
|
--icon-checkmark: url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 16 16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M11.7773 4.08403C12.0071 4.2372 12.0692 4.54764 11.916 4.7774L7.91603 10.7774C7.83293 10.902 7.69834 10.9829 7.54927 10.9976C7.4002 11.0124 7.25237 10.9595 7.14645 10.8536L4.14645 7.85361C3.95118 7.65834 3.95118 7.34176 4.14645 7.1465C4.34171 6.95124 4.65829 6.95124 4.85355 7.1465L7.42229 9.71523L11.084 4.2227C11.2372 3.99294 11.5476 3.93085 11.7773 4.08403Z' fill='white'/%3E%3C/svg%3E%0A");
|
|
440
|
+
--icon-steppers: url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11.7245 6.08191C11.9186 5.95386 12.1826 5.97562 12.3534 6.14637L14.3534 8.14637L14.4179 8.22449C14.546 8.41852 14.5242 8.68253 14.3534 8.8534C14.1826 9.02426 13.9186 9.04601 13.7245 8.91785L13.6464 8.8534L11.9999 7.20691L10.3534 8.8534C10.1582 9.04866 9.84166 9.04866 9.6464 8.8534C9.45123 8.65813 9.45117 8.3416 9.6464 8.14637L11.6464 6.14637L11.7245 6.08191Z' fill='black'/%3E%3Cpath d='M13.7248 15.0822C13.9189 14.9541 14.1829 14.9758 14.3537 15.1467C14.5246 15.3176 14.5463 15.5815 14.4182 15.7756L14.3537 15.8537L12.3537 17.8537C12.1829 18.0246 11.9189 18.0463 11.7248 17.9182L11.6467 17.8537L9.64669 15.8537L9.58224 15.7756C9.45407 15.5815 9.47583 15.3176 9.64669 15.1467C9.81756 14.9758 10.0815 14.9541 10.2756 15.0822L10.3537 15.1467L12.0002 16.7932L13.6467 15.1467L13.7248 15.0822Z' fill='black' /%3E%3C/svg%3E%0A");
|
|
441
|
+
|
|
440
442
|
/* Elevations */
|
|
441
443
|
--figma-elevation-100: 0px 0px 0.5px 0px rgba(0, 0, 0, 0.3),
|
|
442
444
|
0px 1px 3px 0px rgba(0, 0, 0, 0.15);
|
|
@@ -451,6 +453,7 @@
|
|
|
451
453
|
|
|
452
454
|
:root.figma-dark {
|
|
453
455
|
--icon-chevron: url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 16 16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5.87868 7.12132L8 9.24264L10.1213 7.12132' stroke='rgb(255 255 255 / 100%)' stroke-linecap='round'/%3E%3C/svg%3E%0A");
|
|
456
|
+
|
|
454
457
|
--handle-shadow: 0px 0 0 0.75px 0px 0 0 0.75px rgba(0, 0, 0, 0.1),
|
|
455
458
|
0px 0px 0.5px 0px rgba(255, 255, 255, 0.1);
|
|
456
459
|
--figma-color-bg-ghost-hover: rgba(255, 255, 255, 0.05);
|
|
@@ -506,10 +509,33 @@ input[type="password"],
|
|
|
506
509
|
&::-webkit-outer-spin-button,
|
|
507
510
|
&::-webkit-inner-spin-button {
|
|
508
511
|
display: none;
|
|
512
|
+
-webkit-appearance: none;
|
|
509
513
|
margin: 0;
|
|
510
514
|
}
|
|
511
515
|
}
|
|
512
516
|
|
|
517
|
+
fig-input-text {
|
|
518
|
+
&:has([slot="append"]) input[type="number"] {
|
|
519
|
+
&::-webkit-outer-spin-button,
|
|
520
|
+
&::-webkit-inner-spin-button {
|
|
521
|
+
display: none;
|
|
522
|
+
margin: 0;
|
|
523
|
+
opacity: 0;
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
&[steppers="true"] {
|
|
527
|
+
input[type="number"]::-webkit-inner-spin-button {
|
|
528
|
+
display: block;
|
|
529
|
+
opacity: 1;
|
|
530
|
+
height: 1.5rem;
|
|
531
|
+
width: 1.5rem;
|
|
532
|
+
margin-right: calc(var(--spacer-2) * -1);
|
|
533
|
+
background-color: var(--figma-color-text-secondary);
|
|
534
|
+
mask-image: var(--icon-steppers);
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
|
|
513
539
|
/* Textarea */
|
|
514
540
|
textarea {
|
|
515
541
|
min-height: 2rem;
|
package/example.html
CHANGED
|
@@ -272,15 +272,7 @@
|
|
|
272
272
|
label="Upload image"
|
|
273
273
|
size="large"></fig-image>
|
|
274
274
|
</fig-field>
|
|
275
|
-
|
|
276
|
-
<fig-field>
|
|
277
|
-
<label>Large (with upload)</label>
|
|
278
|
-
<fig-image upload="true"
|
|
279
|
-
label="Change image"
|
|
280
|
-
aspect-ratio="auto"
|
|
281
|
-
src="charli.jpeg"
|
|
282
|
-
size="large"></fig-image>
|
|
283
|
-
</fig-field>
|
|
275
|
+
|
|
284
276
|
<br /><br />
|
|
285
277
|
<fig-header>
|
|
286
278
|
<h2>Button</h2>
|
|
@@ -575,7 +567,8 @@
|
|
|
575
567
|
<fig-field>
|
|
576
568
|
<label>Numeric input</label>
|
|
577
569
|
<fig-input-text placeholder="###"
|
|
578
|
-
type="number"
|
|
570
|
+
type="number"
|
|
571
|
+
steppers="true"></fig-input-text>
|
|
579
572
|
</fig-field>
|
|
580
573
|
<fig-field>
|
|
581
574
|
<label>Password input</label>
|
|
@@ -920,15 +913,7 @@
|
|
|
920
913
|
</fig-button>
|
|
921
914
|
</fig-field>
|
|
922
915
|
</fig-content>
|
|
923
|
-
|
|
924
|
-
let elements = Array.from(document.querySelectorAll('*'));
|
|
925
|
-
elements.filter(n => n.tagName.toLowerCase().indexOf("fig-slider") > -1).forEach(n => n.addEventListener('input', (e) => {
|
|
926
|
-
console.log('input:', n.tagName, e.target)
|
|
927
|
-
}))
|
|
928
|
-
document.querySelectorAll('fig-input-color').forEach(n => n.addEventListener('change', (e) => {
|
|
929
|
-
console.log('change:', n.tagName, e.target.value)
|
|
930
|
-
}))
|
|
931
|
-
</script>
|
|
916
|
+
|
|
932
917
|
</body>
|
|
933
918
|
|
|
934
919
|
</html>
|
package/fig.js
CHANGED
|
@@ -450,7 +450,6 @@ class FigDialog extends HTMLDialogElement {
|
|
|
450
450
|
connectedCallback() {
|
|
451
451
|
this.modal =
|
|
452
452
|
this.hasAttribute("modal") && this.getAttribute("modal") !== "false";
|
|
453
|
-
|
|
454
453
|
requestAnimationFrame(() => {
|
|
455
454
|
this.#addCloseListeners();
|
|
456
455
|
});
|
|
@@ -983,8 +982,8 @@ class FigInputText extends HTMLElement {
|
|
|
983
982
|
|
|
984
983
|
//child nodes hack
|
|
985
984
|
requestAnimationFrame(() => {
|
|
986
|
-
|
|
987
|
-
|
|
985
|
+
let append = this.querySelector("[slot=append]");
|
|
986
|
+
let prepend = this.querySelector("[slot=prepend]");
|
|
988
987
|
|
|
989
988
|
this.innerHTML = html;
|
|
990
989
|
|
|
@@ -1031,7 +1030,6 @@ class FigInputText extends HTMLElement {
|
|
|
1031
1030
|
if (this.type === "number") {
|
|
1032
1031
|
value = value / (this.transform || 1);
|
|
1033
1032
|
value = this.#sanitizeInput(value, false);
|
|
1034
|
-
console.log("sanitizeInput", value);
|
|
1035
1033
|
valueTransformed = value * (this.transform || 1);
|
|
1036
1034
|
}
|
|
1037
1035
|
this.value = value;
|
|
@@ -1796,6 +1794,7 @@ window.customElements.define("fig-chit", FigChit);
|
|
|
1796
1794
|
* @attr {string} size - Size of the image preview
|
|
1797
1795
|
*/
|
|
1798
1796
|
class FigImage extends HTMLElement {
|
|
1797
|
+
#src = null;
|
|
1799
1798
|
constructor() {
|
|
1800
1799
|
super();
|
|
1801
1800
|
}
|
|
@@ -1838,9 +1837,6 @@ class FigImage extends HTMLElement {
|
|
|
1838
1837
|
this.#handleFileInput.bind(this)
|
|
1839
1838
|
);
|
|
1840
1839
|
}
|
|
1841
|
-
if (this.src) {
|
|
1842
|
-
this.#loadImage(this.src);
|
|
1843
|
-
}
|
|
1844
1840
|
});
|
|
1845
1841
|
}
|
|
1846
1842
|
async #loadImage(src) {
|
|
@@ -1848,13 +1844,22 @@ class FigImage extends HTMLElement {
|
|
|
1848
1844
|
await new Promise((resolve) => {
|
|
1849
1845
|
this.image = new Image();
|
|
1850
1846
|
this.image.crossOrigin = "Anonymous";
|
|
1851
|
-
|
|
1852
1847
|
this.image.onload = async () => {
|
|
1853
1848
|
this.aspectRatio = this.image.width / this.image.height;
|
|
1854
1849
|
this.style.setProperty(
|
|
1855
1850
|
"--aspect-ratio",
|
|
1856
1851
|
`${this.image.width}/${this.image.height}`
|
|
1857
1852
|
);
|
|
1853
|
+
this.dispatchEvent(
|
|
1854
|
+
new CustomEvent("loaded", {
|
|
1855
|
+
bubbles: true,
|
|
1856
|
+
cancelable: true,
|
|
1857
|
+
detail: {
|
|
1858
|
+
blob: this.blob,
|
|
1859
|
+
base64: this.base64,
|
|
1860
|
+
},
|
|
1861
|
+
})
|
|
1862
|
+
);
|
|
1858
1863
|
resolve();
|
|
1859
1864
|
|
|
1860
1865
|
// Create canvas to extract blob and base64 from image
|
|
@@ -1905,18 +1910,26 @@ class FigImage extends HTMLElement {
|
|
|
1905
1910
|
cancelable: true,
|
|
1906
1911
|
})
|
|
1907
1912
|
);
|
|
1908
|
-
this.src
|
|
1909
|
-
this.setAttribute("src", this.src);
|
|
1910
|
-
this.chit.setAttribute("src", this.src);
|
|
1913
|
+
this.setAttribute("src", this.blob);
|
|
1911
1914
|
}
|
|
1912
1915
|
static get observedAttributes() {
|
|
1913
1916
|
return ["src", "upload"];
|
|
1914
1917
|
}
|
|
1918
|
+
get src() {
|
|
1919
|
+
return this.#src;
|
|
1920
|
+
}
|
|
1921
|
+
set src(value) {
|
|
1922
|
+
this.#src = value;
|
|
1923
|
+
}
|
|
1924
|
+
|
|
1915
1925
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
1916
1926
|
if (name === "src") {
|
|
1917
1927
|
this.src = newValue;
|
|
1918
1928
|
if (this.chit) {
|
|
1919
|
-
this.chit.setAttribute("src", this
|
|
1929
|
+
this.chit.setAttribute("src", this.#src);
|
|
1930
|
+
}
|
|
1931
|
+
if (this.#src) {
|
|
1932
|
+
this.#loadImage(this.#src);
|
|
1920
1933
|
}
|
|
1921
1934
|
}
|
|
1922
1935
|
if (name === "upload") {
|
package/package.json
CHANGED
package/bun.lockb
DELETED
|
Binary file
|
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>
|