@rogieking/figui3 1.3.6 → 1.3.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.
Files changed (4) hide show
  1. package/example.html +36 -0
  2. package/fig.css +14 -0
  3. package/fig.js +31 -19
  4. package/package.json +1 -1
package/example.html CHANGED
@@ -23,6 +23,42 @@
23
23
  <h2>UI3 Components</h2>
24
24
  </fig-header>
25
25
  <fig-content>
26
+ <br /><br />
27
+ <fig-input-angle value="45"
28
+ text="true"></fig-input-angle>
29
+ <br /><br />
30
+ <fig-slider min="0.01"
31
+ max="0.25"
32
+ name="u_thickness"
33
+ variant="minimal"
34
+ step="0.01"
35
+ value="1"
36
+ text="true"
37
+ type="range"
38
+ units="%"
39
+ transform="100">
40
+ </fig-slider>
41
+ <fig-input-text type="number"
42
+ min="1"
43
+ style="width: 100px;"
44
+ max="2"
45
+ step="0.01"
46
+ value="1.5"
47
+ type="range"
48
+ units="%"
49
+ onInput="console.log(event.target.value)"
50
+ transform="100">
51
+ </fig-input-text>
52
+ <fig-slider min="1"
53
+ max="2"
54
+ step="0.01"
55
+ value="1.5"
56
+ type="range"
57
+ units="%"
58
+ text="true"
59
+ onInput="console.log(event.target.value)"
60
+ transform="100">
61
+ </fig-slider>
26
62
  <fig-input-angle text="true"
27
63
  value="0"
28
64
  onInput="console.log(event.target.adjacent, event.target.opposite)"></fig-input-angle>
package/fig.css CHANGED
@@ -1,6 +1,7 @@
1
1
  :root {
2
2
  --figma-color-bg: #ffffff;
3
3
  --figma-color-bg-brand: #0d99ff;
4
+
4
5
  --figma-color-bg-brand-hover: #007be5;
5
6
  --figma-color-bg-brand-pressed: #007be5;
6
7
  --figma-color-bg-brand-secondary: #0768cf;
@@ -160,6 +161,7 @@
160
161
  --figma-color-text-onwarning-tertiary: #0000004d;
161
162
  --figma-color-text-secondary: #00000080;
162
163
  --figma-color-text-secondary-hover: #000000e5;
164
+ --figma-color-text-selection: rgba(13, 153, 255, 0.4);
163
165
  --figma-color-text-selected: #007be5;
164
166
  --figma-color-text-selected-secondary: #007be5;
165
167
  --figma-color-text-selected-tertiary: #007be5;
@@ -478,6 +480,14 @@ html {
478
480
  box-sizing: border-box;
479
481
  }
480
482
 
483
+ ::selection {
484
+ background-color: var(--figma-color-text-selection);
485
+ }
486
+
487
+ ::-moz-selection {
488
+ background-color: var(--figma-color-text-selection);
489
+ }
490
+
481
491
  body {
482
492
  font-size: var(--body-medium-fontSize);
483
493
  letter-spacing: var(--body-letter-spacing);
@@ -2213,12 +2223,14 @@ fig-field,
2213
2223
  justify-content: space-between;
2214
2224
  min-height: calc(1rem + var(--spacer-1) * 2);
2215
2225
  align-items: center;
2226
+ width: 100%;
2216
2227
  }
2217
2228
 
2218
2229
  &[direction="horizontal"] {
2219
2230
  gap: var(--spacer-2);
2220
2231
  align-items: start;
2221
2232
  flex-direction: row;
2233
+ width: auto;
2222
2234
 
2223
2235
  & > label {
2224
2236
  min-width: 4rem;
@@ -2259,10 +2271,12 @@ fig-segmented-control {
2259
2271
  justify-content: center;
2260
2272
  position: relative;
2261
2273
  appearance: none;
2274
+ color: var(--figma-color-text-se);
2262
2275
  padding: 0 var(--spacer-2);
2263
2276
 
2264
2277
  &[selected]:not([selected="false"]),
2265
2278
  &[selected="true"] {
2279
+ color: var(--figma-color-text);
2266
2280
  background-color: var(--figma-color-bg);
2267
2281
  border-radius: calc(var(--radius-medium) - 1px);
2268
2282
  box-shadow: 0 0 0 1px var(--figma-color-border);
package/fig.js CHANGED
@@ -959,30 +959,42 @@ class FigInputText extends HTMLElement {
959
959
  this.input.focus();
960
960
  }
961
961
  #transformNumber(value) {
962
- let transformed = value === "" ? "" : Number(value) * (this.transform || 1);
962
+ if (value === "") return "";
963
+ let transformed = Number(value) * (this.transform || 1);
963
964
  transformed = this.#formatNumber(transformed);
964
965
  return transformed;
965
966
  }
966
967
  #handleInput(e) {
968
+ console.log("handleInput", e.target.value);
969
+ e.stopPropagation();
967
970
  let value = e.target.value;
971
+ let valueTransformed = value;
968
972
  if (this.type === "number") {
969
- value = this.#sanitizeInput(value);
970
- //value = Number(value);
971
973
  value = value / (this.transform || 1);
974
+ value = this.#sanitizeInput(value, false);
975
+ valueTransformed = value * (this.transform || 1);
972
976
  }
973
- this.setAttribute("value", value);
977
+ this.value = value;
978
+ this.input.value = valueTransformed;
979
+ this.dispatchEvent(new CustomEvent("input", { bubbles: true }));
974
980
  }
975
981
  #handleMouseMove(e) {
982
+ if (this.type !== "number") return;
976
983
  if (e.altKey) {
977
- const step = (this.step || 1) * e.movementX;
978
- const value = this.#sanitizeInput(
979
- Number(this.value) + step,
980
- false
981
- ).toFixed(2);
982
- this.setAttribute("value", value);
984
+ let step = (this.step || 1) * e.movementX;
985
+ let value = Number(this.input.value);
986
+ value = value / (this.transform || 1) + step;
987
+ value = this.#sanitizeInput(value, false);
988
+ let valueTransformed = value * (this.transform || 1);
989
+ value = this.#formatNumber(value);
990
+ valueTransformed = this.#formatNumber(valueTransformed);
991
+ this.value = value;
992
+ this.input.value = valueTransformed;
993
+ this.dispatchEvent(new CustomEvent("input", { bubbles: true }));
983
994
  }
984
995
  }
985
996
  #handleMouseDown(e) {
997
+ if (this.type !== "number") return;
986
998
  if (e.altKey) {
987
999
  this.input.style.cursor =
988
1000
  this.style.cursor =
@@ -995,6 +1007,7 @@ class FigInputText extends HTMLElement {
995
1007
  }
996
1008
  }
997
1009
  #handleMouseUp(e) {
1010
+ if (this.type !== "number") return;
998
1011
  this.input.style.cursor =
999
1012
  this.style.cursor =
1000
1013
  document.body.style.cursor =
@@ -1020,6 +1033,7 @@ class FigInputText extends HTMLElement {
1020
1033
  sanitized
1021
1034
  );
1022
1035
  }
