@rogieking/figui3 1.7.0 → 1.7.2
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/components.css +13 -0
- package/example.html +12 -2
- package/fig.js +36 -1
- package/package.json +1 -1
package/components.css
CHANGED
|
@@ -982,6 +982,11 @@ fig-tabs,
|
|
|
982
982
|
gap: var(--spacer-2);
|
|
983
983
|
}
|
|
984
984
|
|
|
985
|
+
fig-tab-content,
|
|
986
|
+
.fig-tab-content {
|
|
987
|
+
display: none;
|
|
988
|
+
}
|
|
989
|
+
|
|
985
990
|
/* Avatar */
|
|
986
991
|
fig-avatar,
|
|
987
992
|
.fig-avatar {
|
|
@@ -2257,6 +2262,14 @@ fig-input-text {
|
|
|
2257
2262
|
box-shadow: inset 0 0 0 1px var(--figma-color-border-selected);
|
|
2258
2263
|
outline: 0;
|
|
2259
2264
|
}
|
|
2265
|
+
/* Disabled */
|
|
2266
|
+
&[disabled]:not([disabled="false"]) {
|
|
2267
|
+
background-color: var(--figma-color-bg);
|
|
2268
|
+
pointer-events: none;
|
|
2269
|
+
cursor: not-allowed;
|
|
2270
|
+
color: var(--figma-color-text-disabled);
|
|
2271
|
+
box-shadow: inset 0 0 0 1px var(--figma-color-border-disabled);
|
|
2272
|
+
}
|
|
2260
2273
|
}
|
|
2261
2274
|
|
|
2262
2275
|
fig-input-color {
|
package/example.html
CHANGED
|
@@ -26,6 +26,9 @@
|
|
|
26
26
|
<h2><label>Effects/</label>UI3 Components</h2>
|
|
27
27
|
</fig-header>
|
|
28
28
|
|
|
29
|
+
<fig-input-text disabled
|
|
30
|
+
value="Disabled"></fig-input-text>
|
|
31
|
+
|
|
29
32
|
<fig-popover action="manual"
|
|
30
33
|
open="true"
|
|
31
34
|
size="large">
|
|
@@ -240,9 +243,16 @@
|
|
|
240
243
|
</fig-header>
|
|
241
244
|
<fig-field>
|
|
242
245
|
<fig-tabs>
|
|
243
|
-
<fig-tab selected
|
|
244
|
-
|
|
246
|
+
<fig-tab selected
|
|
247
|
+
content="#tab-1-content">Tab #1</fig-tab>
|
|
248
|
+
<fig-tab content="#tab-2-content">Tab #2</fig-tab>
|
|
245
249
|
</fig-tabs>
|
|
250
|
+
<fig-tab-content id="tab-1-content">
|
|
251
|
+
Content for Tab #1
|
|
252
|
+
</fig-tab-content>
|
|
253
|
+
<fig-tab-content id="tab-2-content">
|
|
254
|
+
Content for Tab #2
|
|
255
|
+
</fig-tab-content>
|
|
246
256
|
</fig-field>
|
|
247
257
|
<fig-header>
|
|
248
258
|
<h2>Segmented control</h2>
|
package/fig.js
CHANGED
|
@@ -529,18 +529,53 @@ window.customElements.define("fig-popover-2", FigPopover2);
|
|
|
529
529
|
* @attr {boolean} selected - Whether the tab is currently selected
|
|
530
530
|
*/
|
|
531
531
|
class FigTab extends HTMLElement {
|
|
532
|
+
#selected;
|
|
532
533
|
constructor() {
|
|
533
534
|
super();
|
|
535
|
+
this.content = null;
|
|
536
|
+
this.#selected = false;
|
|
534
537
|
}
|
|
535
538
|
connectedCallback() {
|
|
536
539
|
this.setAttribute("label", this.innerText);
|
|
537
540
|
this.addEventListener("click", this.handleClick.bind(this));
|
|
541
|
+
|
|
542
|
+
requestAnimationFrame(() => {
|
|
543
|
+
if (typeof this.getAttribute("content") === "string") {
|
|
544
|
+
this.content = document.querySelector(this.getAttribute("content"));
|
|
545
|
+
if (this.#selected) {
|
|
546
|
+
this.content.style.display = "block";
|
|
547
|
+
} else {
|
|
548
|
+
this.content.style.display = "none";
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
get selected() {
|
|
554
|
+
return this.#selected;
|
|
555
|
+
}
|
|
556
|
+
set selected(value) {
|
|
557
|
+
this.setAttribute("selected", value ? "true" : "false");
|
|
538
558
|
}
|
|
539
559
|
disconnectedCallback() {
|
|
540
560
|
this.removeEventListener("click", this.handleClick);
|
|
541
561
|
}
|
|
542
562
|
handleClick() {
|
|
543
|
-
this.
|
|
563
|
+
this.selected = true;
|
|
564
|
+
if (this.content) {
|
|
565
|
+
this.content.style.display = "block";
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
static get observedAttributes() {
|
|
570
|
+
return ["selected"];
|
|
571
|
+
}
|
|
572
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
573
|
+
if (name === "selected") {
|
|
574
|
+
this.#selected = newValue !== null && newValue !== "false";
|
|
575
|
+
if (this?.content) {
|
|
576
|
+
this.content.style.display = this.#selected ? "block" : "none";
|
|
577
|
+
}
|
|
578
|
+
}
|
|
544
579
|
}
|
|
545
580
|
}
|
|
546
581
|
window.customElements.define("fig-tab", FigTab);
|