@statistikzh/leu 0.8.0 → 0.9.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 (112) hide show
  1. package/.github/workflows/release-please.yml +3 -3
  2. package/CHANGELOG.md +19 -0
  3. package/dist/Accordion.d.ts +1 -1
  4. package/dist/Accordion.js +1 -1
  5. package/dist/Breadcrumb.d.ts +1 -1
  6. package/dist/Breadcrumb.js +1 -1
  7. package/dist/{Button-3adfb3ed.d.ts → Button-5a8009c5.d.ts} +2 -2
  8. package/dist/{Button-3adfb3ed.d.ts.map → Button-5a8009c5.d.ts.map} +1 -1
  9. package/dist/{Button-3adfb3ed.js → Button-5a8009c5.js} +3 -4
  10. package/dist/Button.d.ts +1 -1
  11. package/dist/Button.js +2 -2
  12. package/dist/ButtonGroup.d.ts +1 -1
  13. package/dist/ButtonGroup.js +1 -1
  14. package/dist/Checkbox.d.ts +1 -1
  15. package/dist/Checkbox.js +2 -2
  16. package/dist/CheckboxGroup.d.ts +1 -1
  17. package/dist/CheckboxGroup.js +1 -1
  18. package/dist/Chip.d.ts +1 -1
  19. package/dist/Chip.js +1 -1
  20. package/dist/ChipGroup.d.ts +1 -1
  21. package/dist/ChipGroup.js +1 -1
  22. package/dist/ChipLink.js +1 -1
  23. package/dist/ChipRemovable.js +1 -1
  24. package/dist/ChipSelectable.js +1 -1
  25. package/dist/Dropdown.d.ts +1 -1
  26. package/dist/Dropdown.js +3 -3
  27. package/dist/Icon.d.ts +1 -1
  28. package/dist/Icon.js +1 -1
  29. package/dist/Input.d.ts +1 -1
  30. package/dist/Input.js +1 -1
  31. package/dist/{LeuElement-a20c5fd6.d.ts → LeuElement-7ab5ef5e.d.ts} +1 -1
  32. package/dist/LeuElement-7ab5ef5e.d.ts.map +1 -0
  33. package/dist/{LeuElement-a20c5fd6.js → LeuElement-7ab5ef5e.js} +1 -1
  34. package/dist/Menu.d.ts +1 -1
  35. package/dist/Menu.js +1 -1
  36. package/dist/MenuItem.d.ts +5 -1
  37. package/dist/MenuItem.d.ts.map +1 -1
  38. package/dist/MenuItem.js +18 -3
  39. package/dist/Pagination.d.ts +1 -1
  40. package/dist/Pagination.js +2 -2
  41. package/dist/Popup.d.ts +1 -1
  42. package/dist/Popup.js +1 -1
  43. package/dist/Radio.d.ts +1 -1
  44. package/dist/Radio.js +2 -2
  45. package/dist/RadioGroup.d.ts +1 -1
  46. package/dist/RadioGroup.js +1 -1
  47. package/dist/ScrollTop.d.ts +1 -1
  48. package/dist/ScrollTop.js +2 -2
  49. package/dist/Select.d.ts +1 -1
  50. package/dist/Select.d.ts.map +1 -1
  51. package/dist/Select.js +9 -5
  52. package/dist/Spinner.d.ts +9 -0
  53. package/dist/Spinner.d.ts.map +1 -0
  54. package/dist/Spinner.js +53 -0
  55. package/dist/Table.d.ts +1 -1
  56. package/dist/Table.js +2 -2
  57. package/dist/VisuallyHidden.d.ts +1 -1
  58. package/dist/VisuallyHidden.js +1 -1
  59. package/dist/index.d.ts +1 -1
  60. package/dist/index.js +2 -2
  61. package/dist/leu-accordion.js +1 -1
  62. package/dist/leu-breadcrumb.js +1 -1
  63. package/dist/leu-button-group.js +1 -1
  64. package/dist/leu-button.d.ts +1 -1
  65. package/dist/leu-button.js +2 -2
  66. package/dist/leu-checkbox-group.js +1 -1
  67. package/dist/leu-checkbox.js +1 -1
  68. package/dist/leu-chip-group.js +1 -1
  69. package/dist/leu-chip-link.js +1 -1
  70. package/dist/leu-chip-removable.js +1 -1
  71. package/dist/leu-chip-selectable.js +1 -1
  72. package/dist/leu-dropdown.js +2 -2
  73. package/dist/leu-icon.js +1 -1
  74. package/dist/leu-input.js +1 -1
  75. package/dist/leu-menu-item.js +1 -1
  76. package/dist/leu-menu.js +1 -1
  77. package/dist/leu-pagination.js +2 -2
  78. package/dist/leu-popup.js +1 -1
  79. package/dist/leu-radio-group.js +1 -1
  80. package/dist/leu-radio.js +1 -1
  81. package/dist/leu-scroll-top.js +2 -2
  82. package/dist/leu-select.js +2 -2
  83. package/dist/leu-spinner.d.ts +3 -0
  84. package/dist/leu-spinner.d.ts.map +1 -0
  85. package/dist/leu-spinner.js +7 -0
  86. package/dist/leu-table.js +2 -2
  87. package/dist/leu-visually-hidden.js +1 -1
  88. package/dist/theme.css +52 -25
  89. package/dist/vscode.html-custom-data.json +16 -0
  90. package/dist/vue/index.d.ts +15 -0
  91. package/dist/web-types.json +19 -1
  92. package/package.json +1 -1
  93. package/scripts/generate-component/templates/[namespace]-[name].js +1 -2
  94. package/src/components/button/button.css +2 -3
  95. package/src/components/checkbox/Checkbox.js +1 -1
  96. package/src/components/checkbox/stories/checkbox.stories.js +7 -2
  97. package/src/components/dropdown/Dropdown.js +1 -1
  98. package/src/components/dropdown/test/dropdown.test.js +20 -3
  99. package/src/components/menu/MenuItem.js +21 -2
  100. package/src/components/menu/stories/menu-item.stories.js +18 -8
  101. package/src/components/menu/test/menu-item.test.js +23 -0
  102. package/src/components/radio/Radio.js +1 -1
  103. package/src/components/radio/stories/radio.stories.js +7 -1
  104. package/src/components/select/Select.js +8 -6
  105. package/src/components/select/test/select.test.js +30 -0
  106. package/src/components/spinner/Spinner.js +31 -0
  107. package/src/components/spinner/leu-spinner.js +5 -0
  108. package/src/components/spinner/spinner.css +20 -0
  109. package/src/components/spinner/stories/spinner.stories.js +29 -0
  110. package/src/components/spinner/test/spinner.test.js +30 -0
  111. package/src/styles/custom-properties.css +8 -3
  112. package/dist/LeuElement-a20c5fd6.d.ts.map +0 -1