1036
+
1023
1037
  sanitized = this.#formatNumber(sanitized);
1024
1038
  }
1025
1039
  return sanitized;
@@ -1056,18 +1070,15 @@ class FigInputText extends HTMLElement {
1056
1070
  case "transform":
1057
1071
  if (this.type === "number") {
1058
1072
  this.transform = Number(newValue) || 1;
1059
- this.min = this.#transformNumber(this.min);
1060
- this.max = this.#transformNumber(this.max);
1061
- this.step = this.#transformNumber(this.step);
1062
- this.value = this.#transformNumber(this.value);
1073
+ this.input.value = this.#transformNumber(this.value);
1063
1074
  }
1064
1075
  break;
1065
1076
  case "value":
1066
1077
  let value = newValue;
1067
1078
  if (this.type === "number") {
1068
- let sanitized = this.#sanitizeInput(value);
1069
- this.value = sanitized;
1070
- this.input.value = this.#transformNumber(sanitized);
1079
+ value = this.#sanitizeInput(value, false);
1080
+ this.value = value;
1081
+ this.input.value = this.#transformNumber(value);
1071
1082
  } else {
1072
1083
  this.value = value;
1073
1084
  this.input.value = value;
@@ -1935,6 +1946,7 @@ class FigInputJoystick extends HTMLElement {
1935
1946
  this.#updatePosition(e.touches[0]);
1936
1947
 
1937
1948
  const handleTouchMove = (e) => {
1949
+ this.plane.classList.add("dragging");
1938
1950
  if (this.isDragging) this.#updatePosition(e.touches[0]);
1939
1951
  };
1940
1952
 
@@ -2011,8 +2023,9 @@ class FigInputAngle extends HTMLElement {
2011
2023
  this.handle = null;
2012
2024
  this.angleInput = null;
2013
2025
  this.plane = null;
2026
+ }
2014
2027
 
2015
- // Initialize position
2028
+ connectedCallback() {
2016
2029
  requestAnimationFrame(() => {
2017
2030
  this.precision = this.getAttribute("precision") || 1;
2018
2031
  this.precision = parseInt(this.precision);
@@ -2251,5 +2264,4 @@ class FigInputAngle extends HTMLElement {
2251
2264
  }
2252
2265
  }
2253
2266
  }
2254
-
2255
2267
  customElements.define("fig-input-angle", FigInputAngle);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rogieking/figui3",
3
- "version": "1.3.6",
3
+ "version": "1.3.8",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "devDependencies": {