@rogieking/figui3 3.6.0 → 3.7.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.
Files changed (3) hide show
  1. package/components.css +25 -5
  2. package/fig.js +40 -1
  3. package/package.json +1 -1
package/components.css CHANGED
@@ -1777,6 +1777,7 @@ fig-origin-grid {
1777
1777
  --origin-overflow-nudge-base: var(--spacer-2-5);
1778
1778
  --origin-overflow-nudge-x: 0px;
1779
1779
  --origin-overflow-nudge-y: 0px;
1780
+ --origin-grid-handle-radius: var(--radius-small);
1780
1781
  --origin-overflow-nudge-x-scale: calc((100cqb / 100cqi) * -1);
1781
1782
  --origin-overflow-nudge-y-scale: calc((100cqb / 100cqi) * -1);
1782
1783
  position: absolute;
@@ -1784,10 +1785,11 @@ fig-origin-grid {
1784
1785
  top: 50%;
1785
1786
  width: var(--origin-grid-handle-size);
1786
1787
  height: var(--origin-grid-handle-size);
1787
- border-radius: var(--radius-small);
1788
+ border-radius: var(--origin-grid-handle-radius);
1788
1789
  background: var(--figma-color-bg-brand);
1789
1790
  box-shadow:
1790
- 0 0 0 1px var(--figma-color-bg),
1791
+ inset 0 0 0 0.09375rem var(--handle-color),
1792
+ 0px 0 0 0.5px rgba(0, 0, 0, 0.1),
1791
1793
  var(--elevation-100-canvas);
1792
1794
  transform: translate(
1793
1795
  calc(-50% + var(--origin-overflow-nudge-x)),
@@ -1808,6 +1810,7 @@ fig-origin-grid {
1808
1810
  -webkit-mask-size: 24px 24px;
1809
1811
  mask-size: 24px 24px;
1810
1812
  border-radius: 0;
1813
+ box-shadow: none;
1811
1814
  }
1812
1815
 
1813
1816
  &.beyond-bounds-x.overflow-right {
@@ -2199,6 +2202,8 @@ fig-slider {
2199
2202
  --slider-thumb-color: var(--handle-color);
2200
2203
  --slider-thumb-radius: calc(var(--slider-thumb-width) / 2);
2201
2204
  --slider-thumb-opacity: 1;
2205
+ --slider-thumb-outline: none;
2206
+ --slider-thumb-outline-offset: 2px;
2202
2207
  --slider-tick-opacity: 1;
2203
2208
  --slider-tick-radius: 100%;
2204
2209
  --slider-border-radius: calc(var(--slider-height) / 2);
@@ -2334,6 +2339,9 @@ fig-slider {
2334
2339
  margin-top: calc(
2335
2340
  var(--slider-height) / 2 - var(--slider-thumb-height) / 2
2336
2341
  );
2342
+ outline: var(--slider-thumb-outline);
2343
+ outline-offset: var(--slider-thumb-outline-offset);
2344
+
2337
2345
  aspect-ratio: 1;
2338
2346
  border: none;
2339
2347
  position: relative;
@@ -2409,6 +2417,8 @@ fig-slider {
2409
2417
  border-radius: var(--slider-thumb-radius);
2410
2418
  height: var(--slider-thumb-height);
2411
2419
  width: var(--slider-thumb-width);
2420
+ outline: var(--slider-thumb-outline);
2421
+ outline-offset: var(--slider-thumb-outline-offset);
2412
2422
  aspect-ratio: 1;
2413
2423
  border: none;
2414
2424
  position: relative;
@@ -3326,10 +3336,18 @@ fig-field-slider {
3326
3336
  --slider-tick-height: var(--spacer-2);
3327
3337
  --slider-tick-radius: var(--radius-medium);
3328
3338
  --slider-stepper-padding: 0;
3339
+ --slider-handle-shadow: inset 0 0 0 var(--slider-thumb-height)
3340
+ var(--slider-thumb-color) !important;
3329
3341
  --slider-thumb-opacity: calc(
3330
3342
  min(var(--slider-complete), calc(1 - var(--slider-complete))) * 2
3331
3343
  );
3332
3344
  --slider-tick-opacity: 1;
3345
+
3346
+ &:has(input[type="range"]:focus-within) {
3347
+ --slider-thumb-outline: 1.5px solid var(--figma-color-border-selected) !important;
3348
+ --slider-thumb-outline-offset: 2px !important;
3349
+ }
3350
+
3333
3351
  .fig-slider-input-container {
3334
3352
  box-shadow: none !important;
3335
3353
  &:hover,
@@ -3401,6 +3419,7 @@ fig-field-slider {
3401
3419
  min-width: fit-content;
3402
3420
  max-width: max-content;
3403
3421
  flex: 0 0 auto;
3422
+ border-radius: var(--radius-small);
3404
3423
 
3405
3424
  &:hover,
3406
3425
  &:has(input:focus) {
@@ -3411,6 +3430,7 @@ fig-field-slider {
3411
3430
  }
3412
3431
  input {
3413
3432
  field-sizing: content;
3433
+ border-radius: var(--radius-small);
3414
3434
  width: auto;
3415
3435
  flex: 0 0 auto;
3416
3436
  text-align: right;
@@ -3650,11 +3670,11 @@ fig-joystick {
3650
3670
  .fig-input-joystick-handle {
3651
3671
  position: absolute;
3652
3672
  z-index: 2;
3653
- width: 1rem;
3654
- height: 1rem;
3673
+ width: 0.75rem;
3674
+ height: 0.75rem;
3655
3675
  background: var(--figma-color-bg-brand);
3656
3676
  box-shadow:
3657
- inset 0 0 0 0.125rem var(--handle-color),
3677
+ inset 0 0 0 0.09375rem var(--handle-color),
3658
3678
  0px 0 0 0.5px rgba(0, 0, 0, 0.1),
3659
3679
  var(--elevation-100-canvas);
3660
3680
  border-radius: 50%;
package/fig.js CHANGED
@@ -4019,6 +4019,7 @@ class FigFieldSlider extends HTMLElement {
4019
4019
  #slider = null;
4020
4020
  #observer = null;
4021
4021
  #managedSliderAttrs = new Set();
4022
+ #steppersSyncFrame = 0;
4022
4023
  #boundHandleSliderInput = null;
4023
4024
  #boundHandleSliderChange = null;
4024
4025
  #ignoredSliderAttrs = new Set(["variant", "color", "text", "full"]);
@@ -4070,6 +4071,10 @@ class FigFieldSlider extends HTMLElement {
4070
4071
 
4071
4072
  disconnectedCallback() {
4072
4073
  this.#observer?.disconnect();
4074
+ if (this.#steppersSyncFrame) {
4075
+ cancelAnimationFrame(this.#steppersSyncFrame);
4076
+ this.#steppersSyncFrame = 0;
4077
+ }
4073
4078
  this.#unbindSliderEvents();
4074
4079
  }
4075
4080
 
@@ -4180,15 +4185,49 @@ class FigFieldSlider extends HTMLElement {
4180
4185
  }
4181
4186
 
4182
4187
  this.#managedSliderAttrs = nextManaged;
4188
+ this.#queueSteppersSync();
4183
4189
  }
4184
4190
 
4185
4191
  #getForwardedSliderAttrNames() {
4186
- const reserved = new Set(["label", "direction", "oninput", "onchange"]);
4192
+ const reserved = new Set([
4193
+ "label",
4194
+ "direction",
4195
+ "oninput",
4196
+ "onchange",
4197
+ "steppers",
4198
+ ]);
4187
4199
  return this.getAttributeNames().filter(
4188
4200
  (name) => !reserved.has(name) && !this.#ignoredSliderAttrs.has(name),
4189
4201
  );
4190
4202
  }
4191
4203
 
4204
+ #queueSteppersSync() {
4205
+ if (this.#steppersSyncFrame) {
4206
+ cancelAnimationFrame(this.#steppersSyncFrame);
4207
+ }
4208
+ this.#steppersSyncFrame = requestAnimationFrame(() => {
4209
+ this.#steppersSyncFrame = 0;
4210
+ this.#syncSteppersToNumberInput();
4211
+ });
4212
+ }
4213
+
4214
+ #syncSteppersToNumberInput() {
4215
+ if (!this.#slider) return;
4216
+ const numberInput = this.#slider.querySelector("fig-input-number");
4217
+ if (!numberInput) return;
4218
+
4219
+ const hasSteppers =
4220
+ this.hasAttribute("steppers") &&
4221
+ this.getAttribute("steppers") !== "false";
4222
+ if (!hasSteppers) {
4223
+ numberInput.removeAttribute("steppers");
4224
+ return;
4225
+ }
4226
+
4227
+ const steppersValue = this.getAttribute("steppers");
4228
+ numberInput.setAttribute("steppers", steppersValue ?? "");
4229
+ }
4230
+
4192
4231
  #bindSliderEvents() {
4193
4232
  if (!this.#slider) return;
4194
4233
  if (!this.#boundHandleSliderInput) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rogieking/figui3",
3
- "version": "3.6.0",
3
+ "version": "3.7.0",
4
4
  "description": "A lightweight web components library for building Figma plugin and widget UIs with native look and feel",
5
5
  "author": "Rogie King",
6
6
  "license": "MIT",