@rogieking/figui3 2.33.4 → 2.35.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 +48 -3
- package/fig.js +62 -6
- package/package.json +1 -1
package/components.css
CHANGED
|
@@ -1439,10 +1439,20 @@ fig-3d-rotate {
|
|
|
1439
1439
|
gap: var(--spacer-2);
|
|
1440
1440
|
width: 100%;
|
|
1441
1441
|
--aspect-ratio: 1 / 1;
|
|
1442
|
+
--perspective: 20rem;
|
|
1443
|
+
--perspective-origin: 50% 50%;
|
|
1444
|
+
--transform-origin: 50% 50% -50cqi;
|
|
1442
1445
|
--gradient-start-color: light-dark(
|
|
1443
1446
|
rgba(0, 0, 0, 0.05),
|
|
1444
1447
|
rgba(255, 255, 255, 0.05)
|
|
1445
1448
|
);
|
|
1449
|
+
--border-width: 1px;
|
|
1450
|
+
--border-start-color: light-dark(
|
|
1451
|
+
rgba(0, 0, 0, 0.15),
|
|
1452
|
+
rgba(255, 255, 255, 0.15)
|
|
1453
|
+
);
|
|
1454
|
+
--border-end-color: transparent;
|
|
1455
|
+
--border-end-color: transparent;
|
|
1446
1456
|
--gradient-end-color: transparent;
|
|
1447
1457
|
--figma-3d-rotate-handle-size: 6px;
|
|
1448
1458
|
--front-face-bg: light-dark(var(--figma-color-bg), #555);
|
|
@@ -1484,7 +1494,9 @@ fig-3d-rotate {
|
|
|
1484
1494
|
aspect-ratio: 1 / 1;
|
|
1485
1495
|
max-height: max(3.5rem, 50%);
|
|
1486
1496
|
max-width: max(3.5rem, 50%);
|
|
1487
|
-
perspective: 20rem;
|
|
1497
|
+
perspective: var(--perspective, 20rem);
|
|
1498
|
+
perspective-origin: var(--perspective-origin, 50% 50%);
|
|
1499
|
+
container-type: inline-size;
|
|
1488
1500
|
}
|
|
1489
1501
|
|
|
1490
1502
|
.fig-3d-rotate-cube {
|
|
@@ -1493,6 +1505,7 @@ fig-3d-rotate {
|
|
|
1493
1505
|
position: relative;
|
|
1494
1506
|
aspect-ratio: 1 / 1;
|
|
1495
1507
|
transform-style: preserve-3d;
|
|
1508
|
+
transform-origin: var(--transform-origin, 50% 50% -50cqi);
|
|
1496
1509
|
}
|
|
1497
1510
|
|
|
1498
1511
|
.fig-3d-rotate-face {
|
|
@@ -1531,8 +1544,8 @@ fig-3d-rotate {
|
|
|
1531
1544
|
rotateY(-0.25turn);
|
|
1532
1545
|
background: linear-gradient(
|
|
1533
1546
|
to bottom,
|
|
1534
|
-
var(--
|
|
1535
|
-
var(--
|
|
1547
|
+
var(--border-start-color),
|
|
1548
|
+
var(--border-end-color)
|
|
1536
1549
|
);
|
|
1537
1550
|
border-radius: var(--radius-medium);
|
|
1538
1551
|
}
|
|
@@ -1544,6 +1557,14 @@ fig-3d-rotate {
|
|
|
1544
1557
|
var(--gradient-start-color),
|
|
1545
1558
|
var(--gradient-end-color)
|
|
1546
1559
|
);
|
|
1560
|
+
border-width: var(--border-width) 0;
|
|
1561
|
+
border-style: solid;
|
|
1562
|
+
border-image: linear-gradient(
|
|
1563
|
+
to right,
|
|
1564
|
+
var(--border-start-color),
|
|
1565
|
+
var(--border-end-color)
|
|
1566
|
+
)
|
|
1567
|
+
1;
|
|
1547
1568
|
}
|
|
1548
1569
|
&.left {
|
|
1549
1570
|
transform-origin: 100% 50%;
|
|
@@ -1553,6 +1574,14 @@ fig-3d-rotate {
|
|
|
1553
1574
|
var(--gradient-start-color),
|
|
1554
1575
|
var(--gradient-end-color)
|
|
1555
1576
|
);
|
|
1577
|
+
border-width: var(--border-width) 0;
|
|
1578
|
+
border-style: solid;
|
|
1579
|
+
border-image: linear-gradient(
|
|
1580
|
+
to left,
|
|
1581
|
+
var(--border-start-color),
|
|
1582
|
+
var(--border-end-color)
|
|
1583
|
+
)
|
|
1584
|
+
1;
|
|
1556
1585
|
}
|
|
1557
1586
|
&.top {
|
|
1558
1587
|
translate: 0 -100%;
|
|
@@ -1563,6 +1592,14 @@ fig-3d-rotate {
|
|
|
1563
1592
|
var(--gradient-start-color),
|
|
1564
1593
|
var(--gradient-end-color)
|
|
1565
1594
|
);
|
|
1595
|
+
border-width: 0 var(--border-width);
|
|
1596
|
+
border-style: solid;
|
|
1597
|
+
border-image: linear-gradient(
|
|
1598
|
+
to top,
|
|
1599
|
+
var(--border-start-color),
|
|
1600
|
+
var(--border-end-color)
|
|
1601
|
+
)
|
|
1602
|
+
1;
|
|
1566
1603
|
}
|
|
1567
1604
|
&.bottom {
|
|
1568
1605
|
top: 100%;
|
|
@@ -1574,6 +1611,14 @@ fig-3d-rotate {
|
|
|
1574
1611
|
var(--gradient-start-color),
|
|
1575
1612
|
var(--gradient-end-color)
|
|
1576
1613
|
);
|
|
1614
|
+
border-width: 0 var(--border-width);
|
|
1615
|
+
border-style: solid;
|
|
1616
|
+
border-image: linear-gradient(
|
|
1617
|
+
to bottom,
|
|
1618
|
+
var(--border-start-color),
|
|
1619
|
+
var(--border-end-color)
|
|
1620
|
+
)
|
|
1621
|
+
1;
|
|
1577
1622
|
}
|
|
1578
1623
|
}
|
|
1579
1624
|
}
|
package/fig.js
CHANGED
|
@@ -6462,12 +6462,15 @@ class Fig3DRotate extends HTMLElement {
|
|
|
6462
6462
|
#fieldInputs = {};
|
|
6463
6463
|
|
|
6464
6464
|
static get observedAttributes() {
|
|
6465
|
-
return ["value", "precision", "aspect-ratio", "fields"];
|
|
6465
|
+
return ["value", "precision", "aspect-ratio", "fields", "perspective", "perspective-origin", "transform-origin"];
|
|
6466
6466
|
}
|
|
6467
6467
|
|
|
6468
6468
|
connectedCallback() {
|
|
6469
6469
|
this.#precision = parseInt(this.getAttribute("precision") || "1");
|
|
6470
6470
|
this.#syncAspectRatioVar(this.getAttribute("aspect-ratio"));
|
|
6471
|
+
this.#syncPerspectiveVar(this.getAttribute("perspective"));
|
|
6472
|
+
this.#syncCSSVar("--perspective-origin", this.getAttribute("perspective-origin"));
|
|
6473
|
+
this.#syncTransformOrigin(this.getAttribute("transform-origin"));
|
|
6471
6474
|
this.#parseFields(this.getAttribute("fields"));
|
|
6472
6475
|
const val = this.getAttribute("value");
|
|
6473
6476
|
if (val) this.#parseValue(val);
|
|
@@ -6490,6 +6493,35 @@ class Fig3DRotate extends HTMLElement {
|
|
|
6490
6493
|
}
|
|
6491
6494
|
}
|
|
6492
6495
|
|
|
6496
|
+
#syncPerspectiveVar(value) {
|
|
6497
|
+
if (value && value.trim()) {
|
|
6498
|
+
this.style.setProperty("--perspective", value.trim());
|
|
6499
|
+
} else {
|
|
6500
|
+
this.style.removeProperty("--perspective");
|
|
6501
|
+
}
|
|
6502
|
+
}
|
|
6503
|
+
|
|
6504
|
+
#syncCSSVar(prop, value) {
|
|
6505
|
+
if (value && value.trim()) {
|
|
6506
|
+
this.style.setProperty(prop, value.trim());
|
|
6507
|
+
} else {
|
|
6508
|
+
this.style.removeProperty(prop);
|
|
6509
|
+
}
|
|
6510
|
+
}
|
|
6511
|
+
|
|
6512
|
+
#syncTransformOrigin(value) {
|
|
6513
|
+
if (!value || !value.trim()) {
|
|
6514
|
+
this.style.removeProperty("--transform-origin");
|
|
6515
|
+
return;
|
|
6516
|
+
}
|
|
6517
|
+
const parts = value.trim().split(/\s+/);
|
|
6518
|
+
if (parts.length === 2) {
|
|
6519
|
+
this.style.setProperty("--transform-origin", `${parts[0]} ${parts[1]} -50cqi`);
|
|
6520
|
+
} else {
|
|
6521
|
+
this.style.setProperty("--transform-origin", value.trim());
|
|
6522
|
+
}
|
|
6523
|
+
}
|
|
6524
|
+
|
|
6493
6525
|
#parseFields(str) {
|
|
6494
6526
|
if (!str || !str.trim()) {
|
|
6495
6527
|
this.#fields = [];
|
|
@@ -6507,6 +6539,18 @@ class Fig3DRotate extends HTMLElement {
|
|
|
6507
6539
|
this.#syncAspectRatioVar(newValue);
|
|
6508
6540
|
return;
|
|
6509
6541
|
}
|
|
6542
|
+
if (name === "perspective") {
|
|
6543
|
+
this.#syncPerspectiveVar(newValue);
|
|
6544
|
+
return;
|
|
6545
|
+
}
|
|
6546
|
+
if (name === "perspective-origin") {
|
|
6547
|
+
this.#syncCSSVar("--perspective-origin", newValue);
|
|
6548
|
+
return;
|
|
6549
|
+
}
|
|
6550
|
+
if (name === "transform-origin") {
|
|
6551
|
+
this.#syncTransformOrigin(newValue);
|
|
6552
|
+
return;
|
|
6553
|
+
}
|
|
6510
6554
|
if (name === "fields") {
|
|
6511
6555
|
this.#parseFields(newValue);
|
|
6512
6556
|
if (this.#cube) this.#render();
|
|
@@ -6655,6 +6699,7 @@ class Fig3DRotate extends HTMLElement {
|
|
|
6655
6699
|
e.preventDefault();
|
|
6656
6700
|
this.#isDragging = true;
|
|
6657
6701
|
this.#container.classList.add("dragging");
|
|
6702
|
+
this.#container.setPointerCapture(e.pointerId);
|
|
6658
6703
|
|
|
6659
6704
|
const startX = e.clientX;
|
|
6660
6705
|
const startY = e.clientY;
|
|
@@ -6663,25 +6708,36 @@ class Fig3DRotate extends HTMLElement {
|
|
|
6663
6708
|
|
|
6664
6709
|
const onMove = (e) => {
|
|
6665
6710
|
if (!this.#isDragging) return;
|
|
6711
|
+
if (e.buttons === 0) {
|
|
6712
|
+
onEnd();
|
|
6713
|
+
return;
|
|
6714
|
+
}
|
|
6666
6715
|
const dx = e.clientX - startX;
|
|
6667
6716
|
const dy = e.clientY - startY;
|
|
6668
6717
|
this.#ry = this.#snapToIncrement(startRy + dx * 0.5);
|
|
6669
6718
|
this.#rx = this.#snapToIncrement(startRx - dy * 0.5);
|
|
6670
6719
|
this.#updateCube();
|
|
6671
6720
|
this.#syncFieldInputs();
|
|
6721
|
+
this.setAttribute("value", this.value);
|
|
6672
6722
|
this.#emit("input");
|
|
6673
6723
|
};
|
|
6674
6724
|
|
|
6675
|
-
const
|
|
6725
|
+
const onEnd = () => {
|
|
6726
|
+
if (!this.#isDragging) return;
|
|
6727
|
+
this.setAttribute("value", this.value);
|
|
6676
6728
|
this.#isDragging = false;
|
|
6677
6729
|
this.#container.classList.remove("dragging");
|
|
6678
|
-
|
|
6679
|
-
|
|
6730
|
+
this.#container.removeEventListener("pointermove", onMove);
|
|
6731
|
+
this.#container.removeEventListener("pointerup", onEnd);
|
|
6732
|
+
this.#container.removeEventListener("pointercancel", onEnd);
|
|
6733
|
+
this.#container.removeEventListener("lostpointercapture", onEnd);
|
|
6680
6734
|
this.#emit("change");
|
|
6681
6735
|
};
|
|
6682
6736
|
|
|
6683
|
-
|
|
6684
|
-
|
|
6737
|
+
this.#container.addEventListener("pointermove", onMove);
|
|
6738
|
+
this.#container.addEventListener("pointerup", onEnd);
|
|
6739
|
+
this.#container.addEventListener("pointercancel", onEnd);
|
|
6740
|
+
this.#container.addEventListener("lostpointercapture", onEnd);
|
|
6685
6741
|
}
|
|
6686
6742
|
}
|
|
6687
6743
|
customElements.define("fig-3d-rotate", Fig3DRotate);
|
package/package.json
CHANGED