@rogieking/figui3 1.2.7 → 1.2.8

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 CHANGED
@@ -524,7 +524,7 @@
524
524
  <label>Stepper slider</label>
525
525
  <fig-slider type="stepper"
526
526
  value="25"
527
- default="50"
527
+ default="75"
528
528
  step="25">
529
529
  <datalist>
530
530
  <option value="0"></option>
@@ -538,9 +538,8 @@
538
538
  <fig-field direction="horizontal">
539
539
  <label>Stepper slider (auto)</label>
540
540
  <fig-slider type="stepper"
541
- value="0"
542
- default="5"
543
- min="0"
541
+ value="3"
542
+ min="1"
544
543
  max="10"
545
544
  step="1"
546
545
  text="true">
package/fig.css CHANGED
@@ -1494,18 +1494,6 @@ fig-slider {
1494
1494
  &::before {
1495
1495
  display: none;
1496
1496
  }
1497
- /* Default tick */
1498
- &::after {
1499
- content: "";
1500
- display: block;
1501
- width: var(--slider-tick-size);
1502
- height: var(--slider-tick-size);
1503
- border-radius: 100%;
1504
- background: var(--figma-color-icon);
1505
- position: absolute;
1506
- left: calc(var(--default) * 100% - var(--slider-tick-size) / 2);
1507
- top: calc(50% - var(--slider-tick-size) / 2);
1508
- }
1509
1497
  }
1510
1498
  }
1511
1499
 
@@ -1729,6 +1717,9 @@ fig-slider {
1729
1717
  font-size: 0;
1730
1718
  background: var(--figma-color-icon-tertiary);
1731
1719
  display: block;
1720
+ &[default] {
1721
+ background: var(--figma-color-icon);
1722
+ }
1732
1723
 
1733
1724
  &:first-child:last-child {
1734
1725
  margin: 0 auto;
package/fig.js CHANGED
@@ -673,7 +673,6 @@ class FigSlider extends HTMLElement {
673
673
  }
674
674
  #regenerateInnerHTML() {
675
675
  this.value = Number(this.getAttribute("value") || 0);
676
- this.default = this.getAttribute("default") || null;
677
676
  this.type = this.getAttribute("type") || "range";
678
677
  this.text = this.getAttribute("text") || false;
679
678
  this.units = this.getAttribute("units") || "";
@@ -685,6 +684,7 @@ class FigSlider extends HTMLElement {
685
684
  this.max = Number(this.getAttribute("max") || defaults.max);
686
685
  this.step = Number(this.getAttribute("step") || defaults.step);
687
686
  this.color = this.getAttribute("color") || defaults?.color;
687
+ this.default = this.getAttribute("default") || this.min;
688
688
 
689
689
  if (this.color) {
690
690
  this.style.setProperty("--color", this.color);
@@ -758,6 +758,14 @@ class FigSlider extends HTMLElement {
758
758
  this.inputContainer.append(this.datalist);
759
759
  this.input.setAttribute("list", this.datalist.getAttribute("id"));
760
760
  }
761
+ if (this.datalist) {
762
+ let defaultOption = this.datalist.querySelector(
763
+ `option[value='${this.default}']`
764
+ );
765
+ if (defaultOption) {
766
+ defaultOption.setAttribute("default", "true");
767
+ }
768
+ }
761
769
  if (this.figInputText) {
762
770
  this.figInputText.removeEventListener("input", this.handleTextInput);
763
771
  this.figInputText.addEventListener(
@@ -843,15 +851,14 @@ class FigSlider extends HTMLElement {
843
851
  }
844
852
  }
845
853
  #calculateNormal(value) {
846
- let min = Number(this.input.min);
847
- let max = Number(this.input.max);
848
- let val = value;
849
- return (val - min) / (max - min);
854
+ let min = Number(this.min);
855
+ let max = Number(this.max);
856
+ return (Number(value) - min) / (max - min);
850
857
  }
851
858
  #syncProperties() {
852
859
  let complete = this.#calculateNormal(this.value);
853
- let defaultValue = this.#calculateNormal(this.default);
854
860
  this.style.setProperty("--slider-complete", complete);
861
+ let defaultValue = this.#calculateNormal(this.default);
855
862
  this.style.setProperty("--default", defaultValue);
856
863
  this.style.setProperty("--unchanged", complete === defaultValue ? 1 : 0);
857
864
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rogieking/figui3",
3
- "version": "1.2.7",
3
+ "version": "1.2.8",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "devDependencies": {