@statistikzh/leu 0.2.0 → 0.4.0

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 (153) hide show
  1. package/.github/workflows/deploy-github-pages.yaml +33 -0
  2. package/.storybook/main.js +27 -1
  3. package/.storybook/manager-head.html +1 -0
  4. package/.storybook/manager.js +9 -0
  5. package/.storybook/preview-head.html +1 -1
  6. package/.storybook/preview.js +59 -5
  7. package/.storybook/static/logo.svg +19 -0
  8. package/.storybook/theme.js +7 -0
  9. package/CHANGELOG.md +43 -0
  10. package/README.md +1 -1
  11. package/dist/Button.js +39 -30
  12. package/dist/ButtonGroup.js +5 -7
  13. package/dist/Checkbox.js +107 -88
  14. package/dist/CheckboxGroup.js +43 -38
  15. package/dist/{Chip-389013ff.js → Chip-dac7337d.js} +7 -2
  16. package/dist/ChipGroup.js +4 -6
  17. package/dist/ChipLink.js +6 -8
  18. package/dist/ChipRemovable.js +4 -7
  19. package/dist/ChipSelectable.js +10 -10
  20. package/dist/Dropdown.js +57 -27
  21. package/dist/Input.js +59 -43
  22. package/dist/Menu.js +2 -5
  23. package/dist/MenuItem.js +34 -17
  24. package/dist/Pagination.js +57 -55
  25. package/dist/Radio.js +13 -10
  26. package/dist/RadioGroup.js +43 -40
  27. package/dist/Select.js +57 -44
  28. package/dist/Table.js +147 -125
  29. package/dist/{defineElement-ba770aed.js → _rollupPluginBabelHelpers-20f659f4.js} +1 -15
  30. package/dist/defineElement-47d4f665.js +15 -0
  31. package/dist/index.js +29 -19
  32. package/dist/leu-button-group.js +7 -3
  33. package/dist/leu-button.js +6 -3
  34. package/dist/leu-checkbox-group.js +6 -3
  35. package/dist/leu-checkbox.js +6 -3
  36. package/dist/leu-chip-group.js +6 -3
  37. package/dist/leu-chip-link.js +7 -4
  38. package/dist/leu-chip-removable.js +7 -4
  39. package/dist/leu-chip-selectable.js +7 -4
  40. package/dist/leu-dropdown.js +13 -3
  41. package/dist/leu-input.js +7 -3
  42. package/dist/leu-menu-item.js +8 -3
  43. package/dist/leu-menu.js +6 -3
  44. package/dist/leu-pagination.js +8 -3
  45. package/dist/leu-popup-4bf6f1f4.js +216 -0
  46. package/dist/leu-radio-group.js +6 -3
  47. package/dist/leu-radio.js +6 -3
  48. package/dist/leu-select.js +14 -3
  49. package/dist/leu-table.js +9 -3
  50. package/package.json +29 -12
  51. package/scripts/generate-component/templates/[Name].js +0 -5
  52. package/scripts/generate-component/templates/[name].css +1 -1
  53. package/scripts/generate-component/templates/[namespace]-[name].js +5 -2
  54. package/src/components/accordion/Accordion.js +3 -9
  55. package/src/components/accordion/leu-accordion.js +5 -2
  56. package/src/components/accordion/stories/accordion.stories.js +7 -4
  57. package/src/components/accordion/test/accordion.test.js +92 -2
  58. package/src/components/breadcrumb/Breadcrumb.js +310 -0
  59. package/src/components/breadcrumb/breadcrumb.css +114 -0
  60. package/src/components/breadcrumb/leu-breadcrumb.js +6 -0
  61. package/src/components/breadcrumb/stories/breadcrumb.stories.js +73 -0
  62. package/src/components/breadcrumb/test/breadcrumb.test.js +141 -0
  63. package/src/components/button/Button.js +22 -27
  64. package/src/components/button/button.css +3 -3
  65. package/src/components/button/leu-button.js +5 -2
  66. package/src/components/button/stories/button.stories.js +58 -37
  67. package/src/components/button/test/button.test.js +112 -2
  68. package/src/components/button-group/ButtonGroup.js +1 -7
  69. package/src/components/button-group/leu-button-group.js +5 -2
  70. package/src/components/button-group/stories/button-group.stories.js +6 -0
  71. package/src/components/button-group/test/button-group.test.js +79 -3
  72. package/src/components/checkbox/Checkbox.js +9 -89
  73. package/src/components/checkbox/CheckboxGroup.js +9 -39
  74. package/src/components/checkbox/checkbox-group.css +29 -0
  75. package/src/components/checkbox/checkbox.css +76 -0
  76. package/src/components/checkbox/leu-checkbox-group.js +5 -2
  77. package/src/components/checkbox/leu-checkbox.js +5 -2
  78. package/src/components/checkbox/stories/checkbox-group.stories.js +44 -21
  79. package/src/components/checkbox/stories/checkbox.stories.js +7 -1
  80. package/src/components/checkbox/test/checkbox-group.test.js +124 -0
  81. package/src/components/checkbox/test/checkbox.test.js +72 -59
  82. package/src/components/chip/Chip.js +2 -1
  83. package/src/components/chip/ChipGroup.js +1 -6
  84. package/src/components/chip/ChipLink.js +2 -8
  85. package/src/components/chip/ChipRemovable.js +1 -6
  86. package/src/components/chip/ChipSelectable.js +4 -9
  87. package/src/components/chip/exports.js +4 -10
  88. package/src/components/chip/leu-chip-group.js +5 -2
  89. package/src/components/chip/leu-chip-link.js +5 -2
  90. package/src/components/chip/leu-chip-removable.js +5 -2
  91. package/src/components/chip/leu-chip-selectable.js +5 -2
  92. package/src/components/chip/stories/chip-group.stories.js +18 -6
  93. package/src/components/chip/stories/chip-link.stories.js +16 -4
  94. package/src/components/chip/stories/chip-removable.stories.js +15 -4
  95. package/src/components/chip/stories/chip-selectable.stories.js +13 -3
  96. package/src/components/chip/test/chip-group.test.js +124 -0
  97. package/src/components/chip/test/chip-link.test.js +58 -0
  98. package/src/components/chip/test/chip-removable.test.js +79 -0
  99. package/src/components/chip/test/chip-selectable.test.js +95 -0
  100. package/src/components/chip/test/chip.test.js +1 -1
  101. package/src/components/dropdown/Dropdown.js +53 -25
  102. package/src/components/dropdown/dropdown.css +1 -2
  103. package/src/components/dropdown/leu-dropdown.js +5 -2
  104. package/src/components/dropdown/stories/dropdown.stories.js +11 -5
  105. package/src/components/dropdown/test/dropdown.test.js +6 -6
  106. package/src/components/icon/icon.js +1 -1
  107. package/src/components/icon/test/icon.test.js +66 -0
  108. package/src/components/input/Input.js +33 -39
  109. package/src/components/input/input.css +9 -6
  110. package/src/components/input/leu-input.js +5 -2
  111. package/src/components/input/stories/input.stories.js +8 -2
  112. package/src/components/input/test/input.test.js +431 -4
  113. package/src/components/menu/Menu.js +0 -5
  114. package/src/components/menu/MenuItem.js +22 -15
  115. package/src/components/menu/leu-menu-item.js +5 -2
  116. package/src/components/menu/leu-menu.js +5 -2
  117. package/src/components/menu/menu-item.css +5 -2
  118. package/src/components/menu/stories/menu-item.stories.js +13 -4
  119. package/src/components/menu/stories/menu.stories.js +11 -5
  120. package/src/components/menu/test/menu-item.test.js +180 -0
  121. package/src/components/menu/test/menu.test.js +10 -2
  122. package/src/components/pagination/Pagination.js +53 -65
  123. package/src/components/pagination/leu-pagination.js +5 -2
  124. package/src/components/pagination/stories/pagination.stories.js +17 -9
  125. package/src/components/pagination/test/pagination.test.js +191 -5
  126. package/src/components/popup/Popup.js +200 -0
  127. package/src/components/popup/leu-popup.js +6 -0
  128. package/src/components/popup/popup.css +27 -0
  129. package/src/components/popup/stories/popup.stories.js +58 -0
  130. package/src/components/popup/test/popup.test.js +29 -0
  131. package/src/components/radio/Radio.js +5 -10
  132. package/src/components/radio/RadioGroup.js +7 -39
  133. package/src/components/radio/leu-radio-group.js +5 -2
  134. package/src/components/radio/leu-radio.js +5 -2
  135. package/src/components/radio/radio-group.css +29 -0
  136. package/src/components/radio/stories/radio-group.stories.js +38 -19
  137. package/src/components/radio/stories/radio.stories.js +7 -1
  138. package/src/components/radio/test/radio-group.test.js +86 -0
  139. package/src/components/radio/test/radio.test.js +108 -17
  140. package/src/components/select/Select.js +35 -32
  141. package/src/components/select/leu-select.js +5 -2
  142. package/src/components/select/select.css +13 -13
  143. package/src/components/select/stories/select.stories.js +15 -168
  144. package/src/components/select/test/fixtures.js +162 -0
  145. package/src/components/select/test/select.test.js +236 -12
  146. package/src/components/table/Table.js +48 -123
  147. package/src/components/table/leu-table.js +5 -2
  148. package/src/components/table/stories/table.stories.js +20 -10
  149. package/src/components/table/table.css +99 -0
  150. package/src/components/table/test/table.test.js +1 -1
  151. package/src/lib/utils.js +17 -0
  152. package/{web-dev-server-storybook.config.mjs → web-dev-server.config.mjs} +1 -2
  153. package/web-test-runner.config.mjs +15 -2
