@statistikzh/leu 0.3.0 → 0.5.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 -6
- package/.storybook/static/logo.svg +19 -0
- package/.storybook/theme.js +7 -0
- package/CHANGELOG.md +54 -0
- package/README.md +1 -1
- package/custom-elements-manifest.config.js +46 -0
- package/dist/Accordion.d.ts +31 -0
- package/dist/Accordion.d.ts.map +1 -0
- package/dist/Accordion.js +257 -0
- package/dist/Breadcrumb.d.ts +69 -0
- package/dist/Breadcrumb.d.ts.map +1 -0
- package/dist/Breadcrumb.js +392 -0
- package/dist/Button-da11d064.d.ts +84 -0
- package/dist/Button-da11d064.d.ts.map +1 -0
- package/dist/Button-da11d064.js +542 -0
- package/dist/Button.d.ts +2 -0
- package/dist/Button.d.ts.map +1 -0
- package/dist/Button.js +6 -423
- package/dist/ButtonGroup.d.ts +24 -0
- package/dist/ButtonGroup.d.ts.map +1 -0
- package/dist/ButtonGroup.js +72 -43
- package/dist/Checkbox.d.ts +13 -0
- package/dist/Checkbox.d.ts.map +1 -0
- package/dist/Checkbox.js +101 -84
- package/dist/CheckboxGroup.d.ts +13 -0
- package/dist/CheckboxGroup.d.ts.map +1 -0
- package/dist/CheckboxGroup.js +41 -37
- package/dist/Chip.d.ts +5 -0
- package/dist/Chip.d.ts.map +1 -0
- package/dist/{Chip-5f70d04f.js → Chip.js} +21 -6
- package/dist/ChipGroup.d.ts +28 -0
- package/dist/ChipGroup.d.ts.map +1 -0
- package/dist/ChipGroup.js +64 -10
- package/dist/ChipLink.d.ts +15 -0
- package/dist/ChipLink.d.ts.map +1 -0
- package/dist/ChipLink.js +4 -7
- package/dist/ChipRemovable.d.ts +13 -0
- package/dist/ChipRemovable.d.ts.map +1 -0
- package/dist/ChipRemovable.js +5 -8
- package/dist/ChipSelectable.d.ts +22 -0
- package/dist/ChipSelectable.d.ts.map +1 -0
- package/dist/ChipSelectable.js +8 -11
- package/dist/Dropdown.d.ts +15 -0
- package/dist/Dropdown.d.ts.map +1 -0
- package/dist/Dropdown.js +73 -26
- package/dist/Input.d.ts +154 -0
- package/dist/Input.d.ts.map +1 -0
- package/dist/Input.js +42 -35
- package/dist/Menu.d.ts +8 -0
- package/dist/Menu.d.ts.map +1 -0
- package/dist/Menu.js +2 -5
- package/dist/MenuItem.d.ts +21 -0
- package/dist/MenuItem.d.ts.map +1 -0
- package/dist/MenuItem.js +32 -17
- package/dist/Pagination.d.ts +27 -0
- package/dist/Pagination.d.ts.map +1 -0
- package/dist/Pagination.js +121 -89
- package/dist/Popup.d.ts +18 -0
- package/dist/Popup.d.ts.map +1 -0
- package/dist/Popup.js +215 -0
- package/dist/Radio.d.ts +12 -0
- package/dist/Radio.d.ts.map +1 -0
- package/dist/Radio.js +9 -8
- package/dist/RadioGroup.d.ts +20 -0
- package/dist/RadioGroup.d.ts.map +1 -0
- package/dist/RadioGroup.js +41 -39
- package/dist/ScrollTop.d.ts +19 -0
- package/dist/ScrollTop.d.ts.map +1 -0
- package/dist/ScrollTop.js +122 -0
- package/dist/Select.d.ts +98 -0
- package/dist/Select.d.ts.map +1 -0
- package/dist/Select.js +79 -122
- package/dist/Table.d.ts +48 -0
- package/dist/Table.d.ts.map +1 -0
- package/dist/Table.js +141 -121
- package/dist/VisuallyHidden.d.ts +8 -0
- package/dist/VisuallyHidden.d.ts.map +1 -0
- package/dist/VisuallyHidden.js +28 -0
- package/dist/_rollupPluginBabelHelpers-20f659f4.d.ts +3 -0
- package/dist/_rollupPluginBabelHelpers-20f659f4.d.ts.map +1 -0
- package/dist/{defineElement-ba770aed.js → _rollupPluginBabelHelpers-20f659f4.js} +1 -15
- package/dist/defineElement-40372b4b.d.ts +9 -0
- package/dist/defineElement-40372b4b.d.ts.map +1 -0
- package/dist/defineElement-40372b4b.js +15 -0
- package/dist/icon-03e86700.d.ts +11 -0
- package/dist/icon-03e86700.d.ts.map +1 -0
- package/dist/index.js.d.ts +21 -0
- package/dist/index.js.d.ts.map +1 -0
- package/dist/index.js.js +42 -0
- package/dist/leu-accordion.d.ts +3 -0
- package/dist/leu-accordion.d.ts.map +1 -0
- package/dist/leu-accordion.js +9 -0
- package/dist/leu-breadcrumb.d.ts +3 -0
- package/dist/leu-breadcrumb.d.ts.map +1 -0
- package/dist/leu-breadcrumb.js +23 -0
- package/dist/leu-button-group.d.ts +3 -0
- package/dist/leu-button-group.d.ts.map +1 -0
- package/dist/leu-button-group.js +6 -6
- package/dist/leu-button.d.ts +3 -0
- package/dist/leu-button.d.ts.map +1 -0
- package/dist/leu-button.js +7 -3
- package/dist/leu-checkbox-group.d.ts +3 -0
- package/dist/leu-checkbox-group.d.ts.map +1 -0
- package/dist/leu-checkbox-group.js +6 -3
- package/dist/leu-checkbox.d.ts +3 -0
- package/dist/leu-checkbox.d.ts.map +1 -0
- package/dist/leu-checkbox.js +6 -3
- package/dist/leu-chip-group.d.ts +3 -0
- package/dist/leu-chip-group.d.ts.map +1 -0
- package/dist/leu-chip-group.js +7 -3
- package/dist/leu-chip-link.d.ts +3 -0
- package/dist/leu-chip-link.d.ts.map +1 -0
- package/dist/leu-chip-link.js +7 -4
- package/dist/leu-chip-removable.d.ts +3 -0
- package/dist/leu-chip-removable.d.ts.map +1 -0
- package/dist/leu-chip-removable.js +7 -4
- package/dist/leu-chip-selectable.d.ts +3 -0
- package/dist/leu-chip-selectable.d.ts.map +1 -0
- package/dist/leu-chip-selectable.js +7 -4
- package/dist/leu-dropdown.d.ts +3 -0
- package/dist/leu-dropdown.d.ts.map +1 -0
- package/dist/leu-dropdown.js +15 -4
- package/dist/leu-input.d.ts +3 -0
- package/dist/leu-input.d.ts.map +1 -0
- package/dist/leu-input.js +7 -3
- package/dist/leu-menu-item.d.ts +3 -0
- package/dist/leu-menu-item.d.ts.map +1 -0
- package/dist/leu-menu-item.js +8 -3
- package/dist/leu-menu.d.ts +3 -0
- package/dist/leu-menu.d.ts.map +1 -0
- package/dist/leu-menu.js +6 -3
- package/dist/leu-pagination.d.ts +3 -0
- package/dist/leu-pagination.d.ts.map +1 -0
- package/dist/leu-pagination.js +12 -4
- package/dist/leu-popup.d.ts +3 -0
- package/dist/leu-popup.d.ts.map +1 -0
- package/dist/leu-popup.js +9 -0
- package/dist/leu-radio-group.d.ts +3 -0
- package/dist/leu-radio-group.d.ts.map +1 -0
- package/dist/leu-radio-group.js +6 -3
- package/dist/leu-radio.d.ts +3 -0
- package/dist/leu-radio.d.ts.map +1 -0
- package/dist/leu-radio.js +6 -3
- package/dist/leu-scroll-top.d.ts +3 -0
- package/dist/leu-scroll-top.d.ts.map +1 -0
- package/dist/leu-scroll-top.js +14 -0
- package/dist/leu-select.d.ts +3 -0
- package/dist/leu-select.d.ts.map +1 -0
- package/dist/leu-select.js +16 -4
- package/dist/leu-table.d.ts +3 -0
- package/dist/leu-table.d.ts.map +1 -0
- package/dist/leu-table.js +13 -4
- package/dist/leu-visually-hidden.d.ts +3 -0
- package/dist/leu-visually-hidden.d.ts.map +1 -0
- package/dist/leu-visually-hidden.js +8 -0
- package/dist/theme.css +386 -2
- package/dist/utils-65469421.d.ts +16 -0
- package/dist/utils-65469421.d.ts.map +1 -0
- package/dist/utils-65469421.js +35 -0
- package/index.js +3 -0
- package/package.json +47 -17
- package/postcss.config.cjs +2 -0
- package/rollup.config.js +21 -40
- package/scripts/generate-component/templates/[Name].js +0 -5
- package/scripts/generate-component/templates/[name].css +3 -3
- package/scripts/generate-component/templates/[namespace]-[name].js +5 -2
- package/scripts/postcss-leu-font-styles.cjs +160 -0
- package/src/components/accordion/Accordion.js +0 -6
- package/src/components/accordion/accordion.css +2 -2
- package/src/components/accordion/leu-accordion.js +5 -2
- package/src/components/accordion/stories/accordion.stories.js +8 -4
- package/src/components/accordion/test/accordion.test.js +95 -3
- package/src/components/breadcrumb/Breadcrumb.js +311 -0
- package/src/components/breadcrumb/breadcrumb.css +103 -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 +76 -20
- package/src/components/button/button.css +13 -5
- package/src/components/button/leu-button.js +5 -2
- package/src/components/button/stories/button.stories.js +79 -105
- package/src/components/button/test/button.test.js +184 -3
- package/src/components/button-group/ButtonGroup.js +76 -40
- package/src/components/button-group/leu-button-group.js +5 -2
- package/src/components/button-group/stories/button-group.stories.js +19 -6
- package/src/components/button-group/test/button-group.test.js +87 -4
- package/src/components/checkbox/Checkbox.js +6 -85
- package/src/components/checkbox/CheckboxGroup.js +8 -38
- 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 +1 -0
- package/src/components/chip/ChipGroup.js +42 -7
- package/src/components/chip/ChipLink.js +1 -6
- package/src/components/chip/ChipRemovable.js +2 -7
- package/src/components/chip/ChipSelectable.js +5 -10
- package/src/components/chip/chip-group.css +12 -2
- package/src/components/chip/chip.css +14 -3
- 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 +110 -44
- 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 +72 -24
- 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 +25 -28
- package/src/components/input/input.css +11 -8
- package/src/components/input/leu-input.js +5 -2
- package/src/components/input/stories/input.stories.js +21 -2
- package/src/components/input/test/input.test.js +432 -4
- package/src/components/menu/Menu.js +0 -5
- package/src/components/menu/MenuItem.js +20 -13
- 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 +7 -4
- 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 +118 -99
- package/src/components/pagination/leu-pagination.js +5 -2
- package/src/components/pagination/pagination.css +6 -1
- package/src/components/pagination/stories/pagination.stories.js +30 -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 +2 -6
- package/src/components/radio/RadioGroup.js +6 -38
- 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/radio.css +1 -1
- 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/scroll-top/ScrollTop.js +87 -0
- package/src/components/scroll-top/leu-scroll-top.js +6 -0
- package/src/components/scroll-top/scroll-top.css +34 -0
- package/src/components/scroll-top/stories/scroll-top.stories.js +217 -0
- package/src/components/scroll-top/test/scroll-top.test.js +22 -0
- package/src/components/select/Select.js +58 -37
- package/src/components/select/leu-select.js +5 -2
- package/src/components/select/select.css +15 -15
- 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 +43 -118
- 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/components/visually-hidden/VisuallyHidden.js +13 -0
- package/src/components/visually-hidden/leu-visually-hidden.js +6 -0
- package/src/components/visually-hidden/stories/visually-hidden.stories.js +22 -0
- package/src/components/visually-hidden/test/visually-hidden.test.js +36 -0
- package/src/components/visually-hidden/visually-hidden.css +10 -0
- package/src/lib/defineElement.js +1 -1
- package/src/lib/hasSlotController.js +5 -3
- package/src/lib/utils.js +35 -0
- package/src/styles/custom-properties.css +6 -2
- package/src/styles/font-definitions.json +202 -0
- package/stylelint.config.mjs +2 -0
- package/tsconfig.build.json +21 -0
- package/tsconfig.json +16 -0
- package/{web-dev-server-storybook.config.mjs → web-dev-server.config.mjs} +1 -2
- package/web-test-runner.config.mjs +15 -2
- package/dist/index.js +0 -26
package/rollup.config.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { globSync } from "glob"
|
|
2
|
+
import path from "path"
|
|
3
|
+
import { fileURLToPath } from "url"
|
|
1
4
|
import postcss from "rollup-plugin-postcss"
|
|
2
5
|
import postcssLit from "rollup-plugin-postcss-lit"
|
|
3
6
|
import { babel } from "@rollup/plugin-babel"
|
|
@@ -17,44 +20,25 @@ export const plugins = [
|
|
|
17
20
|
},
|
|
18
21
|
]
|
|
19
22
|
|
|
23
|
+
/**
|
|
24
|
+
* @type {import("rollup").RollupOptions}
|
|
25
|
+
*/
|
|
20
26
|
export default {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"./src/components/chip/ChipLink.js",
|
|
37
|
-
"./src/components/chip/ChipRemovable.js",
|
|
38
|
-
"./src/components/chip/ChipSelectable.js",
|
|
39
|
-
"./src/components/dropdown/leu-dropdown.js",
|
|
40
|
-
"./src/components/dropdown/Dropdown.js",
|
|
41
|
-
"./src/components/input/leu-input.js",
|
|
42
|
-
"./src/components/input/Input.js",
|
|
43
|
-
"./src/components/menu/leu-menu.js",
|
|
44
|
-
"./src/components/menu/leu-menu-item.js",
|
|
45
|
-
"./src/components/menu/Menu.js",
|
|
46
|
-
"./src/components/menu/MenuItem.js",
|
|
47
|
-
"./src/components/pagination/leu-pagination.js",
|
|
48
|
-
"./src/components/pagination/Pagination.js",
|
|
49
|
-
"./src/components/radio/leu-radio.js",
|
|
50
|
-
"./src/components/radio/leu-radio-group.js",
|
|
51
|
-
"./src/components/radio/Radio.js",
|
|
52
|
-
"./src/components/radio/RadioGroup.js",
|
|
53
|
-
"./src/components/select/leu-select.js",
|
|
54
|
-
"./src/components/select/Select.js",
|
|
55
|
-
"./src/components/table/leu-table.js",
|
|
56
|
-
"./src/components/table/Table.js",
|
|
57
|
-
],
|
|
27
|
+
// Select all files in a direct subdirectory of src/components
|
|
28
|
+
// that have a name starting with
|
|
29
|
+
// - a capital letter
|
|
30
|
+
// - or "leu-"
|
|
31
|
+
input: {
|
|
32
|
+
"index.js": "index.js",
|
|
33
|
+
...Object.fromEntries(
|
|
34
|
+
globSync("src/components/*/{[A-Z],leu-}*.js", { nocase: false }).map(
|
|
35
|
+
(file) => [
|
|
36
|
+
path.basename(file, path.extname(file)),
|
|
37
|
+
fileURLToPath(new URL(file, import.meta.url)),
|
|
38
|
+
]
|
|
39
|
+
)
|
|
40
|
+
),
|
|
41
|
+
},
|
|
58
42
|
output: {
|
|
59
43
|
dir: "./dist/",
|
|
60
44
|
format: "esm",
|
|
@@ -66,6 +50,3 @@ export default {
|
|
|
66
50
|
],
|
|
67
51
|
external: /^lit(\/.*\.js)?$/,
|
|
68
52
|
}
|
|
69
|
-
|
|
70
|
-
// TODO: add a second config for a bundle with esbuild
|
|
71
|
-
// import esbuild from "rollup-plugin-esbuild"
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { html, LitElement } from "lit"
|
|
2
|
-
import { defineElement } from "../../lib/defineElement.js"
|
|
3
2
|
import styles from "./[name].css"
|
|
4
3
|
|
|
5
4
|
/**
|
|
@@ -27,7 +26,3 @@ export class Leu[Name] extends LitElement {
|
|
|
27
26
|
`
|
|
28
27
|
}
|
|
29
28
|
}
|
|
30
|
-
|
|
31
|
-
export function define[Name]Elements() {
|
|
32
|
-
defineElement("[name]", [Namespace][Name])
|
|
33
|
-
}
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
:host {
|
|
7
|
-
--[name]-font-regular: var(--leu-font-regular);
|
|
8
|
-
--[name]-font-black: var(--leu-font-black);
|
|
7
|
+
--[name]-font-regular: var(--leu-font-family-regular);
|
|
8
|
+
--[name]-font-black: var(--leu-font-family-black);
|
|
9
9
|
|
|
10
|
-
font-family: var(--
|
|
10
|
+
font-family: var(--[name]-font-regular);
|
|
11
11
|
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineElement } from "../../lib/defineElement.js"
|
|
2
|
+
import { [Namespace][Name] } from "./[Name].js"
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
export { [Namespace][Name] }
|
|
5
|
+
|
|
6
|
+
defineElement("[name]", [Namespace][Name])
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
const path = require("path")
|
|
2
|
+
const fs = require("fs/promises")
|
|
3
|
+
|
|
4
|
+
/* Plugin logic */
|
|
5
|
+
|
|
6
|
+
function getPixelValue(value) {
|
|
7
|
+
return parseInt(value.replace("px", ""), 10)
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
async function parseFile(file) {
|
|
11
|
+
const string = await fs.readFile(file, "utf-8")
|
|
12
|
+
|
|
13
|
+
return JSON.parse(string)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function generateCustomPropertyDeclarations({
|
|
17
|
+
identifier,
|
|
18
|
+
fontSize,
|
|
19
|
+
fontWeight,
|
|
20
|
+
lineHeight,
|
|
21
|
+
spacing,
|
|
22
|
+
}) {
|
|
23
|
+
const customPropertyPrefix = `--leu-t-${identifier}-${fontWeight}`
|
|
24
|
+
|
|
25
|
+
const varFontSize = `${customPropertyPrefix}-font-size`
|
|
26
|
+
const varLineHeight = `${customPropertyPrefix}-line-height`
|
|
27
|
+
const varSpacing = `${customPropertyPrefix}-spacing`
|
|
28
|
+
const varFont = `${customPropertyPrefix}-font`
|
|
29
|
+
const varFontFamily = `--leu-font-family-${fontWeight}`
|
|
30
|
+
|
|
31
|
+
return [
|
|
32
|
+
{ type: "fontSize", name: varFontSize, value: `${fontSize / 16}rem` },
|
|
33
|
+
{ type: "lineHeight", name: varLineHeight, value: `${lineHeight}` },
|
|
34
|
+
{ type: "spacing", name: varSpacing, value: `${spacing}rem` },
|
|
35
|
+
{
|
|
36
|
+
type: "font",
|
|
37
|
+
name: varFont,
|
|
38
|
+
value: `var(${varFontSize}) / var(${varLineHeight}) var(${varFontFamily})`,
|
|
39
|
+
},
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function curveStepDeclarations(curvePrefix, stepStyle) {
|
|
44
|
+
const fontSizeVar = stepStyle.declarations.find(
|
|
45
|
+
(s) => s.type === "fontSize"
|
|
46
|
+
).name
|
|
47
|
+
const lineHeightVar = stepStyle.declarations.find(
|
|
48
|
+
(s) => s.type === "lineHeight"
|
|
49
|
+
).name
|
|
50
|
+
const spacingVar = stepStyle.declarations.find(
|
|
51
|
+
(s) => s.type === "spacing"
|
|
52
|
+
).name
|
|
53
|
+
const fontVar = stepStyle.declarations.find((s) => s.type === "font").name
|
|
54
|
+
|
|
55
|
+
return [
|
|
56
|
+
{ prop: `${curvePrefix}-font-size`, value: ` var(${fontSizeVar})` },
|
|
57
|
+
{ prop: `${curvePrefix}-line-height`, value: ` var(${lineHeightVar})` },
|
|
58
|
+
{ prop: `${curvePrefix}-spacing`, value: ` var(${spacingVar})` },
|
|
59
|
+
{ prop: `${curvePrefix}-font`, value: ` var(${fontVar})` },
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
*
|
|
65
|
+
* @param {*} file
|
|
66
|
+
* @param {import('postcss')} postcss
|
|
67
|
+
* @param {import('postcss').Source} nodeSource
|
|
68
|
+
* @returns
|
|
69
|
+
*/
|
|
70
|
+
async function createLeuFontStyleNodes(file, postcss, nodeSource) {
|
|
71
|
+
const { definitions, curves } = await parseFile(file)
|
|
72
|
+
|
|
73
|
+
const fontStyleDeclarations = definitions.flatMap((style) => {
|
|
74
|
+
const fontSize = getPixelValue(style.fontSize)
|
|
75
|
+
const fontWeights = Array.isArray(style.fontWeight)
|
|
76
|
+
? style.fontWeight
|
|
77
|
+
: [style.fontWeight]
|
|
78
|
+
const spacing = getPixelValue(style.spacing) / 16
|
|
79
|
+
|
|
80
|
+
const identifier = (fontSize / 4) * 10
|
|
81
|
+
|
|
82
|
+
return fontWeights.map((fontWeight) => ({
|
|
83
|
+
name: style.name,
|
|
84
|
+
fontWeight,
|
|
85
|
+
identifier,
|
|
86
|
+
declarations: generateCustomPropertyDeclarations({
|
|
87
|
+
identifier,
|
|
88
|
+
fontSize,
|
|
89
|
+
fontWeight,
|
|
90
|
+
lineHeight: style.lineHeight,
|
|
91
|
+
spacing,
|
|
92
|
+
}),
|
|
93
|
+
}))
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
const fontStyleNodes = fontStyleDeclarations.flatMap((style) =>
|
|
97
|
+
style.declarations.map(
|
|
98
|
+
({ name, value }) =>
|
|
99
|
+
new postcss.Declaration({ prop: name, value, source: nodeSource })
|
|
100
|
+
)
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
const curveNodes = curves.flatMap((curve) => {
|
|
104
|
+
const [_, lastStepName] = curve.steps.at(-1)
|
|
105
|
+
const { identifier } = fontStyleDeclarations.find(
|
|
106
|
+
(style) => style.name === lastStepName && style.fontWeight === "black"
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
const curvePrefix = `--leu-t-curve-${identifier}-black`
|
|
110
|
+
|
|
111
|
+
return curve.steps.flatMap((step) => {
|
|
112
|
+
const [viewport, styleName] = step
|
|
113
|
+
|
|
114
|
+
const stepStyle = fontStyleDeclarations.find(
|
|
115
|
+
(s) => s.name === styleName && s.fontWeight === "black"
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
const nodes = curveStepDeclarations(curvePrefix, stepStyle).map(
|
|
119
|
+
({ prop, value }) =>
|
|
120
|
+
new postcss.Declaration({ prop, value, source: nodeSource })
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
return viewport === null
|
|
124
|
+
? nodes
|
|
125
|
+
: new postcss.AtRule({
|
|
126
|
+
name: "media",
|
|
127
|
+
params: `(${viewport})`,
|
|
128
|
+
nodes,
|
|
129
|
+
source: nodeSource,
|
|
130
|
+
})
|
|
131
|
+
})
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
return [...fontStyleNodes, ...curveNodes]
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/* Plugin config */
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* @type {import('postcss').PluginCreator}
|
|
141
|
+
*/
|
|
142
|
+
module.exports = () => ({
|
|
143
|
+
postcssPlugin: "leu-font-styles",
|
|
144
|
+
AtRule: {
|
|
145
|
+
"leu-font-styles": async (atRule, postcss) => {
|
|
146
|
+
const rootDir = path.dirname(atRule.source.input.file)
|
|
147
|
+
const jsonFile = atRule.params.replace(/['"]+/g, "")
|
|
148
|
+
|
|
149
|
+
const nodes = await createLeuFontStyleNodes(
|
|
150
|
+
path.resolve(rootDir, jsonFile),
|
|
151
|
+
postcss,
|
|
152
|
+
atRule.source
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
atRule.replaceWith(nodes)
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
module.exports.postcss = true
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { LitElement, nothing } from "lit"
|
|
2
2
|
import { html, unsafeStatic } from "lit/static-html.js"
|
|
3
3
|
|
|
4
|
-
import { defineElement } from "../../lib/defineElement.js"
|
|
5
4
|
import styles from "./accordion.css"
|
|
6
5
|
|
|
7
6
|
/**
|
|
@@ -35,7 +34,6 @@ export class LeuAccordion extends LitElement {
|
|
|
35
34
|
this.headingLevel = 2
|
|
36
35
|
this.open = false
|
|
37
36
|
this.label = ""
|
|
38
|
-
this.labelPrefix = ""
|
|
39
37
|
}
|
|
40
38
|
|
|
41
39
|
/**
|
|
@@ -96,7 +94,3 @@ export class LeuAccordion extends LitElement {
|
|
|
96
94
|
}
|
|
97
95
|
/* eslint-enable lit/binding-positions, lit/no-invalid-html */
|
|
98
96
|
}
|
|
99
|
-
|
|
100
|
-
export function defineAccordionElements() {
|
|
101
|
-
defineElement("accordion", LeuAccordion)
|
|
102
|
-
}
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
:host {
|
|
9
|
-
--accordion-font-regular: var(--leu-font-regular);
|
|
10
|
-
--accordion-font-black: var(--leu-font-black);
|
|
9
|
+
--accordion-font-regular: var(--leu-font-family-regular);
|
|
10
|
+
--accordion-font-black: var(--leu-font-family-black);
|
|
11
11
|
|
|
12
12
|
--accordion-toggle-font: var(--accordion-font-black);
|
|
13
13
|
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineElement } from "../../lib/defineElement.js"
|
|
2
|
+
import { LeuAccordion } from "./Accordion.js"
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
export { LeuAccordion }
|
|
5
|
+
|
|
6
|
+
defineElement("accordion", LeuAccordion)
|
|
@@ -8,10 +8,8 @@ export default {
|
|
|
8
8
|
component: "leu-accordion",
|
|
9
9
|
argTypes: {
|
|
10
10
|
headingLevel: {
|
|
11
|
-
control:
|
|
12
|
-
|
|
13
|
-
options: [0, 1, 2, 3, 4, 5, 6],
|
|
14
|
-
},
|
|
11
|
+
control: "select",
|
|
12
|
+
options: [1, 2, 3, 4, 5, 6],
|
|
15
13
|
},
|
|
16
14
|
content: {
|
|
17
15
|
control: {
|
|
@@ -19,6 +17,12 @@ export default {
|
|
|
19
17
|
},
|
|
20
18
|
},
|
|
21
19
|
},
|
|
20
|
+
parameters: {
|
|
21
|
+
design: {
|
|
22
|
+
type: "figma",
|
|
23
|
+
url: "https://www.figma.com/file/d6Pv21UVUbnBs3AdcZijHmbN/KTZH-Design-System?type=design&node-id=17341-82464&mode=design&t=lzVrtq8lxYVJU5TB-11",
|
|
24
|
+
},
|
|
25
|
+
},
|
|
22
26
|
}
|
|
23
27
|
|
|
24
28
|
function Template(args) {
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { html } from "lit"
|
|
2
|
-
import { fixture, expect } from "@open-wc/testing"
|
|
2
|
+
import { fixture, expect, elementUpdated, aTimeout } from "@open-wc/testing"
|
|
3
3
|
|
|
4
4
|
import "../leu-accordion.js"
|
|
5
5
|
|
|
6
6
|
async function defaultFixture() {
|
|
7
|
-
return fixture(
|
|
7
|
+
return fixture(
|
|
8
|
+
html` <leu-accordion label="Titel des Akkordeons"></leu-accordion> `
|
|
9
|
+
)
|
|
8
10
|
}
|
|
9
11
|
|
|
10
12
|
describe("LeuAccordion", () => {
|
|
11
13
|
it("is a defined element", async () => {
|
|
12
|
-
const el =
|
|
14
|
+
const el = customElements.get("leu-accordion")
|
|
13
15
|
|
|
14
16
|
await expect(el).not.to.be.undefined
|
|
15
17
|
})
|
|
@@ -19,4 +21,94 @@ describe("LeuAccordion", () => {
|
|
|
19
21
|
|
|
20
22
|
await expect(el).shadowDom.to.be.accessible()
|
|
21
23
|
})
|
|
24
|
+
|
|
25
|
+
it("renders the correct heading tag", async () => {
|
|
26
|
+
const el = await defaultFixture()
|
|
27
|
+
|
|
28
|
+
await expect(el._getHeadingTag()).to.equal("h2")
|
|
29
|
+
|
|
30
|
+
el.headingLevel = 1
|
|
31
|
+
await expect(el._getHeadingTag()).to.equal("h1")
|
|
32
|
+
|
|
33
|
+
el.headingLevel = 2
|
|
34
|
+
await expect(el._getHeadingTag()).to.equal("h2")
|
|
35
|
+
|
|
36
|
+
el.headingLevel = 3
|
|
37
|
+
await expect(el._getHeadingTag()).to.equal("h3")
|
|
38
|
+
|
|
39
|
+
el.headingLevel = 4
|
|
40
|
+
await expect(el._getHeadingTag()).to.equal("h4")
|
|
41
|
+
|
|
42
|
+
el.headingLevel = 5
|
|
43
|
+
await expect(el._getHeadingTag()).to.equal("h5")
|
|
44
|
+
|
|
45
|
+
el.headingLevel = 6
|
|
46
|
+
await expect(el._getHeadingTag()).to.equal("h6")
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
it("doesn't render an invalid heading tag", async () => {
|
|
50
|
+
const el = await defaultFixture()
|
|
51
|
+
|
|
52
|
+
el.headingLevel = 10
|
|
53
|
+
expect(el._getHeadingTag()).to.equal("h2")
|
|
54
|
+
|
|
55
|
+
el.headingLevel = -1
|
|
56
|
+
expect(el._getHeadingTag()).to.equal("h2")
|
|
57
|
+
|
|
58
|
+
el.headingLevel = 0
|
|
59
|
+
expect(el._getHeadingTag()).to.equal("h2")
|
|
60
|
+
|
|
61
|
+
el.headingLevel = "h3"
|
|
62
|
+
expect(el._getHeadingTag()).to.equal("h2")
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
it("toggles the open state", async () => {
|
|
66
|
+
const el = await fixture(
|
|
67
|
+
html`<leu-accordion label="Titel des Akkordeons"
|
|
68
|
+
><div slot="content">Das ist der Inhalt</div></leu-accordion
|
|
69
|
+
>`
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
const button = el.shadowRoot.querySelector("button")
|
|
73
|
+
|
|
74
|
+
expect(el.open).to.be.false
|
|
75
|
+
|
|
76
|
+
button.click()
|
|
77
|
+
expect(el.open).to.be.true
|
|
78
|
+
|
|
79
|
+
button.click()
|
|
80
|
+
expect(el.open).to.be.false
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
it("doesn't show the content when it is closed", async () => {
|
|
84
|
+
const el = await fixture(
|
|
85
|
+
html`<leu-accordion label="Titel des Akkordeons"
|
|
86
|
+
><div slot="content">Das ist der Inhalt</div></leu-accordion
|
|
87
|
+
>`
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
const button = el.shadowRoot.querySelector("button")
|
|
91
|
+
const content = el.querySelector("[slot=content]")
|
|
92
|
+
|
|
93
|
+
expect(content).not.to.be.visible
|
|
94
|
+
|
|
95
|
+
button.click()
|
|
96
|
+
await elementUpdated(el)
|
|
97
|
+
await aTimeout(100)
|
|
98
|
+
expect(content).to.be.visible
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
it("shows the label prefix before the label", async () => {
|
|
102
|
+
const el = await fixture(
|
|
103
|
+
html`<leu-accordion
|
|
104
|
+
label-prefix="01"
|
|
105
|
+
label="Titel des Akkordeons"
|
|
106
|
+
></leu-accordion>`
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
const button = el.shadowRoot.querySelector("button")
|
|
110
|
+
|
|
111
|
+
expect(button).to.contain.text("01")
|
|
112
|
+
expect(button).to.contain.text("Titel des Akkordeons")
|
|
113
|
+
})
|
|
22
114
|
})
|