@rogieking/figui3 1.3.3 → 1.3.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 +1 -1
- package/fig.css +33 -19
- package/fig.js +35 -2
- package/package.json +1 -1
package/example.html
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
<fig-content>
|
|
26
26
|
<fig-input-angle text="true"
|
|
27
27
|
value="0"
|
|
28
|
-
onInput="console.log(event.target.
|
|
28
|
+
onInput="console.log(event.target.adjacent, event.target.opposite)"></fig-input-angle>
|
|
29
29
|
<br /><br />
|
|
30
30
|
<fig-input-joystick></fig-input-joystick>
|
|
31
31
|
<br /><br />
|
package/fig.css
CHANGED
|
@@ -413,9 +413,9 @@
|
|
|
413
413
|
--body-medium-strong-fontWeight: 550;
|
|
414
414
|
--body-large-strong-fontWeight: 500;
|
|
415
415
|
--body-medium-fontWeight: 450;
|
|
416
|
-
--handle-shadow: 0px 0 0 0.75px rgba(0, 0, 0, 0.
|
|
416
|
+
--handle-shadow: 0px 0 0 0.75px rgba(0, 0, 0, 0.05),
|
|
417
417
|
0px 1px 3px 0px rgba(0, 0, 0, 0.05), 0px 3px 8px 0px rgba(0, 0, 0, 0.05),
|
|
418
|
-
0px 0px 0.5px 0px rgba(0, 0, 0, 0.1);
|
|
418
|
+
0px 0px 0.5px 0px rgba(0, 0, 0, 0.1), var(--figma-elevation-200);
|
|
419
419
|
|
|
420
420
|
--popover-min-width: 15rem;
|
|
421
421
|
--figma-color-bg-ghost-hover: rgba(0, 0, 0, 0.05);
|
|
@@ -1211,7 +1211,7 @@ input[type="checkbox"].switch {
|
|
|
1211
1211
|
align-items: center;
|
|
1212
1212
|
justify-content: center;
|
|
1213
1213
|
border-radius: 0.5rem;
|
|
1214
|
-
background-color: var(--figma-color-bg-
|
|
1214
|
+
background-color: var(--figma-color-bg-secondary);
|
|
1215
1215
|
transition: var(--input-transition);
|
|
1216
1216
|
box-sizing: border-box;
|
|
1217
1217
|
box-shadow: inset 0 0 0 1px var(--figma-color-bordertranslucent);
|
|
@@ -1245,7 +1245,7 @@ input[type="checkbox"].switch:checked:after {
|
|
|
1245
1245
|
}
|
|
1246
1246
|
|
|
1247
1247
|
input[type="checkbox"].switch:disabled {
|
|
1248
|
-
background-color: var(--figma-color-bg-
|
|
1248
|
+
background-color: var(--figma-color-bg-secondary);
|
|
1249
1249
|
cursor: not-allowed;
|
|
1250
1250
|
&:after {
|
|
1251
1251
|
background-color: var(--figma-color-bg);
|
|
@@ -1288,9 +1288,10 @@ input[type="checkbox"]:not(.switch) {
|
|
|
1288
1288
|
}
|
|
1289
1289
|
}
|
|
1290
1290
|
}
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1291
|
+
@media (prefers-color-scheme: light) {
|
|
1292
|
+
input[type="checkbox"]:not(.switch):hover {
|
|
1293
|
+
background-image: 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='M4.50012 7.5L7.50012 10.5L11.5001 4.5' stroke='black' opacity='0.25' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.125' /%3E%3C/svg%3E%0A");
|
|
1294
|
+
}
|
|
1294
1295
|
}
|
|
1295
1296
|
|
|
1296
1297
|
label.checkbox:has([type="checkbox"]) {
|
|
@@ -1335,6 +1336,7 @@ input[type="radio"] {
|
|
|
1335
1336
|
&::after {
|
|
1336
1337
|
transform: scale(1);
|
|
1337
1338
|
opacity: 0.25;
|
|
1339
|
+
background-color: var(--figma-color-icon);
|
|
1338
1340
|
}
|
|
1339
1341
|
}
|
|
1340
1342
|
|
|
@@ -1343,7 +1345,7 @@ input[type="radio"] {
|
|
|
1343
1345
|
width: 0.375rem;
|
|
1344
1346
|
height: 0.375rem;
|
|
1345
1347
|
border-radius: 100%;
|
|
1346
|
-
background-color: var(--figma-color-
|
|
1348
|
+
background-color: var(--figma-color-icon-onbrand);
|
|
1347
1349
|
transform: scale(0);
|
|
1348
1350
|
box-shadow: 0px 0 0 0.75px rgba(0, 0, 0, 0.1),
|
|
1349
1351
|
0px 1px 3px 0px rgba(0, 0, 0, 0.1), 0px 3px 8px 0px rgba(0, 0, 0, 0.1),
|
|
@@ -1533,7 +1535,7 @@ fig-slider {
|
|
|
1533
1535
|
position: absolute;
|
|
1534
1536
|
left: calc(var(--start-percent) - var(--slider-tick-size) / 2);
|
|
1535
1537
|
top: calc(50% - var(--slider-tick-size) / 2);
|
|
1536
|
-
background: var(--figma-color-icon-
|
|
1538
|
+
background: var(--figma-color-icon-onbrand);
|
|
1537
1539
|
}
|
|
1538
1540
|
}
|
|
1539
1541
|
}
|
|
@@ -1741,11 +1743,12 @@ fig-slider {
|
|
|
1741
1743
|
display: block;
|
|
1742
1744
|
width: 100%;
|
|
1743
1745
|
box-shadow: none;
|
|
1746
|
+
background: var(--figma-color-bg-tertiary);
|
|
1744
1747
|
|
|
1745
1748
|
/* Track */
|
|
1746
1749
|
&::before {
|
|
1747
1750
|
box-shadow: none;
|
|
1748
|
-
background: var(--figma-color-text-
|
|
1751
|
+
background: var(--figma-color-text-tertiary);
|
|
1749
1752
|
}
|
|
1750
1753
|
|
|
1751
1754
|
input[type="range"] {
|
|
@@ -1764,6 +1767,7 @@ fig-slider {
|
|
|
1764
1767
|
--slider-thumb-size: 1rem;
|
|
1765
1768
|
--slider-tick-size: calc(var(--slider-height) / 4);
|
|
1766
1769
|
.fig-slider-input-container {
|
|
1770
|
+
background: var(--figma-color-bg-secondary);
|
|
1767
1771
|
&::before {
|
|
1768
1772
|
box-shadow: inset 0 0 0 1px var(--figma-color-bordertranslucent);
|
|
1769
1773
|
background: var(--figma-color-bg-brand);
|
|
@@ -2258,7 +2262,7 @@ fig-segmented-control {
|
|
|
2258
2262
|
&[selected="true"] {
|
|
2259
2263
|
background-color: var(--figma-color-bg);
|
|
2260
2264
|
border-radius: calc(var(--radius-medium) - 1px);
|
|
2261
|
-
box-shadow: var(--
|
|
2265
|
+
box-shadow: 0 0 0 1px var(--figma-color-border);
|
|
2262
2266
|
}
|
|
2263
2267
|
}
|
|
2264
2268
|
}
|
|
@@ -2267,6 +2271,7 @@ fig-input-joystick {
|
|
|
2267
2271
|
--size: 1.5rem;
|
|
2268
2272
|
display: inline-flex;
|
|
2269
2273
|
gap: var(--spacer-2);
|
|
2274
|
+
user-select: none;
|
|
2270
2275
|
.fig-input-joystick-plane-container {
|
|
2271
2276
|
display: flex;
|
|
2272
2277
|
width: 1.5rem;
|
|
@@ -2276,6 +2281,9 @@ fig-input-joystick {
|
|
|
2276
2281
|
flex-grow: 0;
|
|
2277
2282
|
align-items: center;
|
|
2278
2283
|
justify-content: center;
|
|
2284
|
+
&:focus {
|
|
2285
|
+
outline: 0;
|
|
2286
|
+
}
|
|
2279
2287
|
}
|
|
2280
2288
|
.fig-input-joystick-plane {
|
|
2281
2289
|
display: inline-grid;
|
|
@@ -2297,7 +2305,7 @@ fig-input-joystick {
|
|
|
2297
2305
|
position: absolute;
|
|
2298
2306
|
width: var(--size);
|
|
2299
2307
|
height: var(--size);
|
|
2300
|
-
|
|
2308
|
+
box-shadow: inset 0 0 0 1px var(--figma-color-border);
|
|
2301
2309
|
border-radius: var(--radius-medium);
|
|
2302
2310
|
overflow: hidden;
|
|
2303
2311
|
background: var(--figma-color-bg-secondary);
|
|
@@ -2307,8 +2315,8 @@ fig-input-joystick {
|
|
|
2307
2315
|
position: absolute;
|
|
2308
2316
|
height: 0;
|
|
2309
2317
|
border-left: 1px solid var(--figma-color-border);
|
|
2310
|
-
height: 100
|
|
2311
|
-
top:
|
|
2318
|
+
height: calc(100% - 2px);
|
|
2319
|
+
top: 1px;
|
|
2312
2320
|
left: calc(50% - 0.5px);
|
|
2313
2321
|
pointer-events: none;
|
|
2314
2322
|
}
|
|
@@ -2317,9 +2325,9 @@ fig-input-joystick {
|
|
|
2317
2325
|
position: absolute;
|
|
2318
2326
|
height: 0;
|
|
2319
2327
|
border-top: 1px solid var(--figma-color-border);
|
|
2320
|
-
width: 100
|
|
2328
|
+
width: calc(100% - 2px);
|
|
2321
2329
|
top: calc(50% - 0.5px);
|
|
2322
|
-
left:
|
|
2330
|
+
left: 1px;
|
|
2323
2331
|
pointer-events: none;
|
|
2324
2332
|
}
|
|
2325
2333
|
}
|
|
@@ -2339,7 +2347,12 @@ fig-input-joystick {
|
|
|
2339
2347
|
transparent calc(50% + 0.5px)
|
|
2340
2348
|
),
|
|
2341
2349
|
var(--figma-color-bg-secondary);
|
|
2350
|
+
box-shadow: inset 0 0 0 1px var(--figma-color-border-selected);
|
|
2342
2351
|
}
|
|
2352
|
+
.fig-input-joystick-plane-container:focus .fig-input-joystick-guides {
|
|
2353
|
+
box-shadow: inset 0 0 0 1px var(--figma-color-border-selected);
|
|
2354
|
+
}
|
|
2355
|
+
|
|
2343
2356
|
.fig-input-joystick-handle {
|
|
2344
2357
|
position: absolute;
|
|
2345
2358
|
z-index: 1;
|
|
@@ -2356,6 +2369,7 @@ fig-input-angle {
|
|
|
2356
2369
|
--size: 1.5rem;
|
|
2357
2370
|
display: inline-flex;
|
|
2358
2371
|
gap: var(--spacer-2);
|
|
2372
|
+
user-select: none;
|
|
2359
2373
|
|
|
2360
2374
|
.fig-input-angle-plane {
|
|
2361
2375
|
display: inline-grid;
|
|
@@ -2367,10 +2381,10 @@ fig-input-angle {
|
|
|
2367
2381
|
background-color: var(--figma-color-bg-secondary);
|
|
2368
2382
|
border-radius: 100%;
|
|
2369
2383
|
box-shadow: inset 0 0 0 1px var(--figma-color-border);
|
|
2384
|
+
&:focus,
|
|
2370
2385
|
&.dragging {
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
z-index: 2;
|
|
2386
|
+
outline: 0;
|
|
2387
|
+
box-shadow: inset 0 0 0 1px var(--figma-color-border-selected);
|
|
2374
2388
|
}
|
|
2375
2389
|
}
|
|
2376
2390
|
.fig-input-angle-handle {
|
package/fig.js
CHANGED
|
@@ -1767,7 +1767,7 @@ class FigInputJoystick extends HTMLElement {
|
|
|
1767
1767
|
}
|
|
1768
1768
|
#getInnerHTML() {
|
|
1769
1769
|
return `
|
|
1770
|
-
<div class="fig-input-joystick-plane-container">
|
|
1770
|
+
<div class="fig-input-joystick-plane-container" tabindex="0">
|
|
1771
1771
|
<div class="fig-input-joystick-plane">
|
|
1772
1772
|
<div class="fig-input-joystick-guides"></div>
|
|
1773
1773
|
<div class="fig-input-joystick-handle"></div>
|
|
@@ -1801,6 +1801,8 @@ class FigInputJoystick extends HTMLElement {
|
|
|
1801
1801
|
#setupListeners() {
|
|
1802
1802
|
this.plane = this.querySelector(".fig-input-joystick-plane");
|
|
1803
1803
|
this.cursor = this.querySelector(".fig-input-joystick-handle");
|
|
1804
|
+
this.xInput = this.querySelector("fig-input-text[name='x']");
|
|
1805
|
+
this.yInput = this.querySelector("fig-input-text[name='y']");
|
|
1804
1806
|
this.plane.addEventListener("mousedown", this.#handleMouseDown.bind(this));
|
|
1805
1807
|
this.plane.addEventListener(
|
|
1806
1808
|
"touchstart",
|
|
@@ -1938,6 +1940,7 @@ class FigInputJoystick extends HTMLElement {
|
|
|
1938
1940
|
|
|
1939
1941
|
const handleTouchEnd = () => {
|
|
1940
1942
|
this.isDragging = false;
|
|
1943
|
+
this.plane.classList.remove("dragging");
|
|
1941
1944
|
window.removeEventListener("touchmove", handleTouchMove);
|
|
1942
1945
|
window.removeEventListener("touchend", handleTouchEnd);
|
|
1943
1946
|
this.#emitChangeEvent();
|
|
@@ -1989,12 +1992,20 @@ customElements.define("fig-input-joystick", FigInputJoystick);
|
|
|
1989
1992
|
* @attr {number} value - The current angle of the handle in degrees.
|
|
1990
1993
|
* @attr {number} precision - The number of decimal places for the output.
|
|
1991
1994
|
* @attr {boolean} text - Whether to display a text input for the angle value.
|
|
1995
|
+
* @attr {number} adjacent - The adjacent value of the angle.
|
|
1996
|
+
* @attr {number} opposite - The opposite value of the angle.
|
|
1992
1997
|
*/
|
|
1993
1998
|
class FigInputAngle extends HTMLElement {
|
|
1999
|
+
// Declare private fields first
|
|
2000
|
+
#adjacent;
|
|
2001
|
+
#opposite;
|
|
2002
|
+
|
|
1994
2003
|
constructor() {
|
|
1995
2004
|
super();
|
|
1996
2005
|
|
|
1997
2006
|
this.angle = 0; // Angle in degrees
|
|
2007
|
+
this.#adjacent = 1;
|
|
2008
|
+
this.#opposite = 0;
|
|
1998
2009
|
this.isDragging = false;
|
|
1999
2010
|
this.isShiftHeld = false;
|
|
2000
2011
|
this.handle = null;
|
|
@@ -2031,7 +2042,7 @@ class FigInputAngle extends HTMLElement {
|
|
|
2031
2042
|
|
|
2032
2043
|
#getInnerHTML() {
|
|
2033
2044
|
return `
|
|
2034
|
-
<div class="fig-input-angle-plane">
|
|
2045
|
+
<div class="fig-input-angle-plane" tabindex="0">
|
|
2035
2046
|
<div class="fig-input-angle-handle"></div>
|
|
2036
2047
|
</div>
|
|
2037
2048
|
${
|
|
@@ -2083,11 +2094,18 @@ class FigInputAngle extends HTMLElement {
|
|
|
2083
2094
|
#handleAngleInput(e) {
|
|
2084
2095
|
e.stopPropagation();
|
|
2085
2096
|
this.angle = Number(e.target.value);
|
|
2097
|
+
this.#calculateAdjacentAndOpposite();
|
|
2086
2098
|
this.#syncHandlePosition();
|
|
2087
2099
|
this.#emitInputEvent();
|
|
2088
2100
|
this.#emitChangeEvent();
|
|
2089
2101
|
}
|
|
2090
2102
|
|
|
2103
|
+
#calculateAdjacentAndOpposite() {
|
|
2104
|
+
const radians = (this.angle * Math.PI) / 180;
|
|
2105
|
+
this.#adjacent = Math.cos(radians);
|
|
2106
|
+
this.#opposite = Math.sin(radians);
|
|
2107
|
+
}
|
|
2108
|
+
|
|
2091
2109
|
#snapToIncrement(angle) {
|
|
2092
2110
|
if (!this.isShiftHeld) return angle;
|
|
2093
2111
|
const increment = 45;
|
|
@@ -2105,6 +2123,8 @@ class FigInputAngle extends HTMLElement {
|
|
|
2105
2123
|
angle = this.#snapToIncrement(angle);
|
|
2106
2124
|
this.angle = angle;
|
|
2107
2125
|
|
|
2126
|
+
this.#calculateAdjacentAndOpposite();
|
|
2127
|
+
|
|
2108
2128
|
this.#syncHandlePosition();
|
|
2109
2129
|
if (this.text && this.angleInput) {
|
|
2110
2130
|
this.angleInput.setAttribute("value", this.angle.toFixed(this.precision));
|
|
@@ -2146,11 +2166,13 @@ class FigInputAngle extends HTMLElement {
|
|
|
2146
2166
|
this.#updateAngle(e);
|
|
2147
2167
|
|
|
2148
2168
|
const handleMouseMove = (e) => {
|
|
2169
|
+
this.plane.classList.add("dragging");
|
|
2149
2170
|
if (this.isDragging) this.#updateAngle(e);
|
|
2150
2171
|
};
|
|
2151
2172
|
|
|
2152
2173
|
const handleMouseUp = () => {
|
|
2153
2174
|
this.isDragging = false;
|
|
2175
|
+
this.plane.classList.remove("dragging");
|
|
2154
2176
|
window.removeEventListener("mousemove", handleMouseMove);
|
|
2155
2177
|
window.removeEventListener("mouseup", handleMouseUp);
|
|
2156
2178
|
this.#emitChangeEvent();
|
|
@@ -2166,11 +2188,13 @@ class FigInputAngle extends HTMLElement {
|
|
|
2166
2188
|
this.#updateAngle(e.touches[0]);
|
|
2167
2189
|
|
|
2168
2190
|
const handleTouchMove = (e) => {
|
|
2191
|
+
this.plane.classList.add("dragging");
|
|
2169
2192
|
if (this.isDragging) this.#updateAngle(e.touches[0]);
|
|
2170
2193
|
};
|
|
2171
2194
|
|
|
2172
2195
|
const handleTouchEnd = () => {
|
|
2173
2196
|
this.isDragging = false;
|
|
2197
|
+
this.plane.classList.remove("dragging");
|
|
2174
2198
|
window.removeEventListener("touchmove", handleTouchMove);
|
|
2175
2199
|
window.removeEventListener("touchend", handleTouchEnd);
|
|
2176
2200
|
this.#emitChangeEvent();
|
|
@@ -2196,12 +2220,21 @@ class FigInputAngle extends HTMLElement {
|
|
|
2196
2220
|
return this.angle;
|
|
2197
2221
|
}
|
|
2198
2222
|
|
|
2223
|
+
get adjacent() {
|
|
2224
|
+
return this.#adjacent;
|
|
2225
|
+
}
|
|
2226
|
+
|
|
2227
|
+
get opposite() {
|
|
2228
|
+
return this.#opposite;
|
|
2229
|
+
}
|
|
2230
|
+
|
|
2199
2231
|
set value(value) {
|
|
2200
2232
|
if (isNaN(value)) {
|
|
2201
2233
|
console.error("Invalid value: must be a number.");
|
|
2202
2234
|
return;
|
|
2203
2235
|
}
|
|
2204
2236
|
this.angle = value;
|
|
2237
|
+
this.#calculateAdjacentAndOpposite();
|
|
2205
2238
|
this.#syncHandlePosition();
|
|
2206
2239
|
}
|
|
2207
2240
|
|