@rogieking/figui3 1.0.5 → 1.0.7
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/fig.css +2 -11
- package/fig.js +50 -2
- package/package.json +1 -1
package/fig.css
CHANGED
|
@@ -529,17 +529,8 @@ fig-segmented-control {
|
|
|
529
529
|
appearance: none;
|
|
530
530
|
padding: 0 var(--spacer-2);
|
|
531
531
|
|
|
532
|
-
&
|
|
533
|
-
|
|
534
|
-
inset: 0;
|
|
535
|
-
border-radius: 0;
|
|
536
|
-
opacity: 0;
|
|
537
|
-
z-index: 1;
|
|
538
|
-
width: 100%;
|
|
539
|
-
height: 100%;
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
&:has(:checked) {
|
|
532
|
+
&[selected]:not([selected=false]),
|
|
533
|
+
&[selected=true] {
|
|
543
534
|
background-color: var(--figma-color-bg);
|
|
544
535
|
border-radius: calc(var(--radius-medium) - 1px);
|
|
545
536
|
box-shadow: var(--handle-shadow);
|
package/fig.js
CHANGED
|
@@ -406,6 +406,9 @@ class FigTab extends HTMLElement {
|
|
|
406
406
|
this.setAttribute("label", this.innerText)
|
|
407
407
|
this.addEventListener("click", this.handleClick.bind(this))
|
|
408
408
|
}
|
|
409
|
+
disconnectedCallback() {
|
|
410
|
+
this.removeEventListener("click", this.handleClick)
|
|
411
|
+
}
|
|
409
412
|
handleClick() {
|
|
410
413
|
this.setAttribute("selected", "true")
|
|
411
414
|
}
|
|
@@ -420,13 +423,17 @@ class FigTabs extends HTMLElement {
|
|
|
420
423
|
this.name = this.getAttribute("name") || "tabs"
|
|
421
424
|
this.addEventListener("click", this.handleClick.bind(this))
|
|
422
425
|
}
|
|
426
|
+
disconnectedCallback() {
|
|
427
|
+
this.removeEventListener("click", this.handleClick)
|
|
428
|
+
}
|
|
423
429
|
handleClick(event) {
|
|
424
430
|
const target = event.target;
|
|
425
431
|
if (target.nodeName.toLowerCase() === "fig-tab") {
|
|
426
432
|
const tabs = this.querySelectorAll("fig-tab")
|
|
427
|
-
console.log("change", target, tabs, target.nodeName)
|
|
428
433
|
for (const tab of tabs) {
|
|
429
|
-
if (tab
|
|
434
|
+
if (tab === target) {
|
|
435
|
+
this.selectedTab = tab
|
|
436
|
+
} else {
|
|
430
437
|
tab.removeAttribute("selected")
|
|
431
438
|
}
|
|
432
439
|
}
|
|
@@ -435,6 +442,47 @@ class FigTabs extends HTMLElement {
|
|
|
435
442
|
}
|
|
436
443
|
window.customElements.define('fig-tabs', FigTabs);
|
|
437
444
|
|
|
445
|
+
/* Segmented Control */
|
|
446
|
+
class FigSegment extends HTMLElement {
|
|
447
|
+
constructor() {
|
|
448
|
+
super()
|
|
449
|
+
}
|
|
450
|
+
connectedCallback() {
|
|
451
|
+
this.addEventListener("click", this.handleClick.bind(this))
|
|
452
|
+
}
|
|
453
|
+
disconnectedCallback() {
|
|
454
|
+
this.removeEventListener("click", this.handleClick)
|
|
455
|
+
}
|
|
456
|
+
handleClick() {
|
|
457
|
+
this.setAttribute("selected", "true")
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
window.customElements.define('fig-segment', FigSegment);
|
|
461
|
+
|
|
462
|
+
class FigSegmentedControl extends HTMLElement {
|
|
463
|
+
constructor() {
|
|
464
|
+
super()
|
|
465
|
+
}
|
|
466
|
+
connectedCallback() {
|
|
467
|
+
this.name = this.getAttribute("name") || "segmented-control"
|
|
468
|
+
this.addEventListener("click", this.handleClick.bind(this))
|
|
469
|
+
}
|
|
470
|
+
handleClick(event) {
|
|
471
|
+
const target = event.target;
|
|
472
|
+
if (target.nodeName.toLowerCase() === "fig-segment") {
|
|
473
|
+
const segments = this.querySelectorAll("fig-segment")
|
|
474
|
+
for (const segment of segments) {
|
|
475
|
+
if (segment === target) {
|
|
476
|
+
this.selectedSegment = segment
|
|
477
|
+
} else {
|
|
478
|
+
segment.removeAttribute("selected")
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
window.customElements.define('fig-segmented-control', FigSegmentedControl);
|
|
485
|
+
|
|
438
486
|
|
|
439
487
|
|
|
440
488
|
/* Slider */
|
package/package.json
CHANGED