@@ -1,7 +1,6 @@
1
1
  import { html, LitElement } from "lit"
2
- import { defineElement } from "../../lib/defineElement.js"
3
2
  import styles from "./button-group.css"
4
- import { defineButtonElements } from "../button/Button.js"
3
+ import "../button/leu-button.js"
5
4
 
6
5
  /**
7
6
  * @tagname leu-button-group
@@ -56,8 +55,3 @@ export class LeuButtonGroup extends LitElement {
56
55
  `
57
56
  }
58
57
  }
59
-
60
- export function defineButtonGroupElements() {
61
- defineButtonElements()
62
- defineElement("button-group", LeuButtonGroup)
63
- }
@@ -1,3 +1,6 @@
1
- import { defineButtonGroupElements } from "./ButtonGroup.js"
1
+ import { defineElement } from "../../lib/defineElement.js"
2
+ import { LeuButtonGroup } from "./ButtonGroup.js"
2
3
 
3
- defineButtonGroupElements()
4
+ export { LeuButtonGroup }
5
+
6
+ defineElement("button-group", LeuButtonGroup)
@@ -14,6 +14,12 @@ function updateStorybookArgss(id, args) {
14
14
  export default {
15
15
  title: "ButtonGroup",
16
16
  component: "leu-button-group",
17
+ parameters: {
18
+ design: {
19
+ type: "figma",
20
+ url: "https://www.figma.com/file/d6Pv21UVUbnBs3AdcZijHmbN/KTZH-Design-System?type=design&node-id=18180-165796&mode=design&t=lzVrtq8lxYVJU5TB-11",
21
+ },
22
+ },
17
23
  }
18
24
 
19
25
  function Template({ items, value }, { id }) {
@@ -1,15 +1,17 @@
1
1
  import { html } from "lit"
2
- import { fixture, expect } from "@open-wc/testing"
2
+ import { fixture, expect, oneEvent, elementUpdated } from "@open-wc/testing"
3
3
 
4
4
  import "../leu-button-group.js"
5
5
 
6
+ const items = ["Eins", "Zwei", "Drei"]
7
+
6
8
  async function defaultFixture() {
7
- return fixture(html` <leu-button-group /> `)
9
+ return fixture(html` <leu-button-group .items=${items}></leu-button-group> `)
8
10
  }
9
11
 
10
12
  describe("LeuButtonGroup", () => {
11
13
  it("is a defined element", async () => {
12
- const el = await customElements.get("leu-button-group")
14
+ const el = customElements.get("leu-button-group")
13
15
 
14
16
  await expect(el).not.to.be.undefined
15
17
  })
@@ -19,4 +21,78 @@ describe("LeuButtonGroup", () => {
19
21
 
20
22
  await expect(el).shadowDom.to.be.accessible()
21
23
  })
24
+
25
+ it("has no value by default", async () => {
26
+ const el = await defaultFixture()
27
+
28
+ await expect(el.value).to.be.null
29
+ })
30
+
31
+ it("has the correct value after clicking a button", async () => {
32
+ const el = await defaultFixture()
33
+
34
+ const buttons = el.shadowRoot.querySelectorAll("leu-button")
35
+
36
+ buttons[1].click()
37
+ await expect(el.value).to.equal("Zwei")
38
+
39
+ buttons[0].click()
40
+ await expect(el.value).to.equal("Eins")
41
+
42
+ buttons[2].click()
43
+ await expect(el.value).to.equal("Drei")
44
+
45
+ // Should not change after clicking the same button again
46
+ buttons[2].click()
47
+ await expect(el.value).to.equal("Drei")
48
+ })
49
+
50
+ it("renders the active button as a primary button", async () => {
51
+ const el = await defaultFixture()
52
+ el.value = "Zwei"
53
+ await elementUpdated(el)
54
+
55
+ const buttons = el.shadowRoot.querySelectorAll("leu-button")
56
+
57
+ await expect(buttons[0].variant).to.equal("secondary")
58
+ await expect(buttons[1].variant).to.equal("primary")
59
+ await expect(buttons[2].variant).to.equal("secondary")
60
+
61
+ buttons[0].click()
62
+
63
+ await expect(buttons[0].variant).to.equal("secondary")
64
+ await expect(buttons[1].variant).to.equal("secondary")
65
+ await expect(buttons[2].variant).to.equal("secondary")
66
+ })
67
+
68
+ it("sets the correct aria-checked attribute", async () => {
69
+ const el = await defaultFixture()
70
+ el.value = "Drei"
71
+ await elementUpdated(el)
72
+
73
+ const buttons = el.shadowRoot.querySelectorAll("leu-button")
74
+
75
+ await expect(buttons[0].getAttribute("aria-checked")).to.equal("false")
76
+ await expect(buttons[1].getAttribute("aria-checked")).to.equal("false")
77
+ await expect(buttons[2].getAttribute("aria-checked")).to.equal("true")
78
+
79
+ buttons[0].click()
80
+ await expect(buttons[0].getAttribute("aria-checked")).to.equal("false")
81
+ await expect(buttons[1].getAttribute("aria-checked")).to.equal("false")
82
+ await expect(buttons[2].getAttribute("aria-checked")).to.equal("false")
83
+ })
84
+
85
+ it("dispatches an input event when the value changes", async () => {
86
+ const el = await defaultFixture()
87
+ el.value = "Drei"
88
+ await elementUpdated(el)
89
+
90
+ const buttons = el.shadowRoot.querySelectorAll("leu-button")
91
+
92
+ setTimeout(() => buttons[0].click())
93
+
94
+ const inputEvent = await oneEvent(el, "input")
95
+
96
+ await expect(inputEvent.detail.value).to.be.equal("Eins")
97
+ })
22
98
  })
@@ -1,89 +1,13 @@
1
- import { html, css, LitElement } from "lit"
1
+ import { html, LitElement } from "lit"
2
2
  import { Icon } from "../icon/icon.js"
3
- import { defineElement } from "../../lib/defineElement.js"
3
+
4
+ import styles from "./checkbox.css"
4
5
 
5
6
  /**
6
7
  * @tagname leu-checkbox
7
8
  */
