@rogieking/figui3 2.0.2 → 2.0.4

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.
Files changed (4) hide show
  1. package/components.css +115 -18
  2. package/example.html +334 -241
  3. package/fig.js +156 -46
  4. package/package.json +1 -1
package/components.css CHANGED
@@ -290,8 +290,8 @@
290
290
  rgba(255, 0, 48, 1)
291
291
  );
292
292
 
293
- /* Icons - light theme defaults */
294
- --icon-chevron: 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='M5.87868 7.12132L8 9.24264L10.1213 7.12132' stroke='rgb(0 0 0 / 90%)' stroke-linecap='round'/%3E%3C/svg%3E%0A");
293
+ /* Icons - colorless shapes for use with mask-image */
294
+ --icon-chevron: 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='M5.87868 7.12132L8 9.24264L10.1213 7.12132' stroke='black' stroke-linecap='round'/%3E%3C/svg%3E%0A");
295
295
  --icon-checkmark: 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 fill-rule='evenodd' clip-rule='evenodd' d='M11.7773 4.08403C12.0071 4.2372 12.0692 4.54764 11.916 4.7774L7.91603 10.7774C7.83293 10.902 7.69834 10.9829 7.54927 10.9976C7.4002 11.0124 7.25237 10.9595 7.14645 10.8536L4.14645 7.85361C3.95118 7.65834 3.95118 7.34176 4.14645 7.1465C4.34171 6.95124 4.65829 6.95124 4.85355 7.1465L7.42229 9.71523L11.084 4.2227C11.2372 3.99294 11.5476 3.93085 11.7773 4.08403Z' fill='white'/%3E%3C/svg%3E%0A");
296
296
  --icon-steppers: url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11.7245 6.08191C11.9186 5.95386 12.1826 5.97562 12.3534 6.14637L14.3534 8.14637L14.4179 8.22449C14.546 8.41852 14.5242 8.68253 14.3534 8.8534C14.1826 9.02426 13.9186 9.04601 13.7245 8.91785L13.6464 8.8534L11.9999 7.20691L10.3534 8.8534C10.1582 9.04866 9.84166 9.04866 9.6464 8.8534C9.45123 8.65813 9.45117 8.3416 9.6464 8.14637L11.6464 6.14637L11.7245 6.08191Z' fill='black'/%3E%3Cpath d='M13.7248 15.0822C13.9189 14.9541 14.1829 14.9758 14.3537 15.1467C14.5246 15.3176 14.5463 15.5815 14.4182 15.7756L14.3537 15.8537L12.3537 17.8537C12.1829 18.0246 11.9189 18.0463 11.7248 17.9182L11.6467 17.8537L9.64669 15.8537L9.58224 15.7756C9.45407 15.5815 9.47583 15.3176 9.64669 15.1467C9.81756 14.9758 10.0815 14.9541 10.2756 15.0822L10.3537 15.1467L12.0002 16.7932L13.6467 15.1467L13.7248 15.0822Z' fill='black' /%3E%3C/svg%3E%0A");
297
297
 
@@ -309,11 +309,10 @@
309
309
  --handle-shadow: 0px 0 0 0.5px rgba(0, 0, 0, 0.1), var(--figma-elevation-200);
310
310
  }
311
311
 
