@rogieking/figui3 1.0.94 → 1.0.96
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 +18 -0
- package/fig.css +4 -3
- package/fig.js +29 -22
- package/package.json +1 -1
package/example.html
CHANGED
|
@@ -18,7 +18,25 @@
|
|
|
18
18
|
</fig-header>
|
|
19
19
|
<h2>Heading 2</h2>
|
|
20
20
|
<h3>Heading 3</h3>
|
|
21
|
+
<form onsubmit="console.log('submit'); return false;">
|
|
22
|
+
<fig-button type="submit">Submit</fig-button>
|
|
23
|
+
</form>
|
|
21
24
|
<br />
|
|
25
|
+
<fig-button id="button-progressive-blur"
|
|
26
|
+
variant="ghost"
|
|
27
|
+
icon="true"
|
|
28
|
+
class=""
|
|
29
|
+
disabled="true"><svg width="16"
|
|
30
|
+
height="16"
|
|
31
|
+
viewBox="0 0 16 16"
|
|
32
|
+
fill="none"
|
|
33
|
+
xmlns="http://www.w3.org/2000/svg">
|
|
34
|
+
<path fill-rule="evenodd"
|
|
35
|
+
clip-rule="evenodd"
|
|
36
|
+
d="M6.5 6C7.32843 6 8 5.32843 8 4.5C8 3.67157 7.32843 3 6.5 3C5.67157 3 5 3.67157 5 4.5C5 5.32843 5.67157 6 6.5 6ZM6.5 7C7.70948 7 8.71836 6.14112 8.94999 5H14V4H8.94999C8.71836 2.85888 7.70948 2 6.5 2C5.29052 2 4.28164 2.85888 4.05001 4H2V5H4.05001C4.28164 6.14112 5.29052 7 6.5 7ZM9.5 13C8.67157 13 8 12.3284 8 11.5C8 10.6716 8.67157 10 9.5 10C10.3284 10 11 10.6716 11 11.5C11 12.3284 10.3284 13 9.5 13ZM9.5 14C8.29052 14 7.28164 13.1411 7.05001 12H2V11H7.05001C7.28164 9.85888 8.29052 9 9.5 9C10.7095 9 11.7184 9.85888 11.95 11H14V12H11.95C11.7184 13.1411 10.7095 14 9.5 14Z"
|
|
37
|
+
fill="currentColor"></path>
|
|
38
|
+
</svg></fig-button>
|
|
39
|
+
<br /> <br />
|
|
22
40
|
<fig-button disabled>Button 1</fig-button>
|
|
23
41
|
<br /><br />
|
|
24
42
|
<fig-button variant="secondary"
|
package/fig.css
CHANGED
|
@@ -722,13 +722,14 @@ fig-button {
|
|
|
722
722
|
/* Disabled */
|
|
723
723
|
&[disabled]:not([disabled="false"]){
|
|
724
724
|
background-color: var(--figma-color-bg-disabled);
|
|
725
|
-
|
|
726
725
|
pointer-events: none;
|
|
726
|
+
cursor: not-allowed;
|
|
727
727
|
&:not([variant="secondary"]){
|
|
728
728
|
color: var(--figma-color-text-ondisabled);
|
|
729
729
|
box-shadow: none;
|
|
730
730
|
}
|
|
731
|
-
&[variant="secondary"]
|
|
731
|
+
&[variant="secondary"],
|
|
732
|
+
&[variant="ghost"]{
|
|
732
733
|
color: var(--figma-color-text-disabled);
|
|
733
734
|
background-color: transparent;
|
|
734
735
|
}
|
|
@@ -926,7 +927,7 @@ fig-avatar,
|
|
|
926
927
|
background: var(--checkerboard);
|
|
927
928
|
}
|
|
928
929
|
}
|
|
929
|
-
&[borderless] {
|
|
930
|
+
&[borderless] img{
|
|
930
931
|
box-shadow: none;
|
|
931
932
|
}
|
|
932
933
|
|
package/fig.js
CHANGED
|
@@ -8,17 +8,14 @@ function supportsPopover() {
|
|
|
8
8
|
if (window.customElements && !window.customElements.get("fig-button")) {
|
|
9
9
|
/* Button */
|
|
10
10
|
class FigButton extends HTMLElement {
|
|
11
|
-
|
|
11
|
+
type;
|
|
12
12
|
#selected;
|
|
13
13
|
constructor() {
|
|
14
14
|
super();
|
|
15
15
|
this.attachShadow({ mode: "open" });
|
|
16
16
|
}
|
|
17
17
|
connectedCallback() {
|
|
18
|
-
this.
|
|
19
|
-
}
|
|
20
|
-
render() {
|
|
21
|
-
this.#type = this.getAttribute("type") || "button";
|
|
18
|
+
this.type = this.getAttribute("type") || "button";
|
|
22
19
|
this.shadowRoot.innerHTML = `
|
|
23
20
|
<style>
|
|
24
21
|
button, button:hover, button:active {
|
|
@@ -39,7 +36,7 @@ if (window.customElements && !window.customElements.get("fig-button")) {
|
|
|
39
36
|
height: var(--spacer-4);
|
|
40
37
|
}
|
|
41
38
|
</style>
|
|
42
|
-
<button type="${this
|
|
39
|
+
<button type="${this.type}">
|
|
43
40
|
<slot></slot>
|
|
44
41
|
</button>
|
|
45
42
|
`;
|
|
@@ -47,42 +44,54 @@ if (window.customElements && !window.customElements.get("fig-button")) {
|
|
|
47
44
|
this.#selected =
|
|
48
45
|
this.hasAttribute("selected") &&
|
|
49
46
|
this.getAttribute("selected") !== "false";
|
|
50
|
-
this.addEventListener("click", this.handleClick.bind(this));
|
|
51
47
|
|
|
52
|
-
|
|
48
|
+
requestAnimationFrame(() => {
|
|
49
|
+
this.button = this.shadowRoot.querySelector("button");
|
|
50
|
+
this.button.addEventListener("click", this.#handleClick.bind(this));
|
|
51
|
+
});
|
|
53
52
|
}
|
|
53
|
+
|
|
54
54
|
get type() {
|
|
55
|
-
return this
|
|
55
|
+
return this.type;
|
|
56
56
|
}
|
|
57
57
|
set type(value) {
|
|
58
|
-
this.#type = value;
|
|
59
|
-
this.button.type = value;
|
|
60
58
|
this.setAttribute("type", value);
|
|
61
59
|
}
|
|
62
60
|
get selected() {
|
|
63
61
|
return this.#selected;
|
|
64
62
|
}
|
|
65
63
|
set selected(value) {
|
|
66
|
-
this.#selected = value;
|
|
67
64
|
this.setAttribute("selected", value);
|
|
68
65
|
}
|
|
69
66
|
|
|
70
|
-
handleClick(
|
|
71
|
-
if (this
|
|
72
|
-
this.selected
|
|
67
|
+
#handleClick() {
|
|
68
|
+
if (this.type === "toggle") {
|
|
69
|
+
this.toggleAttribute("selected", !this.hasAttribute("selected"));
|
|
73
70
|
}
|
|
74
|
-
if (this
|
|
75
|
-
this.
|
|
71
|
+
if (this.type === "submit") {
|
|
72
|
+
this.closest("form").dispatchEvent(new Event("submit"));
|
|
76
73
|
}
|
|
77
74
|
}
|
|
78
75
|
static get observedAttributes() {
|
|
79
|
-
return ["disabled"];
|
|
76
|
+
return ["disabled", "selected"];
|
|
80
77
|
}
|
|
81
78
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
82
79
|
if (this.button) {
|
|
83
80
|
this.button[name] = newValue;
|
|
84
|
-
|
|
85
|
-
|
|
81
|
+
switch (name) {
|
|
82
|
+
case "disabled":
|
|
83
|
+
this.disabled = this.button.disabled =
|
|
84
|
+
newValue === "true" ||
|
|
85
|
+
(newValue === undefined && newValue !== null);
|
|
86
|
+
break;
|
|
87
|
+
case "type":
|
|
88
|
+
this.type = newValue;
|
|
89
|
+
this.button.type = this.type;
|
|
90
|
+
this.button.setAttribute("type", this.type);
|
|
91
|
+
break;
|
|
92
|
+
case "selected":
|
|
93
|
+
this.#selected = newValue === "true";
|
|
94
|
+
break;
|
|
86
95
|
}
|
|
87
96
|
}
|
|
88
97
|
}
|
|
@@ -145,7 +154,6 @@ if (window.customElements && !window.customElements.get("fig-dropdown")) {
|
|
|
145
154
|
}
|
|
146
155
|
|
|
147
156
|
#handleSelectInput(e) {
|
|
148
|
-
console.log("FigDropdown #handleSelectInput:", e.target.value);
|
|
149
157
|
this.value = e.target.value;
|
|
150
158
|
this.setAttribute("value", this.value);
|
|
151
159
|
}
|
|
@@ -181,7 +189,6 @@ if (window.customElements && !window.customElements.get("fig-dropdown")) {
|
|
|
181
189
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
182
190
|
if (name === "value") {
|
|
183
191
|
this.#syncSelectedValue(newValue);
|
|
184
|
-
console.log("val:", this.value);
|
|
185
192
|
}
|
|
186
193
|
if (name === "type") {
|
|
187
194
|
this.type = newValue;
|
package/package.json
CHANGED