8
9
  export class LeuCheckbox extends LitElement {
9
- static styles = css`
10
- :host {
11
- --checkbox-color: var(--leu-color-black-40);
12
- --checkbox-color-disabled: var(--leu-color-black-20);
13
- --checkbox-color-focus: var(--leu-color-func-cyan);
14
-
15
- --checkbox-label-color: var(--leu-color-black-100);
16
- --checkbox-label-color-disabled: var(--checkbox-color-disabled);
17
-
18
- --checkbox-tick-color: var(--leu-color-black-0);
19
-
20
- --checkbox-font-regular: var(--leu-font-regular);
21
-
22
- position: relative;
23
-
24
- display: inline-flex;
25
- align-items: flex-start;
26
- gap: 0.5rem;
27
-
28
- font-family: var(--checkbox-font-regular);
29
- }
30
-
31
- .checkbox {
32
- --_length: 1.5rem;
33
- appearance: none;
34
- cursor: pointer;
35
-
36
- width: var(--_length);
37
- height: var(--_length);
38
- margin: 0;
39
-
40
- border: 2px solid var(--checkbox-color);
41
- border-radius: 2px;
42
-
43
- flex: 1 0 var(--_length);
44
-
45
- display: grid;
46
- place-items: center;
47
- }
48
-
49
- .checkbox:checked {
50
- background-color: var(--checkbox-color);
51
- }
52
-
53
- .checkbox:is(:hover, :checked, :focus) {
54
- --checkbox-color: var(--checkbox-color-focus);
55
- }
56
-
57
- .checkbox:focus-visible {
58
- outline: 2px solid var(--checkbox-color-focus);
59
- outline-offset: 2px;
60
- }
61
-
62
- .checkbox:disabled {
63
- --checkbox-color: var(--checkbox-color-disabled);
64
- cursor: not-allowed;
65
- }
66
-
67
- .label {
68
- cursor: pointer;
69
- color: var(--checkbox-label-color);
70
- font-size: 1rem;
71
- line-height: 1.5;
72
- }
73
-
74
- .checkbox:disabled + .label {
75
- --checkbox-label-color: var(--checkbox-label-color-disabled);
76
- cursor: not-allowed;
77
- }
78
-
79
- .icon {
80
- position: absolute;
81
- top: 0;
82
- left: 0;
83
- color: var(--checkbox-tick-color);
84
- pointer-events: none;
85
- }
86
- `
10
+ static styles = styles
87
11
 
88
12
  static shadowRootOptions = {
89
13
  ...LitElement.shadowRootOptions,
@@ -93,16 +17,16 @@ export class LeuCheckbox extends LitElement {
93
17
  static properties = {
94
18
  checked: { type: Boolean, reflect: true },
95
19
  disabled: { type: Boolean, reflect: true },
96
- identifier: { type: String },
97
- value: { type: String },
98
- name: { type: String },
20
+ identifier: { type: String, reflect: true },
21
+ value: { type: String, reflect: true },
22
+ name: { type: String, reflect: true },
23
+ label: { type: String, reflect: true },
99
24
  }
100
25
 
101
26
  constructor() {
102
27
  super()
103
28
  this.checked = false
104
29
  this.disabled = false
105
- this.tabIndex = 0
106
30
 
107
31
  this.checkIcon = Icon("check")
108
32
  }
@@ -131,12 +55,8 @@ export class LeuCheckbox extends LitElement {
131
55
  ?disabled=${this.disabled}
132
56
  .value=${this.value}
133
57
  />
134
- <label for=${this.identifier} class="label"><slot></slot></label>
58
+ <label for=${this.identifier} class="label">${this.label}</label>
135
59
  <div class="icon">${this.checkIcon}</div>
136
60
  `
137
61
  }
138
62
  }
139
-
140
- export function defineCheckboxElements() {
141
- defineElement("checkbox", LeuCheckbox)
142
- }
@@ -1,45 +1,17 @@
1
- import { html, css, LitElement } from "lit"
1
+ import { html, LitElement } from "lit"
2
2
  import { classMap } from "lit/directives/class-map.js"
3
- import { defineElement } from "../../lib/defineElement.js"
3
+
4
+ import styles from "./checkbox-group.css"
4
5
 
5
6
  /**
6
7
  * @tagname leu-checkbox-group
7
8
  */
8
9
  export class LeuCheckboxGroup extends LitElement {
9
- static styles = css`
10
- :host {
11
- --group-font-regular: var(--leu-font-regular);
12
- --group-font-black: var(--leu-font-black);
13
-
14
- font-family: var(--group-font-regular);
15
- }
16
-
17
- .fieldset {
18
- display: flex;
19
- align-items: flex-start;
20
- flex-wrap: wrap;
21
- gap: 0.5rem 1rem;
22
-
23
- border: none;
24
- padding: 0;
25
- }
26
-
27
- .fieldset--vertical {
28
- flex-direction: column;
29
- gap: 1rem;
30
- }
31
-
32
- .legend {
33
- font-family: var(--group-font-black);
34
- font-size: 1.125rem;
35
- line-height: 1.5;
36
-
37
- margin-bottom: 0.5rem;
38
- }
39
- `
10
+ static styles = styles
40
11
 
41
12
  static properties = {
42
- orientation: { type: String },
13
+ orientation: { type: String, reflect: true },
14
+ label: { type: String, reflect: true },
43
15
  }
44
16
 
45
17
  constructor() {
@@ -68,13 +40,11 @@ export class LeuCheckboxGroup extends LitElement {
68
40
 
69
41
  return html`
70
42
  <fieldset class=${classMap(fieldsetClasses)}>
71
- <legend class="legend"><slot name="legend"></slot></legend>
43
+ ${this.label
44
+ ? html`<legend class="legend">${this.label}</legend>`
45
+ : html``}
72
46
  <slot @slotchange=${this.handleSlotChange}></slot>
73
47
  </fieldset>
74
48
  `
75
49
  }
76
50
  }
77
-
78
- export function defineCheckboxGroupElements() {
79
- defineElement("checkbox-group", LeuCheckboxGroup)
80
- }
@@ -0,0 +1,29 @@
1
+ :host {
2
+ --group-font-regular: var(--leu-font-regular);
3
+ --group-font-black: var(--leu-font-black);
4
+
5
+ font-family: var(--group-font-regular);
6
+ }
7
+
8
+ .fieldset {
9
+ display: flex;
10
+ align-items: flex-start;
11
+ flex-wrap: wrap;
12
+ gap: 0.5rem 1rem;
13
+
14
+ border: none;
15
+ padding: 0;
16
+ }
17
+
18
+ .fieldset--vertical {
19
+ flex-direction: column;
20
+ gap: 1rem;
21
+ }
22
+
23
+ .legend {
24
+ font-family: var(--group-font-black);
25
+ font-size: 1.125rem;
26
+ line-height: 1.5;
27
+
28
+ margin-bottom: 0.5rem;
29
+ }
@@ -0,0 +1,76 @@
1
+ :host {
2
+ --checkbox-color: var(--leu-color-black-40);
3
+ --checkbox-color-disabled: var(--leu-color-black-20);
4
+ --checkbox-color-focus: var(--leu-color-func-cyan);
5
+
6
+ --checkbox-label-color: var(--leu-color-black-100);
7
+ --checkbox-label-color-disabled: var(--checkbox-color-disabled);
8
+
9
+ --checkbox-tick-color: var(--leu-color-black-0);
10
+
11
+ --checkbox-font-regular: var(--leu-font-regular);
12
+
13
+ position: relative;
14
+
15
+ display: inline-flex;
16
+ align-items: flex-start;
17
+ gap: 0.5rem;
18
+
19
+ font-family: var(--checkbox-font-regular);
20
+ }
21
+
22
+ .checkbox {
23
+ --_length: 1.5rem;
24
+ appearance: none;
25
+ cursor: pointer;
26
+
27
+ width: var(--_length);
28
+ height: var(--_length);
29
+ margin: 0;
30
+
31
+ border: 2px solid var(--checkbox-color);
32
+ border-radius: 2px;
33
+
34
+ flex: 1 0 var(--_length);
35
+
36
+ display: grid;
37
+ place-items: center;
38
+ }
39
+
40
+ .checkbox:checked {
41
+ background-color: var(--checkbox-color);
42
+ }
43
+
44
+ .checkbox:is(:hover, :checked, :focus) {
45
+ --checkbox-color: var(--checkbox-color-focus);
46
+ }
47
+
48
+ .checkbox:focus-visible {
49
+ outline: 2px solid var(--checkbox-color-focus);
50
+ outline-offset: 2px;
51
+ }
52
+
53
+ .checkbox:disabled {
54
+ --checkbox-color: var(--checkbox-color-disabled);
55
+ cursor: not-allowed;
56
+ }
57
+
58
+ .label {
59
+ cursor: pointer;
60
+ color: var(--checkbox-label-color);
61
+ font-size: 1rem;
62
+ line-height: 1.5;
63
+ }
64
+
65
+ .checkbox:disabled + .label {
66
+ --checkbox-label-color: var(--checkbox-label-color-disabled);
67
+ cursor: not-allowed;
68
+ }
69
+
70
+ .icon {
71
+ position: absolute;
72
+ top: 0;
73
+ left: 0;
74
+ color: var(--checkbox-tick-color);
75
+ pointer-events: none;
76
+ }
@@ -1,3 +1,6 @@
1
- import { defineCheckboxGroupElements } from "./CheckboxGroup.js"
1
+ import { defineElement } from "../../lib/defineElement.js"
2
+ import { LeuCheckboxGroup } from "./CheckboxGroup.js"
2
3
 
3
- defineCheckboxGroupElements()
4
+ export { LeuCheckboxGroup }
5
+
6
+ defineElement("checkbox-group", LeuCheckboxGroup)
@@ -1,3 +1,6 @@
1
- import { defineCheckboxElements } from "./Checkbox.js"
1
+ import { defineElement } from "../../lib/defineElement.js"
2
+ import { LeuCheckbox } from "./Checkbox.js"
2
3
 
3
- defineCheckboxElements()
4
+ export { LeuCheckbox }
5
+
6
+ defineElement("checkbox", LeuCheckbox)
@@ -1,6 +1,7 @@
1
1
  import { html } from "lit"
2
2
  import "../leu-checkbox.js"
3
3
  import "../leu-checkbox-group.js"
4
+ import { ifDefined } from "lit/directives/if-defined.js"
4
5
 
5
6
  export default {
6
7
  title: "Checkbox/Group",
@@ -12,32 +13,54 @@ export default {
12
13
  control: { type: "checkbox" },
13
14
  },
14
15
  },
16
+ parameters: {
17
+ design: {
18
+ type: "figma",
19
+ url: "https://www.figma.com/file/d6Pv21UVUbnBs3AdcZijHmbN/KTZH-Design-System?type=design&node-id=17340-81935&mode=design&t=lzVrtq8lxYVJU5TB-11",
20
+ },
21
+ },
15
22
  }
16
23
 
17
- function Template({ legend, orientation }) {
24
+ function Template({ label, orientation }) {
18
25
  return html`
19
- <leu-checkbox-group orientation=${orientation}>
20
- <span slot="legend">${legend}</span>
21
- <leu-checkbox identifier="1" value="1" name="checkbox-button" disabled
22
- >Kurz</leu-checkbox
23
- >
24
- <leu-checkbox identifier="2" value="2" name="checkbox-button"
25
- >Etwas Länger</leu-checkbox
26
- >
27
- <leu-checkbox identifier="3" value="3" name="checkbox-button" disabled
28
- >Deaktiviert dazwischen</leu-checkbox
29
- >
30
- <leu-checkbox identifier="4" value="4" name="checkbox-button"
31
- >Ein langes Label um sicher ein umbruch zu erzwingen</leu-checkbox
32
- >
26
+ <leu-checkbox-group
27
+ orientation=${ifDefined(orientation)}
28
+ label=${ifDefined(label)}
29
+ >
30
+ <leu-checkbox
31
+ identifier="1"
32
+ value="1"
33
+ name="checkbox-button"
34
+ label="Kurz"
35
+ disabled
36
+ ></leu-checkbox>
37
+ <leu-checkbox
38
+ identifier="2"
39
+ value="2"
40
+ name="checkbox-button"
41
+ label="Etwas Länger"
42
+ ></leu-checkbox>
43
+ <leu-checkbox
44
+ identifier="3"
45
+ value="3"
46
+ name="checkbox-button"
47
+ disabled
48
+ label="Deaktiviert dazwischen"
49
+ ></leu-checkbox>
50
+ <leu-checkbox
51
+ identifier="4"
52
+ value="4"
53
+ name="checkbox-button"
54
+ label="Ein langes Label um sicher ein umbruch zu erzwingen"
55
+ ></leu-checkbox>
33
56
  </leu-checkbox-group>
34
57
  `
35
58
  }
36
59
 
37
60
  export const Horizontal = Template.bind({})
38
- export const HorizontalLegend = Template.bind({})
39
- HorizontalLegend.args = {
40
- legend: "Anrede",
61
+ export const HorizontalLabel = Template.bind({})
62
+ HorizontalLabel.args = {
63
+ label: "Anrede",
41
64
  }
42
65
 
43
66
  export const Vertical = Template.bind({})
@@ -45,8 +68,8 @@ Vertical.args = {
45
68
  orientation: "VERTICAL",
46
69
  }
47
70
 
48
- export const VerticalLegend = Template.bind({})
49
- VerticalLegend.args = {
71
+ export const VerticalLabel = Template.bind({})
72
+ VerticalLabel.args = {
50
73
  orientation: "VERTICAL",
51
- legend: "Anrede",
74
+ label: "Anrede",
52
75
  }
@@ -9,6 +9,12 @@ export default {
9
9
  control: "text",
10
10
  },
11
11
  },
12
+ parameters: {
13
+ design: {
14
+ type: "figma",
15
+ url: "https://www.figma.com/file/d6Pv21UVUbnBs3AdcZijHmbN/KTZH-Design-System?type=design&node-id=17340-81935&mode=design&t=lzVrtq8lxYVJU5TB-11",
16
+ },
17
+ },
12
18
  }
13
19
 
14
20
  function Template({ label = "Label", value, checked, disabled }) {
@@ -17,9 +23,9 @@ function Template({ label = "Label", value, checked, disabled }) {
17
23
  .value=${value}
18
24
  ?checked=${checked}
19
25
  ?disabled=${disabled}
26
+ label=${label}
20
27
  identifier="checkbox-1"
21
28
  >
22
- ${label}
23
29
  </leu-checkbox>
24
30
  `
25
31
  }