@statistikzh/leu 0.0.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.
Files changed (141) hide show
  1. package/.editorconfig +29 -0
  2. package/.eslintrc.json +27 -0
  3. package/.github/workflows/publish.yml +19 -0
  4. package/.github/workflows/release-please.yml +19 -0
  5. package/.github/workflows/test.yml +38 -0
  6. package/.husky/commit-msg +4 -0
  7. package/.husky/pre-commit +4 -0
  8. package/.prettierignore +1 -0
  9. package/.storybook/main.js +11 -0
  10. package/.storybook/preview-head.html +5 -0
  11. package/.storybook/preview.js +23 -0
  12. package/CHANGELOG.md +63 -0
  13. package/CODE_OF_CONDUCT.md +128 -0
  14. package/CONTRIBUTING.md +31 -0
  15. package/LICENSE +21 -0
  16. package/README.md +170 -0
  17. package/commitlint.config.cjs +1 -0
  18. package/dist/Button-83c6df93.js +403 -0
  19. package/dist/Checkbox.js +144 -0
  20. package/dist/CheckboxGroup.js +82 -0
  21. package/dist/Chip-60af1402.js +162 -0
  22. package/dist/ChipGroup.js +79 -0
  23. package/dist/ChipLink.js +46 -0
  24. package/dist/ChipRemovable.js +43 -0
  25. package/dist/ChipSelectable.js +92 -0
  26. package/dist/Input.js +686 -0
  27. package/dist/Radio.js +156 -0
  28. package/dist/RadioGroup.js +194 -0
  29. package/dist/Select.js +859 -0
  30. package/dist/Table-72d305d7.js +506 -0
  31. package/dist/Table.js +8 -0
  32. package/dist/defineElement-47d4f665.js +15 -0
  33. package/dist/icon-b68c7e1e.js +202 -0
  34. package/dist/index.js +21 -0
  35. package/dist/leu-checkbox-group.js +6 -0
  36. package/dist/leu-checkbox.js +6 -0
  37. package/dist/leu-chip-group.js +5 -0
  38. package/dist/leu-chip-link.js +6 -0
  39. package/dist/leu-chip-removable.js +7 -0
  40. package/dist/leu-chip-selectable.js +6 -0
  41. package/dist/leu-input.js +9 -0
  42. package/dist/leu-radio-group.js +6 -0
  43. package/dist/leu-radio.js +5 -0
  44. package/dist/leu-select.js +12 -0
  45. package/dist/leu-table.js +10 -0
  46. package/dist/theme.css +51 -0
  47. package/index.js +10 -0
  48. package/package.json +85 -0
  49. package/postcss.config.cjs +14 -0
  50. package/rollup.config.js +54 -0
  51. package/scripts/generate-component/generate.js +167 -0
  52. package/scripts/generate-component/templates/[Name].js +33 -0
  53. package/scripts/generate-component/templates/[name].css +11 -0
  54. package/scripts/generate-component/templates/[namespace]-[name].js +3 -0
  55. package/scripts/generate-component/templates/stories/[name].stories.js +13 -0
  56. package/scripts/generate-component/templates/test/[name].test.js +22 -0
  57. package/src/components/button/Button.js +150 -0
  58. package/src/components/button/button.css +232 -0
  59. package/src/components/button/leu-button.js +3 -0
  60. package/src/components/button/stories/button.stories.js +333 -0
  61. package/src/components/button/test/button.test.js +22 -0
  62. package/src/components/button-group/ButtonGroup.js +63 -0
  63. package/src/components/button-group/button-group.css +10 -0
  64. package/src/components/button-group/leu-button-group.js +3 -0
  65. package/src/components/button-group/stories/button-group.stories.js +41 -0
  66. package/src/components/button-group/test/button-group.test.js +22 -0
  67. package/src/components/checkbox/Checkbox.js +142 -0
  68. package/src/components/checkbox/CheckboxGroup.js +80 -0
  69. package/src/components/checkbox/leu-checkbox-group.js +3 -0
  70. package/src/components/checkbox/leu-checkbox.js +3 -0
  71. package/src/components/checkbox/stories/checkbox-group.stories.js +52 -0
  72. package/src/components/checkbox/stories/checkbox.stories.js +43 -0
  73. package/src/components/checkbox/test/checkbox.test.js +101 -0
  74. package/src/components/chip/Chip.js +24 -0
  75. package/src/components/chip/ChipGroup.js +71 -0
  76. package/src/components/chip/ChipLink.js +45 -0
  77. package/src/components/chip/ChipRemovable.js +42 -0
  78. package/src/components/chip/ChipSelectable.js +91 -0
  79. package/src/components/chip/chip-group.css +5 -0
  80. package/src/components/chip/chip.css +130 -0
  81. package/src/components/chip/exports.js +10 -0
  82. package/src/components/chip/leu-chip-group.js +3 -0
  83. package/src/components/chip/leu-chip-link.js +3 -0
  84. package/src/components/chip/leu-chip-removable.js +3 -0
  85. package/src/components/chip/leu-chip-selectable.js +3 -0
  86. package/src/components/chip/stories/chip-group.stories.js +99 -0
  87. package/src/components/chip/stories/chip-link.stories.js +37 -0
  88. package/src/components/chip/stories/chip-removable.stories.js +28 -0
  89. package/src/components/chip/stories/chip-selectable.stories.js +46 -0
  90. package/src/components/chip/test/chip.test.js +22 -0
  91. package/src/components/dropdown/Dropdown.js +55 -0
  92. package/src/components/dropdown/dropdown.css +17 -0
  93. package/src/components/dropdown/leu-dropdown.js +3 -0
  94. package/src/components/dropdown/stories/dropdown.stories.js +25 -0
  95. package/src/components/dropdown/test/dropdown.test.js +31 -0
  96. package/src/components/icon/icon.js +201 -0
  97. package/src/components/input/Input.js +421 -0
  98. package/src/components/input/input.css +231 -0
  99. package/src/components/input/leu-input.js +3 -0
  100. package/src/components/input/stories/input.stories.js +185 -0
  101. package/src/components/input/test/input.test.js +22 -0
  102. package/src/components/menu/Menu.js +18 -0
  103. package/src/components/menu/MenuItem.js +95 -0
  104. package/src/components/menu/leu-menu-item.js +3 -0
  105. package/src/components/menu/leu-menu.js +3 -0
  106. package/src/components/menu/menu-item.css +72 -0
  107. package/src/components/menu/menu.css +14 -0
  108. package/src/components/menu/stories/menu-item.stories.js +51 -0
  109. package/src/components/menu/stories/menu.stories.js +21 -0
  110. package/src/components/menu/test/menu.test.js +22 -0
  111. package/src/components/pagination/Pagination.js +152 -0
  112. package/src/components/pagination/leu-pagination.js +3 -0
  113. package/src/components/pagination/pagination.css +49 -0
  114. package/src/components/pagination/stories/pagination.stories.js +82 -0
  115. package/src/components/pagination/test/pagination.test.js +22 -0
  116. package/src/components/radio/Radio.js +62 -0
  117. package/src/components/radio/RadioGroup.js +193 -0
  118. package/src/components/radio/leu-radio-group.js +3 -0
  119. package/src/components/radio/leu-radio.js +3 -0
  120. package/src/components/radio/radio.css +76 -0
  121. package/src/components/radio/stories/radio-group.stories.js +49 -0
  122. package/src/components/radio/stories/radio.stories.js +48 -0
  123. package/src/components/radio/test/radio.test.js +38 -0
  124. package/src/components/select/Select.js +350 -0
  125. package/src/components/select/leu-select.js +3 -0
  126. package/src/components/select/select.css +215 -0
  127. package/src/components/select/stories/select.stories.js +302 -0
  128. package/src/components/select/test/select.test.js +29 -0
  129. package/src/components/table/Table.js +301 -0
  130. package/src/components/table/leu-table.js +3 -0
  131. package/src/components/table/stories/table.stories.js +116 -0
  132. package/src/components/table/test/table.test.js +36 -0
  133. package/src/lib/defineElement.js +13 -0
  134. package/src/lib/hasSlotController.js +85 -0
  135. package/src/styles/custom-media.css +5 -0
  136. package/src/styles/custom-properties.css +51 -0
  137. package/src/styles/theme.css +1 -0
  138. package/stat_zh.png +0 -0
  139. package/stylelint.config.mjs +21 -0
  140. package/web-dev-server-storybook.config.mjs +19 -0
  141. package/web-test-runner.config.mjs +49 -0
