@rogieking/figui3 4.8.3 → 4.9.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 +79 -91
- package/dist/components.css +1 -1
- package/dist/fig.css +1 -1
- package/dist/fig.js +37 -37
- package/fig.js +23 -50
- package/package.json +1 -1
package/fig.js
CHANGED
|
@@ -6614,10 +6614,10 @@ class FigInputPalette extends HTMLElement {
|
|
|
6614
6614
|
);
|
|
6615
6615
|
});
|
|
6616
6616
|
inlineWrap.appendChild(wrap);
|
|
6617
|
-
|
|
6618
|
-
if (this.#showAdd) this.#createAddButton(disabled, inlineWrap);
|
|
6619
6617
|
this.appendChild(inlineWrap);
|
|
6620
6618
|
|
|
6619
|
+
if (this.#showAdd) this.#createAddButton(disabled, this);
|
|
6620
|
+
|
|
6621
6621
|
const expandedWrap = document.createElement("div");
|
|
6622
6622
|
expandedWrap.className = "palette-colors-expanded";
|
|
6623
6623
|
this.#colors.forEach((entry, i) => {
|
|
@@ -6644,7 +6644,7 @@ class FigInputPalette extends HTMLElement {
|
|
|
6644
6644
|
ic.setAttribute("alpha", "true");
|
|
6645
6645
|
} else {
|
|
6646
6646
|
ic.setAttribute("text", "true");
|
|
6647
|
-
ic.setAttribute("alpha", "
|
|
6647
|
+
ic.setAttribute("alpha", "false");
|
|
6648
6648
|
ic.setAttribute("full", "");
|
|
6649
6649
|
}
|
|
6650
6650
|
if (disabled) ic.setAttribute("disabled", "");
|
|
@@ -6715,7 +6715,7 @@ class FigInputPalette extends HTMLElement {
|
|
|
6715
6715
|
#createAddButton(disabled, parent = this) {
|
|
6716
6716
|
const atMax = this.#colors.length >= this.#max;
|
|
6717
6717
|
const addBtn = document.createElement("fig-button");
|
|
6718
|
-
addBtn.setAttribute("variant", "
|
|
6718
|
+
addBtn.setAttribute("variant", "ghost");
|
|
6719
6719
|
addBtn.setAttribute("icon", "true");
|
|
6720
6720
|
addBtn.setAttribute("aria-label", "Add color");
|
|
6721
6721
|
addBtn.className = "palette-add-btn";
|
|
@@ -7041,7 +7041,7 @@ class FigInputGradient extends HTMLElement {
|
|
|
7041
7041
|
const gradientValue = JSON.stringify(this.value);
|
|
7042
7042
|
this.innerHTML = `
|
|
7043
7043
|
<fig-fill-picker mode="gradient"${expAttr} value='${gradientValue}'${disabled ? " disabled" : ""}>
|
|
7044
|
-
<fig-chit
|
|
7044
|
+
<fig-chit background="${this.#buildGradientCSS()}"${disabled ? " disabled" : ""}></fig-chit>
|
|
7045
7045
|
</fig-fill-picker>`;
|
|
7046
7046
|
this.#chit = this.querySelector("fig-chit");
|
|
7047
7047
|
this.#track = null;
|
|
@@ -7050,7 +7050,7 @@ class FigInputGradient extends HTMLElement {
|
|
|
7050
7050
|
}
|
|
7051
7051
|
|
|
7052
7052
|
this.innerHTML = `
|
|
7053
|
-
<fig-chit
|
|
7053
|
+
<fig-chit background="${this.#buildGradientCSS()}"${disabled ? " disabled" : ""}></fig-chit>
|
|
7054
7054
|
${mode === "true" ? `<div class="fig-input-gradient-track">${this.#buildStopHandles()}</div>` : ""}`;
|
|
7055
7055
|
this.#chit = this.querySelector("fig-chit");
|
|
7056
7056
|
this.#track = this.querySelector(".fig-input-gradient-track");
|
|
@@ -8380,7 +8380,6 @@ customElements.define("fig-swatch", FigSwatch);
|
|
|
8380
8380
|
*/
|
|
8381
8381
|
class FigMedia extends HTMLElement {
|
|
8382
8382
|
#src = null;
|
|
8383
|
-
#chit = null;
|
|
8384
8383
|
#mediaEl = null;
|
|
8385
8384
|
#fileInput = null;
|
|
8386
8385
|
#blobUrl = null;
|
|
@@ -8465,27 +8464,16 @@ class FigMedia extends HTMLElement {
|
|
|
8465
8464
|
|
|
8466
8465
|
const ar = this.getAttribute("aspect-ratio");
|
|
8467
8466
|
if (ar) {
|
|
8468
|
-
this.style.setProperty("--aspect-ratio", ar);
|
|
8467
|
+
this.style.setProperty("--fig-media-aspect-ratio", ar);
|
|
8468
|
+
} else {
|
|
8469
|
+
this.style.setProperty("--fig-media-aspect-ratio", "4/3");
|
|
8469
8470
|
}
|
|
8470
8471
|
const fit = this.getAttribute("fit");
|
|
8471
8472
|
if (fit) {
|
|
8472
|
-
this.style.setProperty("--fit", fit);
|
|
8473
|
+
this.style.setProperty("--fig-media-fit", fit);
|
|
8473
8474
|
}
|
|
8474
8475
|
|
|
8475
|
-
|
|
8476
|
-
const chit = document.createElement("fig-chit");
|
|
8477
|
-
chit.setAttribute("data-generated", "");
|
|
8478
|
-
chit.setAttribute("size", "large");
|
|
8479
|
-
chit.setAttribute("data-type", this.mediaKind);
|
|
8480
|
-
chit.setAttribute("disabled", "");
|
|
8481
|
-
this.#applyChitBackground(chit);
|
|
8482
|
-
if (this.hasAttribute("checkerboard") && this.getAttribute("checkerboard") !== "false") {
|
|
8483
|
-
chit.setAttribute("checkerboard", "");
|
|
8484
|
-
}
|
|
8485
|
-
this.prepend(chit);
|
|
8486
|
-
}
|
|
8487
|
-
this.#chit = this.querySelector("fig-chit");
|
|
8488
|
-
this.#syncChitType();
|
|
8476
|
+
this.querySelectorAll("fig-chit[data-generated]").forEach((el) => el.remove());
|
|
8489
8477
|
this.#ensureMediaElement();
|
|
8490
8478
|
this.#syncGeneratedMediaElement();
|
|
8491
8479
|
|
|
@@ -8504,16 +8492,6 @@ class FigMedia extends HTMLElement {
|
|
|
8504
8492
|
}
|
|
8505
8493
|
}
|
|
8506
8494
|
|
|
8507
|
-
#applyChitBackground(chit) {
|
|
8508
|
-
const cb = this.hasAttribute("checkerboard") && this.getAttribute("checkerboard") !== "false";
|
|
8509
|
-
chit.setAttribute("background", cb ? "url()" : "var(--figma-color-bg-secondary)");
|
|
8510
|
-
}
|
|
8511
|
-
|
|
8512
|
-
#syncChitType() {
|
|
8513
|
-
if (!this.#chit) return;
|
|
8514
|
-
this.#chit.setAttribute("data-type", this.mediaKind);
|
|
8515
|
-
}
|
|
8516
|
-
|
|
8517
8495
|
#removeMediaElementListeners() {
|
|
8518
8496
|
if (!this.#mediaEl) return;
|
|
8519
8497
|
if (this.#mediaEl.tagName === "VIDEO") {
|
|
@@ -8556,12 +8534,19 @@ class FigMedia extends HTMLElement {
|
|
|
8556
8534
|
video.setAttribute("data-generated", "");
|
|
8557
8535
|
video.className = "fig-media-element";
|
|
8558
8536
|
video.setAttribute("playsinline", "");
|
|
8559
|
-
video.preload = "
|
|
8537
|
+
video.preload = "auto";
|
|
8560
8538
|
this.prepend(video);
|
|
8561
8539
|
this.#mediaEl = video;
|
|
8562
8540
|
this.#mediaEl.addEventListener("play", this.#boundHandleMediaPlay);
|
|
8563
8541
|
this.#mediaEl.addEventListener("pause", this.#boundHandleMediaPause);
|
|
8564
8542
|
this.#mediaEl.addEventListener("ended", this.#boundHandleMediaEnded);
|
|
8543
|
+
const seekToFirstFrame = () => {
|
|
8544
|
+
if (this.#mediaEl?.autoplay) return;
|
|
8545
|
+
try {
|
|
8546
|
+
this.#mediaEl.currentTime = 0.001;
|
|
8547
|
+
} catch {}
|
|
8548
|
+
};
|
|
8549
|
+
this.#mediaEl.addEventListener("loadedmetadata", seekToFirstFrame, { once: true });
|
|
8565
8550
|
} else {
|
|
8566
8551
|
const img = document.createElement("img");
|
|
8567
8552
|
img.setAttribute("data-generated", "");
|
|
@@ -8724,7 +8709,6 @@ class FigMedia extends HTMLElement {
|
|
|
8724
8709
|
}
|
|
8725
8710
|
|
|
8726
8711
|
if (name === "type") {
|
|
8727
|
-
this.#syncChitType();
|
|
8728
8712
|
this.#ensureMediaElement();
|
|
8729
8713
|
this.#syncGeneratedMediaElement();
|
|
8730
8714
|
if (this.#fileInput) {
|
|
@@ -8750,28 +8734,17 @@ class FigMedia extends HTMLElement {
|
|
|
8750
8734
|
|
|
8751
8735
|
if (name === "aspect-ratio") {
|
|
8752
8736
|
if (newValue) {
|
|
8753
|
-
this.style.setProperty("--aspect-ratio", newValue);
|
|
8737
|
+
this.style.setProperty("--fig-media-aspect-ratio", newValue);
|
|
8754
8738
|
} else {
|
|
8755
|
-
this.style.removeProperty("--aspect-ratio");
|
|
8739
|
+
this.style.removeProperty("--fig-media-aspect-ratio");
|
|
8756
8740
|
}
|
|
8757
8741
|
}
|
|
8758
8742
|
|
|
8759
8743
|
if (name === "fit") {
|
|
8760
8744
|
if (newValue) {
|
|
8761
|
-
this.style.setProperty("--fit", newValue);
|
|
8745
|
+
this.style.setProperty("--fig-media-fit", newValue);
|
|
8762
8746
|
} else {
|
|
8763
|
-
this.style.removeProperty("--fit");
|
|
8764
|
-
}
|
|
8765
|
-
}
|
|
8766
|
-
|
|
8767
|
-
if (name === "checkerboard") {
|
|
8768
|
-
if (this.#chit) {
|
|
8769
|
-
if (newValue !== null && newValue !== "false") {
|
|
8770
|
-
this.#chit.setAttribute("checkerboard", "");
|
|
8771
|
-
} else {
|
|
8772
|
-
this.#chit.removeAttribute("checkerboard");
|
|
8773
|
-
}
|
|
8774
|
-
this.#applyChitBackground(this.#chit);
|
|
8747
|
+
this.style.removeProperty("--fig-media-fit");
|
|
8775
8748
|
}
|
|
8776
8749
|
}
|
|
8777
8750
|
|
package/package.json
CHANGED