@@ -21,6 +21,7 @@ import type { LeuRadio } from "../Radio.js";
21
21
  import type { LeuRadioGroup } from "../RadioGroup.js";
22
22
  import type { LeuScrollTop } from "../ScrollTop.js";
23
23
  import type { LeuSelect } from "../Select.js";
24
+ import type { LeuSpinner } from "../Spinner.js";
24
25
  import type { LeuTable } from "../Table.js";
25
26
  import type { LeuVisuallyHidden } from "../VisuallyHidden.js";
26
27
 
@@ -255,6 +256,8 @@ type LeuMenuProps = {
255
256
  type LeuMenuItemProps = {
256
257
  /** Defines if the item is selected or checked */
257
258
  active?: LeuMenuItem["active"];
259
+ /** If the item is part of a multiple selection. Renders a checkmark before the label when active */
260
+ multipleSelection?: LeuMenuItem["multipleSelection"];
258
261
  /** Disables the underlying button or link */
259
262
  disabled?: LeuMenuItem["disabled"];
260
263
  /** If the item should be focusable. Will be reflected as `tabindex` to the underlying button or link */
@@ -383,6 +386,8 @@ type LeuSelectProps = {
383
386
  _menuRef?: LeuSelect["_menuRef"];
384
387
  };
385
388
 
389
+ type LeuSpinnerProps = {};
390
+
386
391
  type LeuTableProps = {
387
392
  /** */
388
393
  columns?: LeuTable["columns"];
@@ -674,6 +679,16 @@ export type CustomElements = {
674
679
  */
675
680
  "leu-select": DefineComponent<LeuSelectProps>;
676
681
 
682
+ /**
683
+ *
684
+ * ---
685
+ *
686
+ *
687
+ * ### **CSS Properties:**
688
+ * - **--leu-spinner-size** - The size of the spinner. _(default: undefined)_
689
+ */
690
+ "leu-spinner": DefineComponent<LeuSpinnerProps>;
691
+
677
692
  /**
678
693
  *
679
694
  * ---
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json",
3
3
  "name": "@statistikzh/leu",
4
- "version": "0.8.0",
4
+ "version": "0.9.0",
5
5
  "description-markup": "markdown",
6
6
  "contributions": {
7
7
  "html": {
@@ -803,6 +803,11 @@
803
803
  "description": "Defines if the item is selected or checked",
804
804
  "value": { "type": "boolean", "default": "false" }
805
805
  },
806
+ {
807
+ "name": "multipleSelection",
808
+ "description": "If the item is part of a multiple selection. Renders a checkmark before the label when active",
809
+ "value": { "type": "boolean", "default": "false" }
810
+ },
806
811
  {
807
812
  "name": "disabled",
808
813
  "description": "Disables the underlying button or link",
@@ -840,6 +845,11 @@
840
845
  "description": "Defines if the item is selected or checked",
841
846
  "value": { "type": "boolean" }
842
847
  },
848
+ {
849
+ "name": "multipleSelection",
850
+ "description": "If the item is part of a multiple selection. Renders a checkmark before the label when active",
851
+ "value": { "type": "boolean" }
852
+ },
843
853
  {
844
854
  "name": "disabled",
845
855
  "description": "Disables the underlying button or link",
@@ -1147,6 +1157,14 @@
1147
1157
  "events": []
1148
1158
  }
1149
1159
  },
1160
+ {
1161
+ "name": "leu-spinner",
1162
+ "description": "\n---\n\n\n### **CSS Properties:**\n - **--leu-spinner-size** - The size of the spinner. _(default: undefined)_",
1163
+ "doc-url": "",
1164
+ "attributes": [],
1165
+ "events": [],
1166
+ "js": { "properties": [], "events": [] }
1167
+ },
1150
1168
  {
1151
1169
  "name": "leu-table",
1152
1170
  "description": "\n---\n",
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "UI component library of the canton of zurich",
4
4
  "license": "MIT",
5
5
  "author": "statistikzh",
6
- "version": "0.8.0",
6
+ "version": "0.9.0",
7
7
  "type": "module",
8
8
  "main": "dist/index.js",
9
9
  "module": "dist/index.js",
@@ -1,6 +1,5 @@
1
- import { defineElement } from "../../lib/defineElement.js"
2
1
  import { [Namespace][Name] } from "./[Name].js"
3
2
 
4
3
  export { [Namespace][Name] }
5
4
 
6
- defineElement("[name]", [Namespace][Name])
5
+ [Namespace][Name].define("[namespace]-[name]")
@@ -8,7 +8,7 @@ button {
8
8
  appearance: none;
9
9
  transition: background 0.1s ease;
10
10
  cursor: pointer;
11
- border: 1px solid transparent;
11
+ border: none;
12
12
  border-radius: 2px;
13
13
 
14
14
  max-width: 100%;
@@ -33,12 +33,11 @@ button:disabled {
33
33
  }
34
34
 
35
35
  button:focus-visible {
36
- border: 1px solid var(--leu-color-black-0);
37
36
  outline: 2px solid var(--leu-color-func-cyan);
37
+ outline-offset: 2px;
38
38
  }
39
39
 
40
40
  button.inverted:focus-visible {
41
- border: 1px solid var(--leu-color-black-100);
42
41
  outline: 2px solid var(--leu-color-black-0);
43
42
  }
44
43
 
@@ -59,7 +59,7 @@ export class LeuCheckbox extends LeuElement {
59
59
  @input=${this.handleInput}
60
60
  .checked=${this.checked}
61
61
  ?disabled=${this.disabled}
62
- .value=${this.value}
62
+ .value=${this.value ?? ""}
63
63
  />
64
64
  <label for=${`checkbox-${this.name}`} class="label"><slot></slot></label>
65
65
  <leu-icon class="icon" name="check"></leu-icon>
@@ -17,9 +17,14 @@ export default {
17
17
  },
18
18
  }
19
19
 
20
- function Template({ label = "Label", value, checked, disabled }) {
20
+ function Template({ label = "Label", value, checked, disabled, name = "" }) {
21
21
  return html`
22
- <leu-checkbox .value=${value} ?checked=${checked} ?disabled=${disabled}>
22
+ <leu-checkbox
23
+ .value=${value}
24
+ ?checked=${checked}
25
+ ?disabled=${disabled}
26
+ name=${name}
27
+ >
23
28
  ${label}
24
29
  </leu-checkbox>
25
30
  `
@@ -65,7 +65,7 @@ export class LeuDropdown extends LeuElement {
65
65
  }
66
66
 
67
67
  _documentClickHandler = (event) => {
68
- if (!this.contains(event.target)) {
68
+ if (!event.composedPath().includes(this)) {
69
69
  this.expanded = false
70
70
  }
71
71
  }
@@ -1,10 +1,13 @@
1
1
  import { html } from "lit"
2
- import { fixture, expect } from "@open-wc/testing"
2
+ import { fixture, expect, elementUpdated } from "@open-wc/testing"
3
3
 
4
4
  import "../leu-dropdown.js"
5
5
 
6
- async function defaultFixture() {
7
- return fixture(html` <leu-dropdown label="Download">
6
+ async function defaultFixture(args = { expanded: false }) {
7
+ return fixture(html` <leu-dropdown
8
+ label="Download"
9
+ ?expanded=${args.expanded}
10
+ >
8
11
  <leu-menu>
9
12
  <leu-menu-item>Als CSV Tabelle</leu-menu-item>
10
13
  <leu-menu-item>Als XLS Tabelle</leu-menu-item>
@@ -28,4 +31,18 @@ describe("LeuDropdown", () => {
28
31
 
29
32
  await expect(el).shadowDom.to.be.accessible()
30
33
  })
34
+
35
+ it("closes the popup when the document is clicked outside the component", async () => {
36
+ const el = await defaultFixture()
37
+
38
+ const toggleButton = el.shadowRoot.querySelector("leu-button")
39
+ toggleButton.click()
40
+ await elementUpdated(el)
41
+
42
+ expect(el.expanded).to.be.true
43
+
44
+ document.body.click()
45
+
46
+ expect(el.expanded).to.be.false
47
+ })
31
48
  })
@@ -1,4 +1,4 @@
1
- import { html } from "lit"
1
+ import { html, nothing } from "lit"
2
2
  import { ifDefined } from "lit/directives/if-defined.js"
3
3
 
4
4
  import { LeuElement } from "../../lib/LeuElement.js"
@@ -15,6 +15,7 @@ import styles from "./menu-item.css"
15
15
  * @tagname leu-menu-item
16
16
  * @slot - The label of the menu item
17
17
  * @property {boolean} active - Defines if the item is selected or checked
18
+ * @property {boolean} multipleSelection - If the item is part of a multiple selection. Renders a checkmark before the label when active
18
19
  * @property {boolean} disabled - Disables the underlying button or link
19
20
  * @property {string} value - The value of the item. It must not contain commas. See `getValue()`
20
21
  * @property {string} href - The href of the underlying link
@@ -38,6 +39,11 @@ export class LeuMenuItem extends LeuElement {
38
39
 
39
40
  static properties = {
40
41
  active: { type: Boolean, reflect: true },
42
+ multipleSelection: {
43
+ type: Boolean,
44
+ reflect: true,
45
+ attr: "multiple-selection",
46
+ },
41
47
  disabled: { type: Boolean, reflect: true },
42
48
  tabbable: { type: Boolean, reflect: true },
43
49
  href: { type: String, reflect: true },
@@ -50,6 +56,7 @@ export class LeuMenuItem extends LeuElement {
50
56
 
51
57
  this.active = false
52
58
  this.disabled = false
59
+ this.multipleSelection = false
53
60
  this.value = undefined
54
61
  this.href = undefined
55
62
  this.tabbable = undefined
@@ -142,9 +149,21 @@ export class LeuMenuItem extends LeuElement {
142
149
  </button>`
143
150
  }
144
151
 
152
+ _renderBeforeSlotDefault() {
153
+ if (!this.multipleSelection) {
154
+ return nothing
155
+ }
156
+
157
+ return this.active
158
+ ? html`<leu-icon name="check"></leu-icon>`
159
+ : html`<leu-icon></leu-icon>`
160
+ }
161
+
145
162
  render() {
146
163
  const content = html`
147
- <slot class="before" name="before"></slot>
164
+ <slot class="before" name="before"
165
+ >${this._renderBeforeSlotDefault()}</slot
166
+ >
148
167
  <span class="label"><slot></slot></span>
149
168
  <slot class="after" name="after"></slot>
150
169
  `
@@ -1,4 +1,4 @@
1
- import { html } from "lit"
1
+ import { html, nothing } from "lit"
2
2
  import { ifDefined } from "lit/directives/if-defined.js"
3
3
 
4
4
  import "../leu-menu-item.js"
@@ -29,14 +29,19 @@ function Template(args) {
29
29
  href=${ifDefined(args.href)}
30
30
  ?active=${args.active}
31
31
  ?disabled=${args.disabled}
32
+ ?multipleSelection=${args.multipleSelection}
32
33
  >
33
- ${isIcon(args.before)
34
- ? html`<leu-icon slot="before" name=${args.before}></leu-icon>`
35
- : html`<span slot="before">${args.before}</span>`}
34
+ ${args.before
35
+ ? isIcon(args.before)
36
+ ? html`<leu-icon slot="before" name=${args.before}></leu-icon>`
37
+ : html`<span slot="before">${args.before}</span>`
38
+ : nothing}
36
39
  ${args.label}
37
- ${isIcon(args.after)
38
- ? html`<leu-icon slot="after" name=${args.after}></leu-icon>`
39
- : html`<span slot="after">${args.after}</span>`}
40
+ ${args.after
41
+ ? isIcon(args.after)
42
+ ? html`<leu-icon slot="after" name=${args.after}></leu-icon>`
43
+ : html`<span slot="after">${args.after}</span>`
44
+ : null}
40
45
  </leu-menu-item>
41
46
  `
42
47
  }
@@ -50,7 +55,7 @@ Active.args = {
50
55
 
51
56
  export const IconBefore = Template.bind({})
52
57
  IconBefore.args = {
53
- before: "check",
58
+ before: "download",
54
59
  }
55
60
 
56
61
  export const IconAfterLink = Template.bind({})
@@ -69,3 +74,8 @@ export const IconPlaceholder = Template.bind({})
69
74
  IconPlaceholder.args = {
70
75
  before: "EMPTY",
71
76
  }
77
+
78
+ export const MultipleSelection = Template.bind({})
79
+ MultipleSelection.args = {
80
+ multipleSelection: true,
81
+ }
@@ -15,6 +15,7 @@ async function defaultFixture(args = {}) {
15
15
  ?active=${args.active}
16
16
  ?disabled=${args.disabled}
17
17
  ?tabbable=${args.tabbable}
18
+ ?multipleSelection=${args.multipleSelection}
18
19
  >
19
20
  ${args.label}
20
21
  </leu-menu-item>
@@ -183,4 +184,26 @@ describe("LeuMenuItem", () => {
183
184
 
184
185
  expect(el.getValue()).to.equal("download-01")
185
186
  })
187
+
188
+ it("renders a palceholder icon when the menu item is part of multiple selection but not active", async () => {
189
+ const el = await defaultFixture({
190
+ label: "Download",
191
+ multipleSelection: true,
192
+ })
193
+
194
+ const icon = el.shadowRoot.querySelector("leu-icon")
195
+ expect(icon).to.exist
196
+ expect(icon).to.have.attribute("name", "EMPTY")
197
+ })
198
+
199
+ it("renders a check icon when the menu item is part of multiple selection and is active", async () => {
200
+ const el = await defaultFixture({
201
+ label: "Download",
202
+ multipleSelection: true,
203
+ })
204
+
205
+ const icon = el.shadowRoot.querySelector("leu-icon")
206
+ expect(icon).to.exist
207
+ expect(icon).to.have.attribute("name", "check")
208
+ })
186
209
  })
@@ -54,7 +54,7 @@ export class LeuRadio extends LeuElement {
54
54
  @input=${this.handleInput}
55
55
  .checked=${this.checked}
56
56
  ?disabled=${this.disabled}
57
- .value=${this.value}
57
+ .value=${this.value ?? ""}
58
58
  />
59
59
  <label for=${`radio-${this.name}`} class="label"><slot></slot></label>
60
60
  `
@@ -22,9 +22,15 @@ function Template({
22
22
  value = "",
23
23
  checked = false,
24
24
  disabled = false,
25
+ name = "",
25
26
  }) {
26
27
  return html`
27
- <leu-radio .value=${value} ?checked=${checked} ?disabled=${disabled}>
28
+ <leu-radio
29
+ .value=${value}
30
+ ?checked=${checked}
31
+ ?disabled=${disabled}
32
+ name=${name}
33
+ >
28
34
  ${label}
29
35
  </leu-radio>
30
36
  `
@@ -146,11 +146,13 @@ export class LeuSelect extends LeuElement {
146
146
 
147
147
  if (
148
148
  changedProperties.has("value") ||
149
- changedProperties.has("_optionFilter")
149
+ changedProperties.has("_optionFilter") ||
150
+ changedProperties.has("multiple")
150
151
  ) {
151
152
  this._updateMenuItems({
152
153
  value: changedProperties.has("value"),
153
154
  optionFilter: changedProperties.has("_optionFilter"),
155
+ multiple: changedProperties.has("multiple"),
154
156
  })
155
157
  }
156
158
  }
@@ -171,6 +173,10 @@ export class LeuSelect extends LeuElement {
171
173
 
172
174
  /* eslint-disable no-param-reassign */
173
175
  menuItems.forEach((menuItem) => {
176
+ if (changed.multiple) {
177
+ menuItem.multipleSelection = this.multiple
178
+ }
179
+
174
180
  if (changed.optionFilter) {
175
181
  menuItem.hidden =
176
182
  this._optionFilter !== "" &&
@@ -203,11 +209,7 @@ export class LeuSelect extends LeuElement {
203
209
  * @param {MouseEvent} event
204
210
  */
205
211
  _handleDocumentClick = (event) => {
206
- if (
207
- event.target instanceof Node &&
208
- !this.contains(event.target) &&
209
- this.open
210
- ) {
212
+ if (!event.composedPath().includes(this) && this.open) {
211
213
  this._closeDropdown()
212
214
  }
213
215
  }
@@ -404,4 +404,34 @@ describe("LeuSelect", () => {
404
404
  const popup = el.shadowRoot.querySelector("leu-popup")
405
405
  expect(popup.active).to.not.be.true
406
406
  })
407
+
408
+ it("sets the multipleSelection property on the menu items when multiple selection is allowed", async () => {
409
+ const el = await defaultFixture({
410
+ options: MUNICIPALITIES,
411
+ label: "Gemeinde",
412
+ multiple: true,
413
+ })
414
+
415
+ const menuItems = Array.from(el.querySelectorAll("leu-menu-item"))
416
+ expect(menuItems.every((item) => item.multipleSelection)).to.be.true
417
+
418
+ el.multiple = false
419
+ await elementUpdated(el)
420
+
421
+ expect(menuItems.every((item) => !item.multipleSelection)).to.be.true
422
+
423
+ it("closes the popup when the document is clicked outside the component", async () => {
424
+ const el = await defaultFixture({
425
+ options: MUNICIPALITIES,
426
+ label: "Gemeinde",
427
+ })
428
+
429
+ const toggleButton = el.shadowRoot.querySelector(".select-toggle")
430
+ toggleButton.click()
431
+
432
+ document.body.click()
433
+
434
+ const popup = el.shadowRoot.querySelector("leu-popup")
435
+ expect(popup.active).to.not.be.true
436
+ })
407
437
  })
@@ -0,0 +1,31 @@
1
+ import { html } from "lit"
2
+
3
+ import { LeuElement } from "../../lib/LeuElement.js"
4
+
5
+ import styles from "./spinner.css"
6
+
7
+ /**
8
+ * @tagname leu-spinner
9
+ * @cssprop --leu-spinner-size - The size of the spinner.
10
+ */
11
+ export class LeuSpinner extends LeuElement {
12
+ static styles = styles
13
+
14
+ render() {
15
+ return html`
16
+ <svg
17
+ class="spinner"
18
+ fill="none"
19
+ xmlns="http://www.w3.org/2000/svg"
20
+ viewBox="0 0 56 56"
21
+ role="presentation"
22
+ >
23
+ <path
24
+ d="M13.8579 13.858c7.8105-7.8105 20.4737-7.8105 28.2842 0 7.8105 7.8104 7.8105 20.4737 0 28.2842-7.8105 7.8105-20.4737 7.8105-28.2842 0-4.3487-4.3486-6.2761-10.2016-5.7824-15.8838"
25
+ stroke="currentColor"
26
+ stroke-width="3"
27
+ />
28
+ </svg>
29
+ `
30
+ }
31
+ }
@@ -0,0 +1,5 @@
1
+ import { LeuSpinner } from "./Spinner.js"
2
+
3
+ export { LeuSpinner }
4
+
5
+ LeuSpinner.define("leu-spinner")
@@ -0,0 +1,20 @@
1
+ @keyframes leu-spinner-rotate {
2
+ from {
3
+ transform: rotate(0deg);
4
+ }
5
+
6
+ to {
7
+ transform: rotate(360deg);
8
+ }
9
+ }
10
+
11
+ :host {
12
+ color: var(--leu-color-func-cyan);
13
+ }
14
+
15
+ .spinner {
16
+ display: block;
17
+ width: var(--leu-spinner-size, 3.5rem);
18
+ height: var(--leu-spinner-size, 3.5rem);
19
+ animation: leu-spinner-rotate 1s cubic-bezier(0.49, 0.12, 0.56, 0.91) infinite;
20
+ }
@@ -0,0 +1,29 @@
1
+ import { html } from "lit"
2
+ import "../leu-spinner.js"
3
+ import { styleMap } from "lit/directives/style-map.js"
4
+
5
+ export default {
6
+ title: "Spinner",
7
+ component: "leu-spinner",
8
+ argTypes: {
9
+ color: {
10
+ control: {
11
+ type: "color",
12
+ presetColors: ["#009ee0", "#d93c1a", "#1a7f1f"],
13
+ },
14
+ },
15
+ },
16
+ }
17
+
18
+ function Template({ size, color }) {
19
+ const styles = styleMap({
20
+ color,
21
+ "--leu-spinner-size": size ? `${size}px` : null,
22
+ })
23
+ return html` <leu-spinner style=${styles}></leu-spinner> `
24
+ }
25
+
26
+ export const Regular = Template.bind({})
27
+ Regular.args = {
28
+ size: 56,
29
+ }
@@ -0,0 +1,30 @@
1
+ import { html } from "lit"
2
+ import { fixture, expect } from "@open-wc/testing"
3
+
4
+ import "../leu-spinner.js"
5
+
6
+ async function defaultFixture() {
7
+ return fixture(html`<leu-spinner></leu-spinner>`)
8
+ }
9
+
10
+ describe("LeuSpinner", () => {
11
+ it("is a defined element", async () => {
12
+ const el = await customElements.get("leu-spinner")
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
+
23
+ it("renders a svg element with a 56x56 viewbox", async () => {
24
+ const el = await defaultFixture()
25
+
26
+ const svg = el.shadowRoot.querySelector("svg")
27
+
28
+ expect(svg).to.have.attribute("viewBox", "0 0 56 56")
29
+ })
30
+ })
@@ -1,6 +1,7 @@
1
1
  @import url("./custom-media.css");
2
2
 
3
- :root {
3
+ :root,
4
+ :host {
4
5
  --leu-color-black-100: #000;
5
6
  --leu-color-black-80: #333;
6
7
  --leu-color-black-60: #666;
@@ -44,8 +45,12 @@
44
45
  --leu-color-func-red: #d93c1a;
45
46
  --leu-color-func-green: #1a7f1f;
46
47
 
47
- --leu-font-family-regular: HelveticaNowRegular, Helvetica, sans-serif; /* stylelint-disable-line value-keyword-case */
48
- --leu-font-family-black: HelveticaNowBlack, Arial Black, Helvetica, sans-serif; /* stylelint-disable-line value-keyword-case */
48
+ /* stylelint-disable value-keyword-case */
49
+ --leu-font-family-regular: InterRegular, HelveticaNowRegular, Helvetica,
50
+ sans-serif;
51
+ --leu-font-family-black: InterBlack, HelveticaNowBlack, Arial Black, Helvetica,
52
+ sans-serif;
53
+ /* stylelint-enable value-keyword-case */
49
54
 
50
55
  --leu-box-shadow-short: 0px 0px 2px var(--leu-color-black-transp-40);
51
56
  --leu-box-shadow-regular: 0px 0px 16px var(--leu-color-black-transp-20);
@@ -1 +0,0 @@
1
- {"version":3,"file":"LeuElement-a20c5fd6.d.ts","sourceRoot":"","sources":["LeuElement-a20c5fd6.js"],"names":[],"mappings":"AA+BA;IACE,8EAcC;CACF;AA7CD,sEAaC;2BAf0B,KAAK"}