@rogieking/figui3 1.6.5 → 1.6.7
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/charli.jpeg +0 -0
- package/components.css +14 -1
- package/example.html +22 -0
- package/fig.js +46 -7
- package/package.json +1 -1
package/charli.jpeg
ADDED
|
Binary file
|
package/components.css
CHANGED
|
@@ -1190,6 +1190,7 @@ fig-image {
|
|
|
1190
1190
|
place-items: center;
|
|
1191
1191
|
width: var(--image-size);
|
|
1192
1192
|
height: var(--image-size);
|
|
1193
|
+
aspect-ratio: 1 / 1;
|
|
1193
1194
|
> * {
|
|
1194
1195
|
grid-area: 1/1;
|
|
1195
1196
|
}
|
|
@@ -1211,6 +1212,16 @@ fig-image {
|
|
|
1211
1212
|
&[size="large"] {
|
|
1212
1213
|
--image-size: 8rem;
|
|
1213
1214
|
}
|
|
1215
|
+
&[aspect-ratio="auto"] {
|
|
1216
|
+
aspect-ratio: var(--aspect-ratio);
|
|
1217
|
+
height: auto;
|
|
1218
|
+
fig-chit,
|
|
1219
|
+
fig-chit::after,
|
|
1220
|
+
input {
|
|
1221
|
+
height: auto !important;
|
|
1222
|
+
aspect-ratio: var(--aspect-ratio) !important;
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1214
1225
|
}
|
|
1215
1226
|
|
|
1216
1227
|
/* Combo input */
|
|
@@ -1856,6 +1867,7 @@ dialog,
|
|
|
1856
1867
|
padding: 0;
|
|
1857
1868
|
outline: 0;
|
|
1858
1869
|
border: 0;
|
|
1870
|
+
inset: auto;
|
|
1859
1871
|
color: var(--figma-color-text);
|
|
1860
1872
|
border-radius: var(--radius-large, 0.8125rem);
|
|
1861
1873
|
background: var(--figma-color-bg);
|
|
@@ -1970,7 +1982,8 @@ dialog[is="fig-dialog"] {
|
|
|
1970
1982
|
}
|
|
1971
1983
|
|
|
1972
1984
|
/* Tooltip */
|
|
1973
|
-
fig-tooltip
|
|
1985
|
+
fig-tooltip,
|
|
1986
|
+
fig-popover {
|
|
1974
1987
|
display: contents;
|
|
1975
1988
|
}
|
|
1976
1989
|
.fig-tooltip {
|
package/example.html
CHANGED
|
@@ -25,6 +25,19 @@
|
|
|
25
25
|
|
|
26
26
|
<h2><label>Effects/</label>UI3 Components</h2>
|
|
27
27
|
</fig-header>
|
|
28
|
+
|
|
29
|
+
<fig-popover action="click"
|
|
30
|
+
size="large">
|
|
31
|
+
<fig-button>
|
|
32
|
+
Hover me
|
|
33
|
+
</fig-button>
|
|
34
|
+
<div popover>
|
|
35
|
+
<fig-button>
|
|
36
|
+
Test
|
|
37
|
+
</fig-button>
|
|
38
|
+
</div>
|
|
39
|
+
</fig-popover>
|
|
40
|
+
|
|
28
41
|
<fig-content>
|
|
29
42
|
|
|
30
43
|
<br /><br /><br /><br /><br /><br /><br /><br /><br />
|
|
@@ -233,6 +246,15 @@
|
|
|
233
246
|
size="large"></fig-image>
|
|
234
247
|
</fig-field>
|
|
235
248
|
<br /><br />
|
|
249
|
+
<fig-field>
|
|
250
|
+
<label>Large (with upload)</label>
|
|
251
|
+
<fig-image upload="true"
|
|
252
|
+
label="Change image"
|
|
253
|
+
aspect-ratio="auto"
|
|
254
|
+
src="charli.jpeg"
|
|
255
|
+
size="large"></fig-image>
|
|
256
|
+
</fig-field>
|
|
257
|
+
<br /><br />
|
|
236
258
|
<fig-header>
|
|
237
259
|
<h2>Button</h2>
|
|
238
260
|
</fig-header>
|
package/fig.js
CHANGED
|
@@ -411,15 +411,13 @@ class FigPopover extends FigTooltip {
|
|
|
411
411
|
this.delay = parseInt(this.getAttribute("delay")) || 0;
|
|
412
412
|
}
|
|
413
413
|
render() {
|
|
414
|
-
|
|
415
|
-
//if (!this.popup) {
|
|
414
|
+
this.destroy();
|
|
416
415
|
this.popup = this.popup || this.querySelector("[popover]");
|
|
417
416
|
this.popup.setAttribute("class", "fig-popover");
|
|
418
417
|
this.popup.style.position = "fixed";
|
|
419
|
-
this.popup.style.
|
|
420
|
-
this.popup.style.
|
|
418
|
+
this.popup.style.visibility = "hidden";
|
|
419
|
+
this.popup.style.display = "inline-flex";
|
|
421
420
|
document.body.append(this.popup);
|
|
422
|
-
//}
|
|
423
421
|
}
|
|
424
422
|
|
|
425
423
|
destroy() {}
|
|
@@ -1805,6 +1803,12 @@ class FigImage extends HTMLElement {
|
|
|
1805
1803
|
this.innerHTML = this.#getInnerHTML();
|
|
1806
1804
|
this.#updateRefs();
|
|
1807
1805
|
}
|
|
1806
|
+
disconnectedCallback() {
|
|
1807
|
+
this.fileInput.removeEventListener(
|
|
1808
|
+
"change",
|
|
1809
|
+
this.#handleFileInput.bind(this)
|
|
1810
|
+
);
|
|
1811
|
+
}
|
|
1808
1812
|
|
|
1809
1813
|
#updateRefs() {
|
|
1810
1814
|
requestAnimationFrame(() => {
|
|
@@ -1815,12 +1819,47 @@ class FigImage extends HTMLElement {
|
|
|
1815
1819
|
|
|
1816
1820
|
this.fileInput.addEventListener(
|
|
1817
1821
|
"change",
|
|
1818
|
-
this
|
|
1822
|
+
this.#handleFileInput.bind(this)
|
|
1819
1823
|
);
|
|
1820
1824
|
}
|
|
1825
|
+
if (this.src) {
|
|
1826
|
+
this.#loadImage(this.src);
|
|
1827
|
+
}
|
|
1828
|
+
});
|
|
1829
|
+
}
|
|
1830
|
+
async #loadImage(src) {
|
|
1831
|
+
// Get blob from canvas
|
|
1832
|
+
await new Promise((resolve) => {
|
|
1833
|
+
this.image = new Image();
|
|
1834
|
+
this.image.crossOrigin = "Anonymous";
|
|
1835
|
+
|
|
1836
|
+
this.image.onload = async () => {
|
|
1837
|
+
this.aspectRatio = this.image.width / this.image.height;
|
|
1838
|
+
this.style.setProperty(
|
|
1839
|
+
"--aspect-ratio",
|
|
1840
|
+
`${this.image.width}/${this.image.height}`
|
|
1841
|
+
);
|
|
1842
|
+
resolve();
|
|
1843
|
+
|
|
1844
|
+
// Create canvas to extract blob and base64 from image
|
|
1845
|
+
const canvas = document.createElement("canvas");
|
|
1846
|
+
const ctx = canvas.getContext("2d");
|
|
1847
|
+
canvas.width = this.image.width;
|
|
1848
|
+
canvas.height = this.image.height;
|
|
1849
|
+
ctx.drawImage(this.image, 0, 0);
|
|
1850
|
+
|
|
1851
|
+
// Get base64 from canvas
|
|
1852
|
+
this.base64 = canvas.toDataURL();
|
|
1853
|
+
|
|
1854
|
+
// Get blob from canvas
|
|
1855
|
+
canvas.toBlob((blob) => {
|
|
1856
|
+
this.blob = URL.createObjectURL(blob);
|
|
1857
|
+
});
|
|
1858
|
+
};
|
|
1859
|
+
this.image.src = src;
|
|
1821
1860
|
});
|
|
1822
1861
|
}
|
|
1823
|
-
async handleFileInput(e) {
|
|
1862
|
+
async #handleFileInput(e) {
|
|
1824
1863
|
this.blob = URL.createObjectURL(e.target.files[0]);
|
|
1825
1864
|
//set base64 url
|
|
1826
1865
|
const reader = new FileReader();
|