312
- /* Dark theme overrides for non-color values (icons, shadows, elevations) */
313
- /* These cannot use light-dark() as they are not color values */
312
+ /* Dark theme overrides for non-color values (shadows, elevations) */
313
+ /* These cannot use light-dark() as they are complex values */
314
314
  @media (prefers-color-scheme: dark) {
315
315
  :root {
316
- --icon-chevron: 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='M5.87868 7.12132L8 9.24264L10.1213 7.12132' stroke='rgb(255 255 255 / 100%)' stroke-linecap='round'/%3E%3C/svg%3E%0A");
317
316
  --handle-shadow: 0px 0 0 0.75px 0px 0 0 0.75px rgba(0, 0, 0, 0.1),
318
317
  0px 0px 0.5px 0px rgba(255, 255, 255, 0.1);
319
318
  --figma-elevation-100: 0px 0px 0.5px 0px rgba(0, 0, 0, 0.5),
@@ -332,7 +331,6 @@
332
331
 
333
332
  /* Class-based dark theme override (for manual theme switching) */
334
333
  :root.figma-dark {
335
- --icon-chevron: 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='M5.87868 7.12132L8 9.24264L10.1213 7.12132' stroke='rgb(255 255 255 / 100%)' stroke-linecap='round'/%3E%3C/svg%3E%0A");
336
334
  --handle-shadow: 0px 0 0 0.75px 0px 0 0 0.75px rgba(0, 0, 0, 0.1),
337
335
  0px 0px 0.5px 0px rgba(255, 255, 255, 0.1);
338
336
  --figma-elevation-100: 0px 0px 0.5px 0px rgba(0, 0, 0, 0.5),
@@ -613,15 +611,6 @@ input[type="text"][list] {
613
611
  }
614
612
  }
615
613
 
616
- input[type="text"][list]:hover,
617
- input[type="text"][list]:active,
618
- input[type="text"][list]:focus,
619
- select {
620
- background-image: var(--icon-chevron);
621
- background-position: calc(100% - 0.25rem) center;
622
- background-repeat: no-repeat;
623
- }
624
-
625
614
  input[type="text"][list],
626
615
  select {
627
616
  padding-right: 1.5rem;
@@ -640,6 +629,23 @@ fig-dropdown,
640
629
  display: block;
641
630
  width: 100%;
642
631
  }
632
+
633
+ /* Chevron icon using mask-image for light-dark support */
634
+ &::after {
635
+ content: "";
636
+ position: absolute;
637
+ right: 0.25rem;
638
+ top: 50%;
639
+ transform: translateY(-50%);
640
+ width: 1rem;
641
+ height: 1rem;
642
+ mask-image: var(--icon-chevron);
643
+ mask-size: contain;
644
+ mask-repeat: no-repeat;
645
+ mask-position: center;
646
+ background-color: var(--figma-color-icon);
647
+ pointer-events: none;
648
+ }
643
649
  }
644
650
 
645
651
  /* Button */
@@ -1546,7 +1552,7 @@ fig-slider {
1546
1552
  --slider-tick-size: calc(var(--slider-height) / 4);
1547
1553
  --slider-handle-shadow: inset 0 0 0 calc(4px + 0.5rem * var(--unchanged))
1548
1554
  var(--handle-color),
1549
- var(--handle-shadow);
1555
+ 0px 0 0 0.5px rgba(0, 0, 0, 0.1), var(--figma-elevation-200);
1550
1556
  --slider-handle-shadow-focus: inset 0 0 0 4px var(--handle-color),
1551
1557
  inset 0 0 0 5px rgba(0, 0, 0, 0.1), var(--handle-shadow),
1552
1558
  0 0 0 1px var(--figma-color-border-selected);
@@ -2241,11 +2247,23 @@ fig-input-number {
2241
2247
  justify-content: center;
2242
2248
  user-select: all;
2243
2249
  gap: 0;
2250
+ min-width: 0;
2251
+ width: 8rem; /* Default width */
2252
+ flex-shrink: 1;
2253
+ flex-grow: 0;
2244
2254
  color: var(--figma-color-text);
2245
2255
 
2256
+ /* When inside a flex container (like fig-field), grow to fill */
2257
+ fig-field &,
2258
+ [style*="flex"] &,
2259
+ [style*="display: flex"] & {
2260
+ width: auto;
2261
+ flex: 1 1 auto;
2262
+ }
2263
+
2246
2264
  &[multiline] {
2247
- display: block;
2248
2265
  display: flex;
2266
+ width: 100%; /* Multiline defaults to full width */
2249
2267
  }
2250
2268
  &[autoresize] input,
2251
2269
  &[autoresize] textarea {
@@ -2353,7 +2371,7 @@ fig-slider {
2353
2371
 
2354
2372
  & fig-input-text[type="number"],
2355
2373
  & fig-input-number {
2356
- width: 3rem;
2374
+ width: 5rem;
2357
2375
  }
2358
2376
  }
2359
2377
 
@@ -2442,6 +2460,17 @@ fig-input-joystick {
2442
2460
  display: inline-flex;
2443
2461
  gap: var(--spacer-2);
2444
2462
  user-select: none;
2463
+
2464
+ /* When inside horizontal fig-field, grow to fill and let inputs expand */
2465
+ fig-field[direction="horizontal"] & {
2466
+ flex: 1;
2467
+ min-width: 0;
2468
+
2469
+ fig-input-number {
2470
+ flex: 1;
2471
+ width: auto;
2472
+ }
2473
+ }
2445
2474
  .fig-input-joystick-plane-container {
2446
2475
  display: flex;
2447
2476
  width: 1.5rem;
@@ -2451,6 +2480,7 @@ fig-input-joystick {
2451
2480
  flex-grow: 0;
2452
2481
  align-items: center;
2453
2482
  justify-content: center;
2483
+ position: relative;
2454
2484
  &:focus {
2455
2485
  outline: 0;
2456
2486
  }
@@ -2466,6 +2496,10 @@ fig-input-joystick {
2466
2496
  cursor: grab;
2467
2497
  --size: 3rem;
2468
2498
  z-index: 2;
2499
+ position: absolute;
2500
+ top: 50%;
2501
+ left: 50%;
2502
+ transform: translate(-50%, -50%);
2469
2503
  }
2470
2504
  }
2471
2505
  .fig-input-joystick-plane > * {
@@ -2541,6 +2575,17 @@ fig-input-angle {
2541
2575
  gap: var(--spacer-2);
2542
2576
  user-select: none;
2543
2577
 
2578
+ /* When inside horizontal fig-field, grow to fill and let inputs expand */
2579
+ fig-field[direction="horizontal"] & {
2580
+ flex: 1;
2581
+ min-width: 0;
2582
+
2583
+ fig-input-number {
2584
+ flex: 1;
2585
+ width: auto;
2586
+ }
2587
+ }
2588
+
2544
2589
  .fig-input-angle-plane {
2545
2590
  display: inline-grid;
2546
2591
  place-items: center;
@@ -2575,6 +2620,49 @@ fig-input-angle {
2575
2620
  }
2576
2621
  }
2577
2622
 
2623
+ /* Shimmer */
2624
+ fig-shimmer {
2625
+ display: contents;
2626
+ --shimmer-angle: 90deg;
2627
+ --shimmer-size: 250% 100%;
2628
+ --shimmer-duration: 1.5s;
2629
+
2630
+ &[direction="vertical"] {
2631
+ --shimmer-angle: 180deg;
2632
+ --shimmer-size: 100% 250%;
2633
+ }
2634
+ &[direction="diagonal"] {
2635
+ --shimmer-angle: 135deg;
2636
+ --shimmer-size: 250% 250%;
2637
+ }
2638
+
2639
+ /* When not playing, remove shimmer effect entirely */
2640
+ &[playing="false"] > * {
2641
+ background: none;
2642
+ -webkit-background-clip: unset;
2643
+ background-clip: unset;
2644
+ -webkit-text-fill-color: unset;
2645
+ animation: none;
2646
+ }
2647
+ }
2648
+
2649
+ /* Only apply shimmer when playing (default) or playing="true" */
2650
+ fig-shimmer:not([playing="false"]) > * {
2651
+ background: linear-gradient(
2652
+ var(--shimmer-angle),
2653
+ var(--figma-color-text-tertiary) 0%,
2654
+ var(--figma-color-text-tertiary) 40%,
2655
+ var(--figma-color-text) 50%,
2656
+ var(--figma-color-text-tertiary) 60%,
2657
+ var(--figma-color-text-tertiary) 100%
2658
+ );
2659
+ background-size: var(--shimmer-size);
2660
+ -webkit-background-clip: text;
2661
+ background-clip: text;
2662
+ -webkit-text-fill-color: transparent;
2663
+ animation: fig-shimmer var(--shimmer-duration) linear infinite;
2664
+ }
2665
+
2578
2666
  /* Utilities */
2579
2667
 
2580
2668
  @keyframes fig-spinner-spin {
@@ -2586,3 +2674,12 @@ fig-input-angle {
2586
2674
  transform: rotate(360deg);
2587
2675
  }
2588
2676
  }
2677
+
2678
+ @keyframes fig-shimmer {
2679
+ 0% {
2680
+ background-position: 100% 100%;
2681
+ }
2682
+ 100% {
2683
+ background-position: 0% 0%;
2684
+ }
2685
+ }