@rogieking/figui3 1.0.15 → 1.0.17

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
@@ -48,8 +48,9 @@
48
48
  </svg>
49
49
  </fig-button>
50
50
  <fig-tooltip text="Toggle off/on">
51
- <fig-button variant="toggle"
51
+ <fig-button variant="ghost"
52
52
  icon="true"
53
+ type="toggle"
53
54
  selected="true">
54
55
  <svg width="24"
55
56
  height="24"
package/fig.css CHANGED
@@ -616,6 +616,7 @@ input[type=button] {
616
616
  color: var(--figma-color-text-onbrand);
617
617
  border-radius: var(--radius-medium);
618
618
  font-weight: 500;
619
+ box-shadow: inset 0 0 0 1px var(--figma-color-bordertranslucent);
619
620
 
620
621
  &:active {
621
622
  background-color: var(--figma-color-bg-brand-pressed);
@@ -1213,6 +1214,7 @@ fig-slider {
1213
1214
  bottom: 0;
1214
1215
  border-radius: 0.5rem;
1215
1216
  min-width: var(--slider-height);
1217
+ box-shadow: inset 0 0 0 1px var(--figma-color-bordertranslucent);
1216
1218
  width: calc(var(--slider-percent) + (1 - var(--slider-complete)) * var(--slider-height));
1217
1219
  max-width: 100%;
1218
1220
  }
package/fig.js CHANGED
@@ -8,6 +8,8 @@ function supportsPopover() {
8
8
 
9
9
  /* Button */
10
10
  class FigButton extends HTMLElement {
11
+ #type
12
+ #selected
11
13
  constructor() {
12
14
  super()
13
15
  this.attachShadow({ mode: 'open' })
@@ -21,11 +23,12 @@ class FigButton extends HTMLElement {
21
23
  button, button:hover, button:active {
22
24
  padding: 0;
23
25
  appearance: none;
24
- display: block;
26
+ display: flex;
25
27
  border: 0;
26
28
  font: inherit;
27
29
  color: inherit;
28
30
  outline: 0;
31
+ place-items: center;
29
32
  background: transparent;
30
33
  }
31
34
  </style>
@@ -33,7 +36,30 @@ class FigButton extends HTMLElement {
33
36
  <slot></slot>
34
37
  </button>
35
38
  `;
39
+ this.#selected = this.hasAttribute("selected") && this.getAttribute("selected") !== "false"
40
+ this.#type = this.getAttribute("type")
36
41
  this.button = this.shadowRoot.querySelector('button')
42
+ this.addEventListener("click", this.handleClick.bind(this))
43
+ }
44
+ get type() {
45
+ return this.#type
46
+ }
47
+ set type(value) {
48
+ this.#type = value
49
+ this.setAttribute("type", value)
50
+ }
51
+ get selected() {
52
+ return this.#selected
53
+ }
54
+ set selected(value) {
55
+ this.#selected = value
56
+ this.setAttribute("selected", value)
57
+ }
58
+
59
+ handleClick() {
60
+ if (this.#type === "toggle") {
61
+ this.selected = !this.#selected
62
+ }
37
63
  }
38
64
  static get observedAttributes() {
39
65
  return ['disabled'];
package/package.json CHANGED
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "name": "@rogieking/figui3",
3
- "version": "1.0.15"
3
+ "version": "1.0.17"
4
4
  }