@rogieking/figui3 2.1.4 → 2.1.5
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 +44 -0
- package/fig.js +28 -1
- package/package.json +1 -1
package/example.html
CHANGED
|
@@ -605,6 +605,26 @@
|
|
|
605
605
|
<fig-chit background="#9747FF"
|
|
606
606
|
size="large"></fig-chit>
|
|
607
607
|
</fig-field>
|
|
608
|
+
<fig-field direction="horizontal">
|
|
609
|
+
<label>Large (Gradient)</label>
|
|
610
|
+
<fig-chit background="linear-gradient(135deg, #667eea 0%, #764ba2 100%)"
|
|
611
|
+
size="large"></fig-chit>
|
|
612
|
+
</fig-field>
|
|
613
|
+
<fig-field direction="horizontal">
|
|
614
|
+
<label>Large (Radial)</label>
|
|
615
|
+
<fig-chit background="radial-gradient(circle, #ff6b6b, #4ecdc4)"
|
|
616
|
+
size="large"></fig-chit>
|
|
617
|
+
</fig-field>
|
|
618
|
+
<fig-field direction="horizontal">
|
|
619
|
+
<label>Large (Angular)</label>
|
|
620
|
+
<fig-chit background="conic-gradient(from 0deg, #ff0000, #ff8800, #ffff00, #00ff00, #0088ff, #8800ff, #ff0000)"
|
|
621
|
+
size="large"></fig-chit>
|
|
622
|
+
</fig-field>
|
|
623
|
+
<fig-field direction="horizontal">
|
|
624
|
+
<label>Large (Image)</label>
|
|
625
|
+
<fig-chit background="url(https://avatars.githubusercontent.com/u/12345678?v=4)"
|
|
626
|
+
size="large"></fig-chit>
|
|
627
|
+
</fig-field>
|
|
608
628
|
|
|
609
629
|
<h3>States</h3>
|
|
610
630
|
<fig-field direction="horizontal">
|
|
@@ -947,6 +967,9 @@
|
|
|
947
967
|
document.getElementById('fill-picker-events').addEventListener('input', (e) => {
|
|
948
968
|
document.getElementById('fill-picker-output').textContent = 'Input: ' + JSON.stringify(e.detail);
|
|
949
969
|
});
|
|
970
|
+
document.getElementById('fill-picker-events').addEventListener('change', (e) => {
|
|
971
|
+
document.getElementById('fill-picker-output').textContent = 'Change: ' + JSON.stringify(e.detail);
|
|
972
|
+
});
|
|
950
973
|
</script>
|
|
951
974
|
</section>
|
|
952
975
|
<hr>
|
|
@@ -1230,6 +1253,27 @@
|
|
|
1230
1253
|
text="true"
|
|
1231
1254
|
alpha="true"></fig-input-color>
|
|
1232
1255
|
</div>
|
|
1256
|
+
|
|
1257
|
+
<h3>Event Listening</h3>
|
|
1258
|
+
<fig-input-color id="input-color-events"
|
|
1259
|
+
value="#FF6B6B"
|
|
1260
|
+
text="true"
|
|
1261
|
+
alpha="true"
|
|
1262
|
+
picker="figma"></fig-input-color>
|
|
1263
|
+
<p class="description"
|
|
1264
|
+
id="input-color-output">Change the color above to see events.</p>
|
|
1265
|
+
<script>
|
|
1266
|
+
document.getElementById('input-color-events').addEventListener('input', (e) => {
|
|
1267
|
+
const el = e.target;
|
|
1268
|
+
document.getElementById('input-color-output').textContent =
|
|
1269
|
+
`Input: ${el.value} | Hex: ${el.hexOpaque} | Alpha: ${el.alpha}%`;
|
|
1270
|
+
});
|
|
1271
|
+
document.getElementById('input-color-events').addEventListener('change', (e) => {
|
|
1272
|
+
const el = e.target;
|
|
1273
|
+
document.getElementById('input-color-output').textContent =
|
|
1274
|
+
`Change: ${el.value} | Hex: ${el.hexOpaque} | Alpha: ${el.alpha}%`;
|
|
1275
|
+
});
|
|
1276
|
+
</script>
|
|
1233
1277
|
</section>
|
|
1234
1278
|
<hr>
|
|
1235
1279
|
|
package/fig.js
CHANGED
|
@@ -2203,6 +2203,10 @@ class FigInputColor extends HTMLElement {
|
|
|
2203
2203
|
"input",
|
|
2204
2204
|
this.#handleAlphaInput.bind(this)
|
|
2205
2205
|
);
|
|
2206
|
+
this.#alphaInput.addEventListener(
|
|
2207
|
+
"change",
|
|
2208
|
+
this.#handleChange.bind(this)
|
|
2209
|
+
);
|
|
2206
2210
|
}
|
|
2207
2211
|
});
|
|
2208
2212
|
}
|
|
@@ -2290,7 +2294,15 @@ class FigInputColor extends HTMLElement {
|
|
|
2290
2294
|
event.stopPropagation();
|
|
2291
2295
|
const detail = event.detail;
|
|
2292
2296
|
if (detail && detail.color) {
|
|
2293
|
-
|
|
2297
|
+
// Build hex value with alpha included
|
|
2298
|
+
let hexValue = detail.color;
|
|
2299
|
+
if (detail.alpha !== undefined) {
|
|
2300
|
+
const alphaHex = Math.round(detail.alpha * 255)
|
|
2301
|
+
.toString(16)
|
|
2302
|
+
.padStart(2, "0");
|
|
2303
|
+
hexValue = detail.color + alphaHex;
|
|
2304
|
+
}
|
|
2305
|
+
this.#setValues(hexValue);
|
|
2294
2306
|
if (this.#textInput) {
|
|
2295
2307
|
this.#textInput.setAttribute(
|
|
2296
2308
|
"value",
|
|
@@ -2300,6 +2312,10 @@ class FigInputColor extends HTMLElement {
|
|
|
2300
2312
|
if (this.#alphaInput && detail.alpha !== undefined) {
|
|
2301
2313
|
this.#alphaInput.setAttribute("value", Math.round(detail.alpha * 100));
|
|
2302
2314
|
}
|
|
2315
|
+
if (this.#swatch) {
|
|
2316
|
+
this.#swatch.setAttribute("background", this.hexOpaque);
|
|
2317
|
+
this.#swatch.setAttribute("alpha", this.rgba.a);
|
|
2318
|
+
}
|
|
2303
2319
|
this.#emitInputEvent();
|
|
2304
2320
|
}
|
|
2305
2321
|
}
|
|
@@ -4347,6 +4363,9 @@ class FigFillPicker extends HTMLElement {
|
|
|
4347
4363
|
this.#updateColorInputs();
|
|
4348
4364
|
this.#emitInput();
|
|
4349
4365
|
});
|
|
4366
|
+
this.#hueSlider.addEventListener("change", () => {
|
|
4367
|
+
this.#emitChange();
|
|
4368
|
+
});
|
|
4350
4369
|
|
|
4351
4370
|
// Setup opacity slider
|
|
4352
4371
|
if (showAlpha) {
|
|
@@ -4358,6 +4377,9 @@ class FigFillPicker extends HTMLElement {
|
|
|
4358
4377
|
this.#updateColorInputs();
|
|
4359
4378
|
this.#emitInput();
|
|
4360
4379
|
});
|
|
4380
|
+
this.#opacitySlider.addEventListener("change", () => {
|
|
4381
|
+
this.#emitChange();
|
|
4382
|
+
});
|
|
4361
4383
|
}
|
|
4362
4384
|
|
|
4363
4385
|
// Setup color input
|
|
@@ -4375,6 +4397,9 @@ class FigFillPicker extends HTMLElement {
|
|
|
4375
4397
|
}
|
|
4376
4398
|
this.#emitInput();
|
|
4377
4399
|
});
|
|
4400
|
+
colorInput.addEventListener("change", () => {
|
|
4401
|
+
this.#emitChange();
|
|
4402
|
+
});
|
|
4378
4403
|
|
|
4379
4404
|
// Setup eyedropper
|
|
4380
4405
|
const eyedropper = container.querySelector(".fig-fill-picker-eyedropper");
|
|
@@ -4480,6 +4505,7 @@ class FigFillPicker extends HTMLElement {
|
|
|
4480
4505
|
|
|
4481
4506
|
this.#colorArea.addEventListener("pointerup", () => {
|
|
4482
4507
|
this.#isDraggingColor = false;
|
|
4508
|
+
this.#emitChange();
|
|
4483
4509
|
});
|
|
4484
4510
|
|
|
4485
4511
|
// Handle drag (for when handle is at corners)
|
|
@@ -4497,6 +4523,7 @@ class FigFillPicker extends HTMLElement {
|
|
|
4497
4523
|
|
|
4498
4524
|
this.#colorAreaHandle.addEventListener("pointerup", () => {
|
|
4499
4525
|
this.#isDraggingColor = false;
|
|
4526
|
+
this.#emitChange();
|
|
4500
4527
|
});
|
|
4501
4528
|
}
|
|
4502
4529
|
|