@rogieking/figui3 1.0.20 → 1.0.21

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/fig.css +23 -18
  2. package/fig.js +8 -3
  3. package/package.json +1 -1
package/fig.css CHANGED
@@ -602,26 +602,33 @@ fig-dropdown>option {
602
602
  /* Button */
603
603
  .fig-button,
604
604
  fig-button {
605
- border-radius: var(--radius-medium);
606
605
  box-shadow: inset 0 0 0 1px var(--figma-color-bordertranslucent);
607
606
  color: var(--figma-color-text-onbrand);
607
+ display: flex;
608
+ align-items: center;
609
+ justify-content: center;
610
+ height: var(--spacer-4);
611
+ padding: 0 var(--spacer-2);
612
+ appearance: none;
613
+ border: 0;
614
+ color: inherit;
615
+ outline: 0;
616
+ border-radius: var(--radius-medium);
617
+ background-color: var(--figma-color-bg-brand);
618
+ font-weight: 500;
608
619
 
609
- &,
610
620
  &>button {
621
+ background: transparent;
622
+ box-shadow: none;
623
+ border: 0;
624
+ appearance: none;
625
+ outline: 0;
611
626
  display: flex;
612
627
  align-items: center;
613
628
  justify-content: center;
629
+ border-radius: var(--radius-medium);
614
630
  height: var(--spacer-4);
615
631
  padding: 0 var(--spacer-2);
616
- appearance: none;
617
- border: 0;
618
- color: inherit;
619
- background-color: var(--figma-color-bg-brand);
620
- font-weight: 500;
621
- }
622
-
623
- &>button {
624
- background: transparent;
625
632
  }
626
633
 
627
634
  &:has(>button) {
@@ -633,8 +640,7 @@ fig-button {
633
640
  }
634
641
 
635
642
  /* Variant: Ghost */
636
- &[variant="ghost"],
637
- &[variant="ghost"]>button {
643
+ &[variant="ghost"] {
638
644
  box-shadow: none;
639
645
  background: none;
640
646
  color: var(--figma-color-text);
@@ -649,15 +655,13 @@ fig-button {
649
655
  }
650
656
  }
651
657
 
652
- &[variant="ghost"][disabled=true],
653
- &[variant="ghost"][disabled=true]>button {
658
+ &[variant="ghost"][disabled=true] {
654
659
  background-color: transparent;
655
660
  }
656
661
 
657
662
 
658
663
  /* Variant: Secondary */
659
- &[variant="secondary"],
660
- &[variant="secondary"]>button {
664
+ &[variant="secondary"] {
661
665
  box-shadow: inset 0 0 0 1px var(--figma-color-border);
662
666
  background: none;
663
667
  color: var(--figma-color-text);
@@ -736,7 +740,8 @@ fig-button {
736
740
  background-color: var(--figma-color-bg-selected);
737
741
  }
738
742
 
739
- &:focus {
743
+ &:focus,
744
+ &:focus-within {
740
745
  outline: 0;
741
746
  box-shadow: inset 0 0 0 1px var(--figma-color-border-selected);
742
747
  }
package/fig.js CHANGED
@@ -18,7 +18,7 @@ class FigButton extends HTMLElement {
18
18
  this.render()
19
19
  }
20
20
  render() {
21
- this.#type = this.getAttribute("type")
21
+ this.#type = this.getAttribute("type") || "button"
22
22
  /*this.shadowRoot.innerHTML = `
23
23
  <style>
24
24
  button, button:hover, button:active {
@@ -37,12 +37,17 @@ class FigButton extends HTMLElement {
37
37
  <slot></slot>
38
38
  </button>
39
39
  `;*/
40
- this.innerHTML = `<button type="${this.#type}">${this.innerHTML}</button>`
40
+
41
41
  this.#selected = this.hasAttribute("selected") && this.getAttribute("selected") !== "false"
42
- this.button = this.querySelector('button')
43
42
  this.addEventListener("click", this.handleClick.bind(this))
44
43
 
45
44
 
45
+ //child nodes hack
46
+ requestAnimationFrame(() => {
47
+ this.innerHTML = `<button type="${this.#type}">${this.innerHTML}</button>`
48
+ this.button = this.querySelector('button')
49
+ })
50
+
46
51
  }
47
52
  get type() {
48
53
  return this.#type
package/package.json CHANGED
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "name": "@rogieking/figui3",
3
- "version": "1.0.20"
3
+ "version": "1.0.21"
4
4
  }