@@ -0,0 +1,49 @@
1
+ :host {
2
+ margin-top: 16px;
3
+ display: flex;
4
+ justify-content: end;
5
+ font-family: var(--leu-font-regular);
6
+ }
7
+
8
+ .input {
9
+ width: 50px;
10
+ padding: 0;
11
+ border: 2px solid var(--leu-color-black-40);
12
+ border-radius: 2px;
13
+ color: var(--leu-color-black-transp-60);
14
+ text-align: center;
15
+ font-size: 16px;
16
+ font-style: normal;
17
+ font-weight: 400;
18
+ line-height: 24px;
19
+ outline-offset: 2px;
20
+ }
21
+
22
+ /* no arrows: Chrome, Safari, Edge, Opera */
23
+ .input::-webkit-outer-spin-button,
24
+ .input::-webkit-inner-spin-button {
25
+ appearance: none;
26
+ margin: 0;
27
+ }
28
+
29
+ /* no arrows: Firefox */
30
+ .input[type="number"] {
31
+ appearance: textfield;
32
+ }
33
+
34
+ .input:focus,
35
+ .input:hover {
36
+ border-color: var(--leu-color-func-cyan);
37
+ outline: none;
38
+ }
39
+
40
+ .input:focus-visible {
41
+ outline: 2px solid var(--leu-color-func-cyan);
42
+ }
43
+
44
+ .label {
45
+ margin: 0 16px;
46
+ line-height: 50px;
47
+ color: var(--leu-color-black-transp-60);
48
+ white-space: nowrap;
49
+ }
@@ -0,0 +1,82 @@
1
+ import { html } from "lit"
2
+ import "../leu-pagination.js"
3
+
4
+ // https://stackoverflow.com/questions/72566428/storybook-angular-how-to-dynamically-update-args-from-the-template
5
+ import { UPDATE_STORY_ARGS } from "@storybook/core-events" // eslint-disable-line
6
+ function updateStorybookArgss(id, args) {
7
+ const channel = window.__STORYBOOK_ADDONS_CHANNEL__
8
+ channel.emit(UPDATE_STORY_ARGS, {
9
+ storyId: id,
10
+ updatedArgs: args,
11
+ })
12
+ }
13
+
14
+ const items = [
15
+ { id: 1, label: "Ananas", value: 7 },
16
+ { id: 2, label: "Apfel", value: 12 },
17
+ { id: 3, label: "Aprikose", value: 3 },
18
+ { id: 4, label: "Banare", value: 11 },
19
+ { id: 5, label: "Birne", value: 10 },
20
+ { id: 6, label: "Brombeere", value: 5 },
21
+ { id: 7, label: "Cranberries", value: 3 },
22
+ { id: 8, label: "Datteln", value: 2 },
23
+ { id: 9, label: "Erdbeere", value: 0 },
24
+ { id: 10, label: "Feige", value: 11 },
25
+ { id: 11, label: "Granatapfel", value: 14 },
26
+ { id: 12, label: "Grapefruit", value: 7 },
27
+ { id: 13, label: "Heidelbeere", value: 12 },
28
+ { id: 14, label: "Himbeere", value: 3 },
29
+ { id: 15, label: "Johannisbeere", value: 11 },
30
+ { id: 16, label: "Kirsche", value: 10 },
31
+ { id: 17, label: "Kiwi", value: 5 },
32
+ { id: 18, label: "Limette", value: 3 },
33
+ { id: 19, label: "Litschi", value: 2 },
34
+ { id: 20, label: "Mandarine", value: 0 },
35
+ { id: 21, label: "Mango", value: 11 },
36
+ { id: 22, label: "Melone", value: 14 },
37
+ { id: 23, label: "Mirabelle", value: 14 },
38
+ { id: 24, label: "Nashi", value: 12 },
39
+ { id: 25, label: "Orange", value: 3 },
40
+ { id: 26, label: "Papaya", value: 6 },
41
+ { id: 27, label: "Pfirsich", value: 5 },
42
+ { id: 28, label: "Pflaume", value: 17 },
43
+ { id: 29, label: "Physalis", value: 1 },
44
+ { id: 30, label: "Preiselbeere", value: 19 },
45
+ { id: 31, label: "Pomelo", value: 12 },
46
+ { id: 32, label: "Quitte", value: 0 },
47
+ { id: 33, label: "Rhabarber", value: 1 },
48
+ { id: 34, label: "Sanddorn", value: 2 },
49
+ { id: 35, label: "Stachelbeere", value: 19 },
50
+ { id: 36, label: "Ugli", value: 9 },
51
+ { id: 37, label: "Weintraube", value: 11 },
52
+ { id: 38, label: "Zitrone", value: 4 },
53
+ { id: 39, label: "Zwetschge", value: 20 },
54
+ ]
55
+
56
+ export default {
57
+ title: "Pagination",
58
+ component: "leu-pagination",
59
+ }
60
+
61
+ function Template({ min, max }, { id }) {
62
+ return html`
63
+ ${items.slice(min, max).map((item) => html`<div>${item.label}</div>`)}
64
+ <leu-pagination
65
+ dataLength=${items.length}
66
+ itemsOnAPage="5"
67
+ @range-updated=${(e) => {
68
+ updateStorybookArgss(id, {
69
+ min: e.detail.min,
70
+ max: e.detail.max,
71
+ })
72
+ }}
73
+ >
74
+ </leu-pagination>
75
+ `
76
+ }
77
+
78
+ export const Regular = Template.bind({})
79
+ Regular.args = {
80
+ min: 0,
81
+ max: 5,
82
+ }
@@ -0,0 +1,22 @@
1
+ import { html } from "lit"
2
+ import { fixture, expect } from "@open-wc/testing"
3
+
4
+ import "../leu-pagination.js"
5
+
6
+ async function defaultFixture() {
7
+ return fixture(html` <leu-pagination></leu-button>`)
8
+ }
9
+
10
+ describe("LeuPagination", () => {
11
+ it("is a defined element", async () => {
12
+ const el = await customElements.get("leu-pagination")
13
+
14
+ await expect(el).not.to.be.undefined
15
+ })
16
+
17
+ it("passes the a11y audit", async () => {
18
+ const el = await defaultFixture()
19
+
20
+ await expect(el).shadowDom.to.be.accessible()
21
+ })
22
+ })
@@ -0,0 +1,62 @@
1
+ import { html, LitElement } from "lit"
2
+ import { defineElement } from "../../lib/defineElement.js"
3
+ import styles from "./radio.css"
4
+
5
+ /**
6
+ * @tagname leu-radio
7
+ */
8
+ export class LeuRadio extends LitElement {
9
+ static styles = styles
10
+
11
+ static shadowRootOptions = {
12
+ ...LitElement.shadowRootOptions,
13
+ delegatesFocus: true,
14
+ }
15
+
16
+ static properties = {
17
+ checked: { type: Boolean, reflect: true },
18
+ disabled: { type: Boolean, reflect: true },
19
+ identifier: { type: String },
20
+ value: { type: String },
21
+ name: { type: String },
22
+ }
23
+
24
+ constructor() {
25
+ super()
26
+ this.checked = false
27
+ this.disabled = false
28
+ this.tabIndex = 0
29
+ }
30
+
31
+ handleChange(event) {
32
+ this.checked = event.target.checked
33
+
34
+ const customEvent = new CustomEvent(event.type, event)
35
+ this.dispatchEvent(customEvent)
36
+ }
37
+
38
+ handleInput(event) {
39
+ this.checked = event.target.checked
40
+ }
41
+
42
+ render() {
43
+ return html`
44
+ <input
45
+ id=${this.identifier}
46
+ class="radio"
47
+ type="radio"
48
+ name="${this.name}"
49
+ @change=${this.handleChange}
50
+ @input=${this.handleInput}
51
+ .checked=${this.checked}
52
+ ?disabled=${this.disabled}
53
+ .value=${this.value}
54
+ />
55
+ <label for=${this.identifier} class="label"><slot></slot></label>
56
+ `
57
+ }
58
+ }
59
+
60
+ export function defineRadioElements() {
61
+ defineElement("radio", LeuRadio)
62
+ }
@@ -0,0 +1,193 @@
1
+ import { html, css, LitElement } from "lit"
2
+ import { classMap } from "lit/directives/class-map.js"
3
+ import { defineElement } from "../../lib/defineElement.js"
4
+
5
+ /**
6
+ * @tagname leu-radio-group
7
+ */
8
+ export class LeuRadioGroup 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
+ `
40
+
41
+ static properties = {
42
+ orientation: { type: String },
43
+ }
44
+
45
+ constructor() {
46
+ super()
47
+ this.orientation = "HORIZONTAL"
48
+ this._currentIndex = 0
49
+ this.items = []
50
+ }
51
+
52
+ get value() {
53
+ const checkedValues = this.items
54
+ .filter((i) => i.checked)
55
+ .map((i) => i.value)
56
+ return checkedValues.length > 0 ? checkedValues[0] : ""
57
+ }
58
+
59
+ connectedCallback() {
60
+ super.connectedCallback()
61
+ this.handleItems()
62
+ this.addEventListeners()
63
+ }
64
+
65
+ disconnectedCallback() {
66
+ super.disconnectedCallback()
67
+ this.removeEventListeners()
68
+ }
69
+
70
+ addEventListeners() {
71
+ this.addEventListener("input", this.handleInput)
72
+ this.addEventListener("focusin", this.handleFocusIn)
73
+ this.addEventListener("keydown", this.handleKeyDown)
74
+ }
75
+
76
+ removeEventListeners() {
77
+ this.removeEventListener("input", this.handleInput)
78
+ this.removeEventListener("focusin", this.handleFocusIn)
79
+ this.removeEventListener("keydown", this.handleKeyDown)
80
+ }
81
+
82
+ handleSlotChange() {
83
+ this.handleItems()
84
+ }
85
+
86
+ handleFocusIn = (e) => {
87
+ this._currentIndex = this.items.indexOf(e.target)
88
+ }
89
+
90
+ handleKeyDown = (e) => {
91
+ const currentIndex = this.items.indexOf(e.target)
92
+
93
+ switch (e.key) {
94
+ case "ArrowUp":
95
+ case "ArrowLeft":
96
+ this.selectNextItem(currentIndex, -1)
97
+ break
98
+ case "ArrowDown":
99
+ case "ArrowRight":
100
+ this.selectNextItem(currentIndex, 1)
101
+ break
102
+ case "Home":
103
+ this.selectItem(this.items.find((item) => !item.disabled))
104
+ break
105
+ case "End":
106
+ this.selectItem(this.items.findLast((item) => !item.disabled))
107
+ break
108
+ default:
109
+ }
110
+
111
+ this.setTabIndex()
112
+ }
113
+
114
+ handleInput = (e) => {
115
+ if (e.target.checked) {
116
+ this.items
117
+ .filter((item) => item !== e.target)
118
+ .forEach((item) => {
119
+ item.checked = false // eslint-disable-line no-param-reassign
120
+ })
121
+ }
122
+ }
123
+
124
+ selectItem(selectingItem) {
125
+ this.items.forEach((item) => {
126
+ item.checked = item === selectingItem // eslint-disable-line no-param-reassign
127
+ })
128
+ }
129
+
130
+ selectNextItem(startingIndex, direction) {
131
+ let selected = false
132
+
133
+ for (let index = 0; index < this.items.length; index += 1) {
134
+ const currentIndex =
135
+ (this.items.length + index * direction + startingIndex + direction) %
136
+ this.items.length
137
+ const currentItem = this.items[currentIndex]
138
+
139
+ if (!selected && !currentItem.disabled) {
140
+ currentItem.checked = true
141
+ currentItem.focus()
142
+ selected = true
143
+ } else if (selected) {
144
+ currentItem.checked = false
145
+ }
146
+ }
147
+ }
148
+
149
+ setTabIndex() {
150
+ this.items.forEach((item, index) => {
151
+ if (index === this._currentIndex) {
152
+ item.tabIndex = "0" // eslint-disable-line no-param-reassign
153
+ } else {
154
+ item.tabIndex = "-1" // eslint-disable-line no-param-reassign
155
+ }
156
+ })
157
+ }
158
+
159
+ handleItems() {
160
+ this.items = [...this.querySelectorAll(":scope > *:not([slot])")]
161
+ this.initializeIndex()
162
+ this.setTabIndex()
163
+ }
164
+
165
+ initializeIndex() {
166
+ const index = this.items.findIndex(
167
+ (item) => item.hasAttribute("checked") && !item.hasAttribute("disabled")
168
+ )
169
+ const nextEnabledIndex = this.items.findIndex(
170
+ (item) => !item.hasAttribute("disabled")
171
+ )
172
+
173
+ this._currentIndex = index >= 0 ? index : nextEnabledIndex
174
+ }
175
+
176
+ render() {
177
+ const fieldsetClasses = {
178
+ fieldset: "true",
179
+ "fieldset--vertical": this.orientation === "VERTICAL",
180
+ }
181
+
182
+ return html`
183
+ <fieldset class=${classMap(fieldsetClasses)}>
184
+ <legend class="legend"><slot name="legend"></slot></legend>
185
+ <slot @slotchange=${this.handleSlotChange}></slot>
186
+ </fieldset>
187
+ `
188
+ }
189
+ }
190
+
191
+ export function defineRadioGroupElements() {
192
+ defineElement("radio-group", LeuRadioGroup)
193
+ }
@@ -0,0 +1,3 @@
1
+ import { defineRadioGroupElements } from "./RadioGroup.js"
2
+
3
+ defineRadioGroupElements()
@@ -0,0 +1,3 @@
1
+ import { defineRadioElements } from "./Radio.js"
2
+
3
+ defineRadioElements()
@@ -0,0 +1,76 @@
1
+ :host {
2
+ --radio-color: var(--leu-color-black-40);
3
+ --radio-color-disabled: var(--leu-color-black-20);
4
+ --radio-color-focus: var(--leu-color-func-cyan);
5
+
6
+ --radio-label-color: var(--leu-color-black-100);
7
+ --radio-label-color-disabled: var(--radio-color-disabled);
8
+
9
+ --radio-font-regular: var(--leu-font-regular);
10
+
11
+ display: inline-flex;
12
+ align-items: flex-start;
13
+ gap: 0.5rem;
14
+
15
+ font-family: var(--radio-font-regular);
16
+ }
17
+
18
+ .radio {
19
+ --_length: 1.5rem;
20
+ appearance: none;
21
+ cursor: pointer;
22
+
23
+ width: var(--_length);
24
+ height: var(--_length);
25
+ margin: 0;
26
+
27
+ border: 2px solid var(--radio-color);
28
+ border-radius: 50%;
29
+
30
+ flex: 1 0 var(--_length);
31
+
32
+ display: grid;
33
+ place-items: center;
34
+ }
35
+
36
+ .radio::before {
37
+ content: "";
38
+ width: 0.75rem;
39
+ height: 0.75rem;
40
+
41
+ border-radius: 50%;
42
+ background-color: var(--radio-color);
43
+
44
+ transform: scale(0);
45
+ }
46
+
47
+ .radio:checked::before {
48
+ transform: scale(1);
49
+ }
50
+
51
+ .radio:is(:hover, :checked, :focus) {
52
+ --radio-color: var(--radio-color-focus);
53
+ }
54
+
55
+ .radio:focus-visible {
56
+ outline: 2px solid var(--radio-color-focus);
57
+ outline-offset: 2px;
58
+ }
59
+
60
+ .radio:disabled {
61
+ --radio-color: var(--radio-color-disabled);
62
+ cursor: not-allowed;
63
+ }
64
+
65
+ .label {
66
+ cursor: pointer;
67
+
68
+ color: var(--radio-label-color);
69
+ font-size: 1rem;
70
+ line-height: 1.5;
71
+ }
72
+
73
+ .radio:disabled + .label {
74
+ --radio-label-color: var(--radio-label-color-disabled);
75
+ cursor: not-allowed;
76
+ }
@@ -0,0 +1,49 @@
1
+ import { html } from "lit"
2
+ import "../leu-radio.js"
3
+ import "../leu-radio-group.js"
4
+
5
+ export default {
6
+ title: "Radio/Group",
7
+ component: "leu-radio-group",
8
+ argTypes: {
9
+ legend: { control: "text" },
10
+ orientation: {
11
+ options: ["VERTICAL", "HORIZONTAL"],
12
+ control: { type: "radio" },
13
+ },
14
+ },
15
+ }
16
+
17
+ function Template({ legend, orientation }) {
18
+ return html`
19
+ <leu-radio-group orientation=${orientation}>
20
+ <span slot="legend">${legend}</span>
21
+ <leu-radio identifier="1" value="1" name="radio-button" disabled
22
+ >Kurz</leu-radio
23
+ >
24
+ <leu-radio identifier="2" value="2" name="radio-button"
25
+ >Etwas Länger</leu-radio
26
+ >
27
+ <leu-radio identifier="3" value="3" name="radio-button"
28
+ >Ein langes Label um sicher ein umbruch zu erzwingen</leu-radio
29
+ >
30
+ </leu-radio-group>
31
+ `
32
+ }
33
+
34
+ export const Horizontal = Template.bind({})
35
+ export const HorizontalLegend = Template.bind({})
36
+ HorizontalLegend.args = {
37
+ legend: "Anrede",
38
+ }
39
+
40
+ export const Vertical = Template.bind({})
41
+ Vertical.args = {
42
+ orientation: "VERTICAL",
43
+ }
44
+
45
+ export const VerticalLegend = Template.bind({})
46
+ VerticalLegend.args = {
47
+ orientation: "VERTICAL",
48
+ legend: "Anrede",
49
+ }
@@ -0,0 +1,48 @@
1
+ import { html } from "lit"
2
+ import "../leu-radio.js"
3
+
4
+ export default {
5
+ title: "Radio",
6
+ component: "leu-radio",
7
+ argTypes: {
8
+ label: {
9
+ control: "text",
10
+ },
11
+ },
12
+ }
13
+
14
+ function Template({
15
+ label = "Label",
16
+ value = "",
17
+ checked = false,
18
+ disabled = false,
19
+ }) {
20
+ return html`
21
+ <leu-radio
22
+ .value=${value}
23
+ ?checked=${checked}
24
+ ?disabled=${disabled}
25
+ identifier=${"radio-1"}
26
+ >
27
+ ${label}
28
+ </leu-radio>
29
+ `
30
+ }
31
+
32
+ export const Regular = Template.bind({})
33
+
34
+ export const Checked = Template.bind({})
35
+ Checked.args = {
36
+ checked: true,
37
+ }
38
+
39
+ export const Disabled = Template.bind({})
40
+ Disabled.args = {
41
+ disabled: true,
42
+ }
43
+
44
+ export const CheckedDisabled = Template.bind({})
45
+ CheckedDisabled.args = {
46
+ checked: true,
47
+ disabled: true,
48
+ }
@@ -0,0 +1,38 @@
1
+ import { html } from "lit"
2
+ import { fixture, expect } from "@open-wc/testing"
3
+
4
+ import "../leu-radio.js"
5
+ import "../leu-radio-group.js"
6
+
7
+ async function defaultFixture() {
8
+ return fixture(html`
9
+ <leu-radio-group>
10
+ <span slot="legend">Legende</span>
11
+ <leu-radio identifier="1" value="1" name="radio-button" disabled
12
+ >Kurz</leu-radio
13
+ >
14
+ <leu-radio identifier="2" value="2" name="radio-button"
15
+ >Etwas Länger</leu-radio
16
+ >
17
+ <leu-radio identifier="3" value="3" name="radio-button"
18
+ >Ein langes Label um sicher ein umbruch zu erzwingen</leu-radio
19
+ >
20
+ </leu-radio-group>
21
+ `)
22
+ }
23
+
24
+ describe("LeuRadio", () => {
25
+ it("is a defined element", async () => {
26
+ const elRadio = await customElements.get("leu-radio")
27
+ const elRadioGroup = await customElements.get("leu-radio-group")
28
+
29
+ await expect(elRadio).not.to.be.undefined
30
+ await expect(elRadioGroup).not.to.be.undefined
31
+ })
32
+
33
+ it("passes the a11y audit", async () => {
34
+ const el = await defaultFixture()
35
+
36
+ await expect(el).shadowDom.to.be.accessible()
37
+ })
38
+ })