@rogieking/figui3 3.8.2 → 3.9.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/README.md CHANGED
@@ -302,11 +302,14 @@ A segmented button group for exclusive selection.
302
302
  |-----------|------|---------|-------------|
303
303
  | `name` | string | — | Control group identifier |
304
304
  | `value` | string | — | Selected segment value (trimmed, case-sensitive match) |
305
+ | `animated` | boolean | `false` | Enables animated segment indicator (`animated` or `animated="true"`); omit or set `animated="false"` to disable |
306
+ | `sizing` | `"equal"` \| `"auto"` | `"equal"` | Segment width mode (`equal` = evenly distributed, `auto` = content width) |
305
307
 
306
308
  Selection behavior:
307
309
  - If `fig-segmented-control[value]` is set, it takes precedence and selects the first matching segment.
308
310
  - Segment match value resolves from `fig-segment[value]` when present and non-empty; otherwise it falls back to `fig-segment` text content (`textContent.trim()`).
309
311
  - If no segment matches the control `value`, current selection is preserved.
312
+ - Animated indicator does not run on initial paint; it only animates subsequent selection changes when `animated` is enabled.
310
313
 
311
314
  Events:
312
315
  - Emits bubbling `input` and `change` events when user interaction changes selection.
package/components.css CHANGED
@@ -3450,16 +3450,44 @@ fig-segmented-control {
3450
3450
  gap: 0;
3451
3451
  display: inline-flex;
3452
3452
  align-items: stretch;
3453
+ position: relative;
3454
+ overflow: hidden;
3455
+ --seg-indicator-x: 0px;
3456
+ --seg-indicator-w: 0px;
3457
+ --seg-indicator-opacity: 0;
3458
+ --seg-indicator-transition-duration: 0ms;
3459
+
3460
+ &::before {
3461
+ content: "";
3462
+ position: absolute;
3463
+ top: 1px;
3464
+ left: 0;
3465
+ width: var(--seg-indicator-w);
3466
+ height: calc(100% - 2px);
3467
+ transform: translateX(var(--seg-indicator-x));
3468
+ border-radius: calc(var(--radius-medium) - 1px);
3469
+ background-color: var(--figma-color-bg);
3470
+ box-shadow: 0 0 0 1px var(--figma-color-border);
3471
+ opacity: var(--seg-indicator-opacity);
3472
+ pointer-events: none;
3473
+ z-index: 0;
3474
+ transition:
3475
+ transform var(--seg-indicator-transition-duration) ease,
3476
+ width var(--seg-indicator-transition-duration) ease,
3477
+ opacity 0.12s ease;
3478
+ }
3453
3479
 
3454
3480
  & fig-segment {
3455
- flex: 1;
3481
+ flex: 1 1 0;
3456
3482
  display: flex;
3457
3483
  align-items: center;
3458
3484
  justify-content: center;
3459
3485
  position: relative;
3486
+ z-index: 1;
3460
3487
  appearance: none;
3461
3488
  color: var(--figma-color-text-secondary);
3462
3489
  padding: 0 var(--spacer-2);
3490
+ transition: none;
3463
3491
 
3464
3492
  &[selected]:not([selected="false"]),
3465
3493
  &[selected="true"] {
@@ -3479,6 +3507,42 @@ fig-segmented-control {
3479
3507
  }
3480
3508
  }
3481
3509
 
3510
+ &:not([sizing]),
3511
+ &[sizing=""],
3512
+ &[sizing="equal"] {
3513
+ & fig-segment {
3514
+ flex: 1 1 0;
3515
+ }
3516
+ }
3517
+
3518
+ &[sizing="auto"] {
3519
+ display: inline-flex;
3520
+ width: fit-content;
3521
+ max-width: 100%;
3522
+ flex: 0 0 auto;
3523
+
3524
+ &[full]:not([full="false"]) {
3525
+ display: inline-flex;
3526
+ width: fit-content;
3527
+ flex: 0 0 auto;
3528
+ align-self: auto;
3529
+ }
3530
+
3531
+ & fig-segment {
3532
+ flex: 0 0 auto;
3533
+ }
3534
+ }
3535
+
3536
+ &[animated]:not([animated="false"]) {
3537
+ & fig-segment {
3538
+ &[selected]:not([selected="false"]),
3539
+ &[selected="true"] {
3540
+ background-color: transparent;
3541
+ box-shadow: none;
3542
+ }
3543
+ }
3544
+ }
3545
+
3482
3546
  &[size="large"] {
3483
3547
  height: var(--spacer-5);
3484
3548
 
@@ -3489,6 +3553,7 @@ fig-segmented-control {
3489
3553
 
3490
3554
  &[disabled]:not([disabled="false"]) {
3491
3555
  pointer-events: none;
3556
+ --seg-indicator-opacity: 0;
3492
3557
 
3493
3558
  fig-segment {
3494
3559
  color: var(--figma-color-text-disabled);
@@ -3498,6 +3563,13 @@ fig-segmented-control {
3498
3563
  }
3499
3564
  }
3500
3565
 
3566
+ @media (prefers-reduced-motion: reduce) {
3567
+ .segmented-control::before,
3568
+ fig-segmented-control::before {
3569
+ transition: none !important;
3570
+ }
3571
+ }
3572
+
3501
3573
  fig-joystick {
3502
3574
  --size: 100%;
3503
3575
  --aspect-ratio: 1 / 1;