@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.
- package/.github/workflows/deploy-github-pages.yaml +33 -0
- package/.storybook/main.js +27 -1
- package/.storybook/manager-head.html +1 -0
- package/.storybook/manager.js +9 -0
- package/.storybook/preview-head.html +1 -1
- package/.storybook/preview.js +59 -5
- package/.storybook/static/logo.svg +19 -0
- package/.storybook/theme.js +7 -0
- package/CHANGELOG.md +43 -0
- package/README.md +1 -1
- package/dist/Button.js +39 -30
- package/dist/ButtonGroup.js +5 -7
- package/dist/Checkbox.js +107 -88
- package/dist/CheckboxGroup.js +43 -38
- package/dist/{Chip-389013ff.js → Chip-dac7337d.js} +7 -2
- package/dist/ChipGroup.js +4 -6
- package/dist/ChipLink.js +6 -8
- package/dist/ChipRemovable.js +4 -7
- package/dist/ChipSelectable.js +10 -10
- package/dist/Dropdown.js +57 -27
- package/dist/Input.js +59 -43
- package/dist/Menu.js +2 -5
- package/dist/MenuItem.js +34 -17
- package/dist/Pagination.js +57 -55
- package/dist/Radio.js +13 -10
- package/dist/RadioGroup.js +43 -40
- package/dist/Select.js +57 -44
- package/dist/Table.js +147 -125
- package/dist/{defineElement-ba770aed.js → _rollupPluginBabelHelpers-20f659f4.js} +1 -15
- package/dist/defineElement-47d4f665.js +15 -0
- package/dist/index.js +29 -19
- package/dist/leu-button-group.js +7 -3
- package/dist/leu-button.js +6 -3
- package/dist/leu-checkbox-group.js +6 -3
- package/dist/leu-checkbox.js +6 -3
- package/dist/leu-chip-group.js +6 -3
- package/dist/leu-chip-link.js +7 -4
- package/dist/leu-chip-removable.js +7 -4
- package/dist/leu-chip-selectable.js +7 -4
- package/dist/leu-dropdown.js +13 -3
- package/dist/leu-input.js +7 -3
- package/dist/leu-menu-item.js +8 -3
- package/dist/leu-menu.js +6 -3
- package/dist/leu-pagination.js +8 -3
- package/dist/leu-popup-4bf6f1f4.js +216 -0
- package/dist/leu-radio-group.js +6 -3
- package/dist/leu-radio.js +6 -3
- package/dist/leu-select.js +14 -3
- package/dist/leu-table.js +9 -3
- package/package.json +29 -12
- package/scripts/generate-component/templates/[Name].js +0 -5
- package/scripts/generate-component/templates/[name].css +1 -1
- package/scripts/generate-component/templates/[namespace]-[name].js +5 -2
- package/src/components/accordion/Accordion.js +3 -9
- package/src/components/accordion/leu-accordion.js +5 -2
- package/src/components/accordion/stories/accordion.stories.js +7 -4
- package/src/components/accordion/test/accordion.test.js +92 -2
- package/src/components/breadcrumb/Breadcrumb.js +310 -0
- package/src/components/breadcrumb/breadcrumb.css +114 -0
- package/src/components/breadcrumb/leu-breadcrumb.js +6 -0
- package/src/components/breadcrumb/stories/breadcrumb.stories.js +73 -0
- package/src/components/breadcrumb/test/breadcrumb.test.js +141 -0
- package/src/components/button/Button.js +22 -27
- package/src/components/button/button.css +3 -3
- package/src/components/button/leu-button.js +5 -2
- package/src/components/button/stories/button.stories.js +58 -37
- package/src/components/button/test/button.test.js +112 -2
- package/src/components/button-group/ButtonGroup.js +1 -7
- package/src/components/button-group/leu-button-group.js +5 -2
- package/src/components/button-group/stories/button-group.stories.js +6 -0
- package/src/components/button-group/test/button-group.test.js +79 -3
- package/src/components/checkbox/Checkbox.js +9 -89
- package/src/components/checkbox/CheckboxGroup.js +9 -39
- package/src/components/checkbox/checkbox-group.css +29 -0
- package/src/components/checkbox/checkbox.css +76 -0
- package/src/components/checkbox/leu-checkbox-group.js +5 -2
- package/src/components/checkbox/leu-checkbox.js +5 -2
- package/src/components/checkbox/stories/checkbox-group.stories.js +44 -21
- package/src/components/checkbox/stories/checkbox.stories.js +7 -1
- package/src/components/checkbox/test/checkbox-group.test.js +124 -0
- package/src/components/checkbox/test/checkbox.test.js +72 -59
- package/src/components/chip/Chip.js +2 -1
- package/src/components/chip/ChipGroup.js +1 -6
- package/src/components/chip/ChipLink.js +2 -8
- package/src/components/chip/ChipRemovable.js +1 -6
- package/src/components/chip/ChipSelectable.js +4 -9
- package/src/components/chip/exports.js +4 -10
- package/src/components/chip/leu-chip-group.js +5 -2
- package/src/components/chip/leu-chip-link.js +5 -2
- package/src/components/chip/leu-chip-removable.js +5 -2
- package/src/components/chip/leu-chip-selectable.js +5 -2
- package/src/components/chip/stories/chip-group.stories.js +18 -6
- package/src/components/chip/stories/chip-link.stories.js +16 -4
- package/src/components/chip/stories/chip-removable.stories.js +15 -4
- package/src/components/chip/stories/chip-selectable.stories.js +13 -3
- package/src/components/chip/test/chip-group.test.js +124 -0
- package/src/components/chip/test/chip-link.test.js +58 -0
- package/src/components/chip/test/chip-removable.test.js +79 -0
- package/src/components/chip/test/chip-selectable.test.js +95 -0
- package/src/components/chip/test/chip.test.js +1 -1
- package/src/components/dropdown/Dropdown.js +53 -25
- package/src/components/dropdown/dropdown.css +1 -2
- package/src/components/dropdown/leu-dropdown.js +5 -2
- package/src/components/dropdown/stories/dropdown.stories.js +11 -5
- package/src/components/dropdown/test/dropdown.test.js +6 -6
- package/src/components/icon/icon.js +1 -1
- package/src/components/icon/test/icon.test.js +66 -0
- package/src/components/input/Input.js +33 -39
- package/src/components/input/input.css +9 -6
- package/src/components/input/leu-input.js +5 -2
- package/src/components/input/stories/input.stories.js +8 -2
- package/src/components/input/test/input.test.js +431 -4
- package/src/components/menu/Menu.js +0 -5
- package/src/components/menu/MenuItem.js +22 -15
- package/src/components/menu/leu-menu-item.js +5 -2
- package/src/components/menu/leu-menu.js +5 -2
- package/src/components/menu/menu-item.css +5 -2
- package/src/components/menu/stories/menu-item.stories.js +13 -4
- package/src/components/menu/stories/menu.stories.js +11 -5
- package/src/components/menu/test/menu-item.test.js +180 -0
- package/src/components/menu/test/menu.test.js +10 -2
- package/src/components/pagination/Pagination.js +53 -65
- package/src/components/pagination/leu-pagination.js +5 -2
- package/src/components/pagination/stories/pagination.stories.js +17 -9
- package/src/components/pagination/test/pagination.test.js +191 -5
- package/src/components/popup/Popup.js +200 -0
- package/src/components/popup/leu-popup.js +6 -0
- package/src/components/popup/popup.css +27 -0
- package/src/components/popup/stories/popup.stories.js +58 -0
- package/src/components/popup/test/popup.test.js +29 -0
- package/src/components/radio/Radio.js +5 -10
- package/src/components/radio/RadioGroup.js +7 -39
- package/src/components/radio/leu-radio-group.js +5 -2
- package/src/components/radio/leu-radio.js +5 -2
- package/src/components/radio/radio-group.css +29 -0
- package/src/components/radio/stories/radio-group.stories.js +38 -19
- package/src/components/radio/stories/radio.stories.js +7 -1
- package/src/components/radio/test/radio-group.test.js +86 -0
- package/src/components/radio/test/radio.test.js +108 -17
- package/src/components/select/Select.js +35 -32
- package/src/components/select/leu-select.js +5 -2
- package/src/components/select/select.css +13 -13
- package/src/components/select/stories/select.stories.js +15 -168
- package/src/components/select/test/fixtures.js +162 -0
- package/src/components/select/test/select.test.js +236 -12
- package/src/components/table/Table.js +48 -123
- package/src/components/table/leu-table.js +5 -2
- package/src/components/table/stories/table.stories.js +20 -10
- package/src/components/table/table.css +99 -0
- package/src/components/table/test/table.test.js +1 -1
- package/src/lib/utils.js +17 -0
- package/{web-dev-server-storybook.config.mjs → web-dev-server.config.mjs} +1 -2
- package/web-test-runner.config.mjs +15 -2
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { html } from "lit"
|
|
2
|
+
import { fixture, expect } from "@open-wc/testing"
|
|
3
|
+
import { sendKeys } from "@web/test-runner-commands"
|
|
4
|
+
|
|
5
|
+
import "../leu-checkbox.js"
|
|
6
|
+
import "../leu-checkbox-group.js"
|
|
7
|
+
|
|
8
|
+
async function defaultFixture() {
|
|
9
|
+
return fixture(html`
|
|
10
|
+
<leu-checkbox-group>
|
|
11
|
+
<leu-checkbox
|
|
12
|
+
label="Option 1"
|
|
13
|
+
identifier="a"
|
|
14
|
+
value="1"
|
|
15
|
+
disabled
|
|
16
|
+
></leu-checkbox>
|
|
17
|
+
<leu-checkbox label="Option 2" identifier="b" value="2"></leu-checkbox>
|
|
18
|
+
<leu-checkbox label="Option 3" identifier="c" value="3"></leu-checkbox>
|
|
19
|
+
</leu-checkbox-group>
|
|
20
|
+
`)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async function checkedFixture() {
|
|
24
|
+
return fixture(html`
|
|
25
|
+
<leu-checkbox-group>
|
|
26
|
+
<leu-checkbox
|
|
27
|
+
label="Option 1"
|
|
28
|
+
identifier="a"
|
|
29
|
+
value="1"
|
|
30
|
+
disabled
|
|
31
|
+
></leu-checkbox>
|
|
32
|
+
<leu-checkbox
|
|
33
|
+
label="Option 2"
|
|
34
|
+
identifier="b"
|
|
35
|
+
value="2"
|
|
36
|
+
checked
|
|
37
|
+
></leu-checkbox>
|
|
38
|
+
<leu-checkbox label="Option 3" identifier="c" value="3"></leu-checkbox>
|
|
39
|
+
</leu-checkbox-group>
|
|
40
|
+
`)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
describe("LeuCheckboxGroup", () => {
|
|
44
|
+
it("is a defined element", async () => {
|
|
45
|
+
const el = customElements.get("leu-checkbox-group")
|
|
46
|
+
|
|
47
|
+
await expect(el).not.to.be.undefined
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
it("passes the a11y audit", async () => {
|
|
51
|
+
const el = await defaultFixture()
|
|
52
|
+
|
|
53
|
+
await expect(el).shadowDom.to.be.accessible()
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
it("has a default value of an empty array", async () => {
|
|
57
|
+
const el = await defaultFixture()
|
|
58
|
+
|
|
59
|
+
expect(el.value).to.deep.equal([])
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
it("updates the value when a checkbox is checked", async () => {
|
|
63
|
+
const el = await defaultFixture()
|
|
64
|
+
const leuCheckbox = el.querySelector('leu-checkbox[value="2"]')
|
|
65
|
+
const checkbox = leuCheckbox.shadowRoot.querySelector("input")
|
|
66
|
+
|
|
67
|
+
checkbox.click()
|
|
68
|
+
|
|
69
|
+
expect(el.value).to.deep.equal(["2"])
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
it("allows multiple checkboxes to be checked", async () => {
|
|
73
|
+
const el = await defaultFixture()
|
|
74
|
+
const leuCheckbox2 = el.querySelector('leu-checkbox[value="2"]')
|
|
75
|
+
const leuCheckbox3 = el.querySelector('leu-checkbox[value="3"]')
|
|
76
|
+
const checkbox2 = leuCheckbox2.shadowRoot.querySelector("input")
|
|
77
|
+
const checkbox3 = leuCheckbox3.shadowRoot.querySelector("input")
|
|
78
|
+
|
|
79
|
+
checkbox2.click()
|
|
80
|
+
checkbox3.click()
|
|
81
|
+
|
|
82
|
+
expect(el.value).to.deep.equal(["2", "3"])
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
it("updates the value when a checkbox is unchecked", async () => {
|
|
86
|
+
const el = await defaultFixture()
|
|
87
|
+
const leuCheckbox = el.querySelector('leu-checkbox[value="2"]')
|
|
88
|
+
const checkbox = leuCheckbox.shadowRoot.querySelector("input")
|
|
89
|
+
|
|
90
|
+
checkbox.click()
|
|
91
|
+
checkbox.click()
|
|
92
|
+
|
|
93
|
+
expect(el.value).to.deep.equal([])
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
it("doesn't update the value when a disabled checkbox is clicked", async () => {
|
|
97
|
+
const el = await defaultFixture()
|
|
98
|
+
const leuCheckbox = el.querySelector('leu-checkbox[value="1"]')
|
|
99
|
+
const checkbox = leuCheckbox.shadowRoot.querySelector("input")
|
|
100
|
+
|
|
101
|
+
checkbox.click()
|
|
102
|
+
|
|
103
|
+
expect(el.value).to.deep.equal([])
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
it("has a default value that reflects all checked checkboxes", async () => {
|
|
107
|
+
const el = await checkedFixture()
|
|
108
|
+
|
|
109
|
+
expect(el.value).to.deep.equal(["2"])
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
it("delegates focus to the first active checkbox", async () => {
|
|
113
|
+
const el = await defaultFixture()
|
|
114
|
+
const leuCheckbox = el.querySelector('leu-checkbox[value="2"]')
|
|
115
|
+
const checkbox = leuCheckbox.shadowRoot.querySelector("input")
|
|
116
|
+
|
|
117
|
+
await sendKeys({
|
|
118
|
+
press: "Tab",
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
expect(document.activeElement).to.equal(leuCheckbox)
|
|
122
|
+
expect(leuCheckbox.shadowRoot.activeElement).to.equal(checkbox)
|
|
123
|
+
})
|
|
124
|
+
})
|
|
@@ -1,32 +1,22 @@
|
|
|
1
1
|
import { html } from "lit"
|
|
2
|
-
import { fixture, expect } from "@open-wc/testing"
|
|
2
|
+
import { fixture, expect, elementUpdated, oneEvent } from "@open-wc/testing"
|
|
3
|
+
import { sendKeys } from "@web/test-runner-commands"
|
|
3
4
|
|
|
4
5
|
import "../leu-checkbox.js"
|
|
5
|
-
import "../leu-checkbox-group.js"
|
|
6
6
|
|
|
7
7
|
async function defaultFixture() {
|
|
8
8
|
return fixture(html`
|
|
9
|
-
<leu-checkbox
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
`)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
async function checkedFixture() {
|
|
18
|
-
return fixture(html`
|
|
19
|
-
<leu-checkbox-group>
|
|
20
|
-
<leu-checkbox identifier="a" value="1" disabled>1</leu-checkbox>
|
|
21
|
-
<leu-checkbox identifier="b" value="2" checked>2</leu-checkbox>
|
|
22
|
-
<leu-checkbox identifier="c" value="3">3</leu-checkbox>
|
|
23
|
-
</leu-checkbox-group>
|
|
9
|
+
<leu-checkbox
|
|
10
|
+
identifier="b"
|
|
11
|
+
value="2"
|
|
12
|
+
label="Das ist ein Label"
|
|
13
|
+
></leu-checkbox>
|
|
24
14
|
`)
|
|
25
15
|
}
|
|
26
16
|
|
|
27
17
|
describe("LeuCheckbox", () => {
|
|
28
18
|
it("is a defined element", async () => {
|
|
29
|
-
const el =
|
|
19
|
+
const el = customElements.get("leu-checkbox")
|
|
30
20
|
|
|
31
21
|
await expect(el).not.to.be.undefined
|
|
32
22
|
})
|
|
@@ -37,65 +27,88 @@ describe("LeuCheckbox", () => {
|
|
|
37
27
|
await expect(el).shadowDom.to.be.accessible()
|
|
38
28
|
})
|
|
39
29
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const el = await customElements.get("leu-checkbox-group")
|
|
30
|
+
it("is not checked by default", async () => {
|
|
31
|
+
const el = await defaultFixture()
|
|
43
32
|
|
|
44
|
-
|
|
45
|
-
|
|
33
|
+
expect(el.checked).to.be.false
|
|
34
|
+
})
|
|
46
35
|
|
|
47
|
-
|
|
48
|
-
|
|
36
|
+
it("toggles the checked property when clicked", async () => {
|
|
37
|
+
const el = await defaultFixture()
|
|
38
|
+
const checkbox = el.shadowRoot.querySelector("input")
|
|
39
|
+
const label = el.shadowRoot.querySelector("label")
|
|
49
40
|
|
|
50
|
-
|
|
51
|
-
|
|
41
|
+
checkbox.click()
|
|
42
|
+
await elementUpdated(el)
|
|
52
43
|
|
|
53
|
-
|
|
54
|
-
const el = await defaultFixture()
|
|
55
|
-
const leuCheckbox = el.querySelector('leu-checkbox[value="2"]')
|
|
56
|
-
const checkbox = leuCheckbox.shadowRoot.querySelector("input")
|
|
44
|
+
expect(el.checked).to.be.true
|
|
57
45
|
|
|
58
|
-
|
|
46
|
+
label.click()
|
|
47
|
+
await elementUpdated(el)
|
|
59
48
|
|
|
60
|
-
|
|
61
|
-
|
|
49
|
+
expect(el.checked).to.be.false
|
|
50
|
+
})
|
|
62
51
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
52
|
+
it("does not toggle the checked property when disabled", async () => {
|
|
53
|
+
const el = await defaultFixture()
|
|
54
|
+
const checkbox = el.shadowRoot.querySelector("input")
|
|
55
|
+
const label = el.shadowRoot.querySelector("label")
|
|
67
56
|
|
|
68
|
-
|
|
69
|
-
|
|
57
|
+
el.disabled = true
|
|
58
|
+
await elementUpdated(el)
|
|
70
59
|
|
|
71
|
-
|
|
72
|
-
|
|
60
|
+
checkbox.click()
|
|
61
|
+
await elementUpdated(el)
|
|
62
|
+
|
|
63
|
+
expect(el.checked).to.be.false
|
|
64
|
+
|
|
65
|
+
label.click()
|
|
66
|
+
await elementUpdated(el)
|
|
73
67
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const leuCheckbox = el.querySelector('leu-checkbox[value="1"]')
|
|
77
|
-
const checkbox = leuCheckbox.shadowRoot.querySelector("input")
|
|
68
|
+
expect(el.checked).to.be.false
|
|
69
|
+
})
|
|
78
70
|
|
|
79
|
-
|
|
71
|
+
it("toggles the checked property when the space key is pressed", async () => {
|
|
72
|
+
const el = await defaultFixture()
|
|
73
|
+
el.focus()
|
|
80
74
|
|
|
81
|
-
|
|
75
|
+
await sendKeys({
|
|
76
|
+
press: "Space",
|
|
82
77
|
})
|
|
83
78
|
|
|
84
|
-
|
|
85
|
-
const el = await checkedFixture()
|
|
79
|
+
expect(el.checked).to.be.true
|
|
86
80
|
|
|
87
|
-
|
|
81
|
+
await sendKeys({
|
|
82
|
+
press: "Space",
|
|
88
83
|
})
|
|
89
84
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
85
|
+
expect(el.checked).to.be.false
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
it("fires a change event when clicked", async () => {
|
|
89
|
+
const el = await defaultFixture()
|
|
90
|
+
const checkbox = el.shadowRoot.querySelector("input")
|
|
94
91
|
|
|
95
|
-
|
|
92
|
+
setTimeout(() => checkbox.click())
|
|
93
|
+
const event = await oneEvent(el, "change")
|
|
96
94
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
95
|
+
expect(event).to.exist
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
it("fires an input event when clicked", async () => {
|
|
99
|
+
const el = await defaultFixture()
|
|
100
|
+
const checkbox = el.shadowRoot.querySelector("input")
|
|
101
|
+
|
|
102
|
+
setTimeout(() => checkbox.click())
|
|
103
|
+
const event = await oneEvent(el, "input")
|
|
104
|
+
|
|
105
|
+
expect(event).to.exist
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
it("applies the identifier to the input and the label", async () => {
|
|
109
|
+
const el = await defaultFixture()
|
|
110
|
+
|
|
111
|
+
expect(el.shadowRoot.querySelector("input").id).to.equal("b")
|
|
112
|
+
expect(el.shadowRoot.querySelector("label").htmlFor).to.equal("b")
|
|
100
113
|
})
|
|
101
114
|
})
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { LitElement, html } from "lit"
|
|
2
|
-
import { defineElement } from "../../lib/defineElement.js"
|
|
3
2
|
import styles from "./chip-group.css"
|
|
4
3
|
|
|
5
4
|
/* Figma https://www.figma.com/file/d6Pv21UVUbnBs3AdcZijHmbN/KTZH-Design-System?type=design&node-id=131766-248643&mode=design&t=Kjo5VDiqivihn8dh-11 */
|
|
@@ -18,7 +17,7 @@ export class LeuChipGroup extends LitElement {
|
|
|
18
17
|
static styles = styles
|
|
19
18
|
|
|
20
19
|
static properties = {
|
|
21
|
-
selectionMode: { type: String, attribute: "selection-mode" },
|
|
20
|
+
selectionMode: { type: String, attribute: "selection-mode", reflect: true },
|
|
22
21
|
}
|
|
23
22
|
|
|
24
23
|
constructor() {
|
|
@@ -65,7 +64,3 @@ export class LeuChipGroup extends LitElement {
|
|
|
65
64
|
return html`<slot @slotchange=${this.handleSlotChange}></slot>`
|
|
66
65
|
}
|
|
67
66
|
}
|
|
68
|
-
|
|
69
|
-
export function defineChipGroupElements() {
|
|
70
|
-
defineElement("chip-group", LeuChipGroup)
|
|
71
|
-
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { html } from "lit"
|
|
2
|
-
import { defineElement } from "../../lib/defineElement.js"
|
|
3
2
|
|
|
4
3
|
import { LeuChipBase } from "./Chip.js"
|
|
5
4
|
|
|
@@ -20,8 +19,7 @@ export class LeuChipLink extends LeuChipBase {
|
|
|
20
19
|
* The size of the chip
|
|
21
20
|
* @type {keyof typeof SIZES}
|
|
22
21
|
*/
|
|
23
|
-
size: { type: String },
|
|
24
|
-
|
|
22
|
+
size: { type: String, reflect: true },
|
|
25
23
|
href: { type: String, reflect: true },
|
|
26
24
|
}
|
|
27
25
|
|
|
@@ -35,11 +33,7 @@ export class LeuChipLink extends LeuChipBase {
|
|
|
35
33
|
|
|
36
34
|
render() {
|
|
37
35
|
return html`<a href=${this.href} class="button">
|
|
38
|
-
<span class="label"
|
|
36
|
+
<span class="label">${this.label}</span>
|
|
39
37
|
</a>`
|
|
40
38
|
}
|
|
41
39
|
}
|
|
42
|
-
|
|
43
|
-
export function defineChipLinkElements() {
|
|
44
|
-
defineElement("chip-link", LeuChipLink)
|
|
45
|
-
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { html } from "lit"
|
|
2
|
-
import { defineElement } from "../../lib/defineElement.js"
|
|
3
2
|
|
|
4
3
|
import { LeuChipBase } from "./Chip.js"
|
|
5
4
|
import { Icon } from "../icon/icon.js"
|
|
@@ -31,12 +30,8 @@ export class LeuChipRemovable extends LeuChipBase {
|
|
|
31
30
|
|
|
32
31
|
render() {
|
|
33
32
|
return html`<button @click=${(e) => this.handleClick(e)} class="button">
|
|
34
|
-
<span class="label"
|
|
33
|
+
<span class="label">${this.label}</span>
|
|
35
34
|
<div class="icon">${this._removeIcon}</div>
|
|
36
35
|
</button>`
|
|
37
36
|
}
|
|
38
37
|
}
|
|
39
|
-
|
|
40
|
-
export function defineChipRemovableElements() {
|
|
41
|
-
defineElement("chip-removable", LeuChipRemovable)
|
|
42
|
-
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { html } from "lit"
|
|
2
|
-
import { defineElement } from "../../lib/defineElement.js"
|
|
3
2
|
|
|
4
3
|
import { LeuChipBase } from "./Chip.js"
|
|
5
4
|
|
|
@@ -27,7 +26,7 @@ export class LeuChipSelectable extends LeuChipBase {
|
|
|
27
26
|
* @type {keyof typeof SIZES}
|
|
28
27
|
* @default "regular"
|
|
29
28
|
*/
|
|
30
|
-
size: { type: String },
|
|
29
|
+
size: { type: String, reflect: true },
|
|
31
30
|
|
|
32
31
|
/**
|
|
33
32
|
* The variant of the chip. Has an effect not only on the visual appearance but also on the behavior.
|
|
@@ -37,10 +36,10 @@ export class LeuChipSelectable extends LeuChipBase {
|
|
|
37
36
|
* @type {keyof typeof VARIANTS}
|
|
38
37
|
* @default "default"
|
|
39
38
|
*/
|
|
40
|
-
variant: { type: String },
|
|
39
|
+
variant: { type: String, reflect: true },
|
|
41
40
|
|
|
42
41
|
selected: { type: Boolean, reflect: true },
|
|
43
|
-
value: { type: String },
|
|
42
|
+
value: { type: String, reflect: true },
|
|
44
43
|
}
|
|
45
44
|
|
|
46
45
|
constructor() {
|
|
@@ -81,11 +80,7 @@ export class LeuChipSelectable extends LeuChipBase {
|
|
|
81
80
|
class="button"
|
|
82
81
|
aria-selected=${this.selected ? "true" : "false"}
|
|
83
82
|
>
|
|
84
|
-
<span class="label"
|
|
83
|
+
<span class="label">${this.label}</span>
|
|
85
84
|
</button>`
|
|
86
85
|
}
|
|
87
86
|
}
|
|
88
|
-
|
|
89
|
-
export function defineChipSelectableElements() {
|
|
90
|
-
defineElement("chip-selectable", LeuChipSelectable)
|
|
91
|
-
}
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
export { LeuChipGroup
|
|
2
|
-
export { LeuChipLink
|
|
3
|
-
export {
|
|
4
|
-
|
|
5
|
-
defineChipRemovableElements,
|
|
6
|
-
} from "./ChipRemovable.js"
|
|
7
|
-
export {
|
|
8
|
-
LeuChipSelectable,
|
|
9
|
-
defineChipSelectableElements,
|
|
10
|
-
} from "./ChipSelectable.js"
|
|
1
|
+
export { LeuChipGroup } from "./ChipGroup.js"
|
|
2
|
+
export { LeuChipLink } from "./ChipLink.js"
|
|
3
|
+
export { LeuChipRemovable } from "./ChipRemovable.js"
|
|
4
|
+
export { LeuChipSelectable } from "./ChipSelectable.js"
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineElement } from "../../lib/defineElement.js"
|
|
2
|
+
import { LeuChipGroup } from "./ChipGroup.js"
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
export { LeuChipGroup }
|
|
5
|
+
|
|
6
|
+
defineElement("chip-group", LeuChipGroup)
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineElement } from "../../lib/defineElement.js"
|
|
2
|
+
import { LeuChipRemovable } from "./ChipRemovable.js"
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
export { LeuChipRemovable }
|
|
5
|
+
|
|
6
|
+
defineElement("chip-removable", LeuChipRemovable)
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineElement } from "../../lib/defineElement.js"
|
|
2
|
+
import { LeuChipSelectable } from "./ChipSelectable.js"
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
export { LeuChipSelectable }
|
|
5
|
+
|
|
6
|
+
defineElement("chip-selectable", LeuChipSelectable)
|
|
@@ -8,7 +8,7 @@ import { SELECTION_MODES } from "../ChipGroup.js"
|
|
|
8
8
|
import { VARIANTS as SELECTABLE_VARIANTS } from "../ChipSelectable.js"
|
|
9
9
|
|
|
10
10
|
export default {
|
|
11
|
-
title: "Chip
|
|
11
|
+
title: "Chip/Group",
|
|
12
12
|
component: "leu-chip-group",
|
|
13
13
|
argTypes: {
|
|
14
14
|
selectionMode: {
|
|
@@ -21,6 +21,15 @@ export default {
|
|
|
21
21
|
selectionMode: "",
|
|
22
22
|
inverted: false,
|
|
23
23
|
},
|
|
24
|
+
parameters: {
|
|
25
|
+
design: {
|
|
26
|
+
type: "figma",
|
|
27
|
+
url: "https://www.figma.com/file/d6Pv21UVUbnBs3AdcZijHmbN/KTZH-Design-System?type=design&node-id=17340-81933&mode=design&t=lzVrtq8lxYVJU5TB-11",
|
|
28
|
+
},
|
|
29
|
+
html: {
|
|
30
|
+
root: "[data-root]",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
24
33
|
}
|
|
25
34
|
|
|
26
35
|
const chips = ["Chip 1", "Chip 2", "Chip 3"]
|
|
@@ -31,6 +40,7 @@ function invertedBackground(args, content) {
|
|
|
31
40
|
style="background: ${args.inverted
|
|
32
41
|
? "hsla(209, 83%, 59%, 1)"
|
|
33
42
|
: "var(--leu-color-black-5)"}; padding: 1rem;"
|
|
43
|
+
data-root
|
|
34
44
|
>
|
|
35
45
|
${content}
|
|
36
46
|
</div>
|
|
@@ -42,8 +52,7 @@ function DefaultTemplate(args) {
|
|
|
42
52
|
<leu-chip-group selection-mode=${args.selectionMode}>
|
|
43
53
|
${chips.map(
|
|
44
54
|
(chip) => html`
|
|
45
|
-
<leu-chip-removable ?inverted=${args.inverted}>
|
|
46
|
-
${chip}
|
|
55
|
+
<leu-chip-removable ?inverted=${args.inverted} label=${chip}>
|
|
47
56
|
</leu-chip-removable>
|
|
48
57
|
`
|
|
49
58
|
)}
|
|
@@ -62,8 +71,8 @@ function SingleTemplate(args) {
|
|
|
62
71
|
?inverted=${args.inverted}
|
|
63
72
|
variant=${SELECTABLE_VARIANTS.radio}
|
|
64
73
|
value="chip-${chip}"
|
|
74
|
+
label=${chip}
|
|
65
75
|
>
|
|
66
|
-
${chip}
|
|
67
76
|
</leu-chip-selectable>
|
|
68
77
|
`
|
|
69
78
|
)}
|
|
@@ -78,8 +87,11 @@ function MultipleTemplate(args) {
|
|
|
78
87
|
<leu-chip-group selection-mode=${args.selectionMode}>
|
|
79
88
|
${chips.map(
|
|
80
89
|
(chip) => html`
|
|
81
|
-
<leu-chip-selectable
|
|
82
|
-
|
|
90
|
+
<leu-chip-selectable
|
|
91
|
+
?inverted=${args.inverted}
|
|
92
|
+
value="chip-${chip}"
|
|
93
|
+
label=${chip}
|
|
94
|
+
>
|
|
83
95
|
</leu-chip-selectable>
|
|
84
96
|
`
|
|
85
97
|
)}
|
|
@@ -6,7 +6,7 @@ import "../leu-chip-link.js"
|
|
|
6
6
|
import { SIZES } from "../ChipLink.js"
|
|
7
7
|
|
|
8
8
|
export default {
|
|
9
|
-
title: "Chip
|
|
9
|
+
title: "Chip/Link",
|
|
10
10
|
component: "leu-chip-link",
|
|
11
11
|
argTypes: {
|
|
12
12
|
size: { control: "select", options: Object.values(SIZES) },
|
|
@@ -14,6 +14,15 @@ export default {
|
|
|
14
14
|
args: {
|
|
15
15
|
label: "Publikationen",
|
|
16
16
|
},
|
|
17
|
+
parameters: {
|
|
18
|
+
design: {
|
|
19
|
+
type: "figma",
|
|
20
|
+
url: "https://www.figma.com/file/d6Pv21UVUbnBs3AdcZijHmbN/KTZH-Design-System?type=design&node-id=17340-81933&mode=design&t=lzVrtq8lxYVJU5TB-11",
|
|
21
|
+
},
|
|
22
|
+
html: {
|
|
23
|
+
root: "[data-root]",
|
|
24
|
+
},
|
|
25
|
+
},
|
|
17
26
|
}
|
|
18
27
|
|
|
19
28
|
function Template(args) {
|
|
@@ -22,10 +31,13 @@ function Template(args) {
|
|
|
22
31
|
style="background: ${args.inverted
|
|
23
32
|
? "hsla(209, 83%, 59%, 1)"
|
|
24
33
|
: "var(--leu-color-black-5)"}; padding: 1rem;"
|
|
34
|
+
data-root
|
|
25
35
|
>
|
|
26
|
-
<leu-chip-link
|
|
27
|
-
|
|
28
|
-
|
|
36
|
+
<leu-chip-link
|
|
37
|
+
size=${ifDefined(args.size)}
|
|
38
|
+
?inverted=${args.inverted}
|
|
39
|
+
label=${args.label}
|
|
40
|
+
></leu-chip-link>
|
|
29
41
|
</div>
|
|
30
42
|
`
|
|
31
43
|
}
|
|
@@ -3,11 +3,20 @@ import { html } from "lit"
|
|
|
3
3
|
import "../leu-chip-removable.js"
|
|
4
4
|
|
|
5
5
|
export default {
|
|
6
|
-
title: "Chip
|
|
6
|
+
title: "Chip/Removable",
|
|
7
7
|
component: "leu-chip-removable",
|
|
8
8
|
args: {
|
|
9
9
|
label: "Publikationen",
|
|
10
10
|
},
|
|
11
|
+
parameters: {
|
|
12
|
+
design: {
|
|
13
|
+
type: "figma",
|
|
14
|
+
url: "https://www.figma.com/file/d6Pv21UVUbnBs3AdcZijHmbN/KTZH-Design-System?type=design&node-id=17340-81933&mode=design&t=lzVrtq8lxYVJU5TB-11",
|
|
15
|
+
},
|
|
16
|
+
html: {
|
|
17
|
+
root: "[data-root]",
|
|
18
|
+
},
|
|
19
|
+
},
|
|
11
20
|
}
|
|
12
21
|
|
|
13
22
|
function Template(args) {
|
|
@@ -16,10 +25,12 @@ function Template(args) {
|
|
|
16
25
|
style="background: ${args.inverted
|
|
17
26
|
? "hsla(209, 83%, 59%, 1)"
|
|
18
27
|
: "var(--leu-color-black-5)"}; padding: 1rem;"
|
|
28
|
+
data-root
|
|
19
29
|
>
|
|
20
|
-
<leu-chip-removable
|
|
21
|
-
|
|
22
|
-
|
|
30
|
+
<leu-chip-removable
|
|
31
|
+
?inverted=${args.inverted}
|
|
32
|
+
label=${args.label}
|
|
33
|
+
></leu-chip-removable>
|
|
23
34
|
</div>
|
|
24
35
|
`
|
|
25
36
|
}
|
|
@@ -6,7 +6,7 @@ import "../leu-chip-selectable.js"
|
|
|
6
6
|
import { SIZES, VARIANTS } from "../ChipSelectable.js"
|
|
7
7
|
|
|
8
8
|
export default {
|
|
9
|
-
title: "Chip
|
|
9
|
+
title: "Chip/Selectable",
|
|
10
10
|
component: "leu-chip-selectable",
|
|
11
11
|
argTypes: {
|
|
12
12
|
variant: { control: "select", options: Object.values(VARIANTS) },
|
|
@@ -16,6 +16,15 @@ export default {
|
|
|
16
16
|
args: {
|
|
17
17
|
label: "Publikationen",
|
|
18
18
|
},
|
|
19
|
+
parameters: {
|
|
20
|
+
design: {
|
|
21
|
+
type: "figma",
|
|
22
|
+
url: "https://www.figma.com/file/d6Pv21UVUbnBs3AdcZijHmbN/KTZH-Design-System?type=design&node-id=17340-81933&mode=design&t=lzVrtq8lxYVJU5TB-11",
|
|
23
|
+
},
|
|
24
|
+
html: {
|
|
25
|
+
root: "[data-root]",
|
|
26
|
+
},
|
|
27
|
+
},
|
|
19
28
|
}
|
|
20
29
|
|
|
21
30
|
function Template(args) {
|
|
@@ -24,14 +33,15 @@ function Template(args) {
|
|
|
24
33
|
style="background: ${args.inverted
|
|
25
34
|
? "hsla(209, 83%, 59%, 1)"
|
|
26
35
|
: "var(--leu-color-black-5)"}; padding: 1rem;"
|
|
36
|
+
data-root
|
|
27
37
|
>
|
|
28
38
|
<leu-chip-selectable
|
|
29
39
|
size=${ifDefined(args.size)}
|
|
30
40
|
variant=${ifDefined(args.variant)}
|
|
41
|
+
label=${args.label}
|
|
31
42
|
?selected=${args.selected}
|
|
32
43
|
?inverted=${args.inverted}
|
|
33
|
-
|
|
34
|
-
>
|
|
44
|
+
></leu-chip-selectable>
|
|
35
45
|
</div>
|
|
36
46
|
`
|
|
37
47
|
}
|