@statistikzh/leu 0.28.1 → 0.28.3
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/dist/{Accordion-CwkI7sfx.js → Accordion-EwJ1WHFd.js} +1 -1
- package/dist/Accordion.js +2 -2
- package/dist/{Button-DcuvEVkC.d.ts → Button-BywuwtT2.d.ts} +0 -1
- package/dist/{Button-D1aYnunQ.js → Button-q4GeKj_3.js} +3 -4
- package/dist/Button.d.ts +1 -1
- package/dist/Button.js +4 -4
- package/dist/{ButtonGroup-CqThYjzX.js → ButtonGroup-BeU3Prei.js} +2 -2
- package/dist/ButtonGroup.js +5 -5
- package/dist/{ChartWrapper-BjVT4x-H.js → ChartWrapper-Bdb0_n2z.js} +2 -2
- package/dist/ChartWrapper.js +3 -3
- package/dist/{Checkbox-HxYqp2w4.js → Checkbox-BC0gAuaH.js} +2 -2
- package/dist/Checkbox.js +3 -3
- package/dist/{CheckboxGroup-DYws2rwt.js → CheckboxGroup-CiOgcwmo.js} +2 -2
- package/dist/CheckboxGroup.js +4 -4
- package/dist/{Chip-gKxD6IaZ.js → Chip-CYlPzmTG.js} +1 -1
- package/dist/Chip.js +2 -2
- package/dist/{ChipGroup-ZvBzX_wd.js → ChipGroup-3IMW_Mp7.js} +1 -1
- package/dist/ChipGroup.js +3 -3
- package/dist/ChipLink.js +2 -2
- package/dist/ChipRemovable.js +3 -3
- package/dist/ChipSelectable.js +2 -2
- package/dist/{Dialog-BYpzTprV.js → Dialog-DCl5qSXY.js} +3 -4
- package/dist/Dialog.js +3 -3
- package/dist/{Dropdown-C4CgE4E-.js → Dropdown-COmpmOev.js} +5 -5
- package/dist/Dropdown.d.ts +1 -1
- package/dist/Dropdown.js +8 -8
- package/dist/{FileInput-nsnSQCaU.js → FileInput-DXjoqKB4.js} +4 -4
- package/dist/FileInput.d.ts +1 -1
- package/dist/FileInput.js +6 -6
- package/dist/{Icon-D8HTPEFH.js → Icon-Bmk7lLWY.js} +1 -1
- package/dist/Icon.js +2 -2
- package/dist/{Input-OrILqlax.js → Input-B9FwAPKO.js} +2 -2
- package/dist/Input.js +3 -3
- package/dist/{LeuElement-C_lcHzQI.js → LeuElement-CQJQi8TB.js} +1 -1
- package/dist/{Menu-CFLCnI34.js → Menu-bWCAn0rT.js} +2 -2
- package/dist/Menu.js +4 -4
- package/dist/{MenuItem-ICjLCGim.js → MenuItem-CzCFZi8o.js} +2 -2
- package/dist/MenuItem.js +3 -3
- package/dist/{Message-Dw5D_0i1.js → Message-DMaM9ukF.js} +2 -2
- package/dist/Message.js +3 -3
- package/dist/{Pagination-D1tP5FrM.js → Pagination-870u3UgQ.js} +4 -4
- package/dist/{Pagination-9eZ8WMvR.d.ts → Pagination-B-mTHZiw.d.ts} +1 -1
- package/dist/Pagination.d.ts +1 -1
- package/dist/Pagination.js +6 -6
- package/dist/{Placeholder-CnGzCZ5-.js → Placeholder-DvvzGB1p.js} +1 -1
- package/dist/Placeholder.js +2 -2
- package/dist/{Popup-BiN_tZDN.js → Popup-BpG_7twr.js} +1 -1
- package/dist/Popup.js +2 -2
- package/dist/{ProgressBar-BfJo_KyU.js → ProgressBar-BkskTLWK.js} +1 -1
- package/dist/ProgressBar.js +2 -2
- package/dist/{Radio-CV7vuQUj.js → Radio-BS7UUhR3.js} +1 -1
- package/dist/Radio.js +2 -2
- package/dist/{RadioGroup-C3XWSScc.js → RadioGroup-Cpo9kAjB.js} +2 -2
- package/dist/RadioGroup.js +3 -3
- package/dist/{Range-C8RVrIM9.js → Range-Dh0p5UWA.js} +1 -1
- package/dist/Range.js +2 -2
- package/dist/{ScrollTop-B_TJ_k4m.js → ScrollTop-CtPidICZ.js} +3 -3
- package/dist/ScrollTop.d.ts +1 -1
- package/dist/ScrollTop.js +5 -5
- package/dist/{Select-CbPTrL3G.js → Select-W1KqDOgx.js} +7 -7
- package/dist/Select.d.ts +1 -1
- package/dist/Select.js +9 -9
- package/dist/{Spinner-ChKJQJTN.js → Spinner-CmAYIFws.js} +1 -1
- package/dist/Spinner.js +2 -2
- package/dist/{Tab-BJbzY1xd.js → Tab-7Cww5fSx.js} +1 -1
- package/dist/Tab.js +2 -2
- package/dist/{TabGroup-BIaCHrKR.js → TabGroup-tURfCrlw.js} +3 -3
- package/dist/TabGroup.js +4 -4
- package/dist/{TabPanel-CTyw410b.js → TabPanel-DIZcmcMV.js} +1 -1
- package/dist/TabPanel.js +2 -2
- package/dist/{Table-D3QmePJd.js → Table-BVYjYXP9.js} +3 -3
- package/dist/Table.d.ts +1 -1
- package/dist/Table.js +7 -7
- package/dist/{Tag-nUnWtHYy.js → Tag-x0KmEDEa.js} +1 -1
- package/dist/Tag.js +2 -2
- package/dist/{VisuallyHidden-DF2q9pTa.js → VisuallyHidden-CXRfGsaZ.js} +1 -1
- package/dist/VisuallyHidden.js +2 -2
- package/dist/custom-elements.json +6445 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +30 -30
- package/dist/leu-accordion.js +2 -2
- package/dist/leu-button-group.js +5 -5
- package/dist/leu-button.d.ts +1 -1
- package/dist/leu-button.js +4 -4
- package/dist/leu-chart-wrapper.js +3 -3
- package/dist/leu-checkbox-group.js +4 -4
- package/dist/leu-checkbox.js +3 -3
- package/dist/leu-chip-group.js +3 -3
- package/dist/leu-chip-link.js +2 -2
- package/dist/leu-chip-removable.js +3 -3
- package/dist/leu-chip-selectable.js +2 -2
- package/dist/leu-dialog.js +3 -3
- package/dist/leu-dropdown.js +8 -8
- package/dist/leu-file-input.js +6 -6
- package/dist/leu-icon.js +2 -2
- package/dist/leu-input.js +3 -3
- package/dist/leu-menu-item.js +3 -3
- package/dist/leu-menu.js +4 -4
- package/dist/leu-message.js +3 -3
- package/dist/leu-pagination.d.ts +1 -1
- package/dist/leu-pagination.js +6 -6
- package/dist/leu-placeholder.js +2 -2
- package/dist/leu-popup.js +2 -2
- package/dist/leu-progress-bar.js +2 -2
- package/dist/leu-radio-group.js +3 -3
- package/dist/leu-radio.js +2 -2
- package/dist/leu-range.js +2 -2
- package/dist/leu-scroll-top.js +5 -5
- package/dist/leu-select.js +9 -9
- package/dist/leu-spinner.js +2 -2
- package/dist/leu-tab-group.js +4 -4
- package/dist/leu-tab-panel.js +2 -2
- package/dist/leu-tab.js +2 -2
- package/dist/leu-table.js +7 -7
- package/dist/leu-tag.js +2 -2
- package/dist/leu-visually-hidden.js +2 -2
- package/dist/vscode.html-custom-data.json +11 -11
- package/dist/vue/index.d.ts +20 -20
- package/dist/web-types.json +28 -28
- package/package.json +4 -1
- package/.editorconfig +0 -29
- package/.github/workflows/ci.yml +0 -81
- package/.github/workflows/deploy-github-pages.yaml +0 -34
- package/.github/workflows/publish.yml +0 -28
- package/.github/workflows/release-please.yml +0 -19
- package/.husky/commit-msg +0 -1
- package/.husky/pre-commit +0 -1
- package/.nvmrc +0 -1
- package/.prettierignore +0 -2
- package/.release-please-manifest.json +0 -3
- package/.storybook/main.ts +0 -34
- package/.storybook/manager-head.html +0 -1
- package/.storybook/manager.ts +0 -6
- package/.storybook/preview.ts +0 -96
- package/.storybook/static/fonts/Inter-Black.woff2 +0 -0
- package/.storybook/static/fonts/Inter-Regular.woff2 +0 -0
- package/.storybook/static/fonts.css +0 -11
- package/.storybook/static/global.css +0 -5
- package/.storybook/static/logo.svg +0 -19
- package/.storybook/theme.ts +0 -8
- package/AGENTS.md +0 -162
- package/CHANGELOG.md +0 -601
- package/CODE_OF_CONDUCT.md +0 -128
- package/CONTRIBUTING.md +0 -42
- package/commitlint.config.cjs +0 -1
- package/custom-elements-manifest.config.js +0 -46
- package/eslint.config.mjs +0 -79
- package/postcss.config.cjs +0 -16
- package/release-please-config.json +0 -9
- package/scripts/generate-component/generate.js +0 -167
- package/scripts/generate-component/templates/[Name].ts +0 -31
- package/scripts/generate-component/templates/[name].css +0 -6
- package/scripts/generate-component/templates/[namespace]-[name].ts +0 -11
- package/scripts/generate-component/templates/stories/[name].stories.ts +0 -26
- package/scripts/generate-component/templates/test/[name].test.ts +0 -23
- package/scripts/postcss-leu-font-styles.cjs +0 -154
- package/src/components/accordion/Accordion.ts +0 -108
- package/src/components/accordion/accordion.css +0 -150
- package/src/components/accordion/leu-accordion.ts +0 -11
- package/src/components/accordion/stories/accordion.stories.ts +0 -62
- package/src/components/accordion/test/accordion.test.ts +0 -118
- package/src/components/button/Button.ts +0 -286
- package/src/components/button/button.css +0 -317
- package/src/components/button/leu-button.ts +0 -11
- package/src/components/button/stories/button.stories.ts +0 -366
- package/src/components/button/test/button.test.ts +0 -417
- package/src/components/button-group/ButtonGroup.ts +0 -97
- package/src/components/button-group/button-group.css +0 -5
- package/src/components/button-group/leu-button-group.ts +0 -11
- package/src/components/button-group/stories/button-group.stories.ts +0 -54
- package/src/components/button-group/test/button-group.test.ts +0 -105
- package/src/components/chart-wrapper/ChartWrapper.ts +0 -78
- package/src/components/chart-wrapper/chart-wrapper.css +0 -87
- package/src/components/chart-wrapper/leu-chart-wrapper.ts +0 -11
- package/src/components/chart-wrapper/stories/chart-wrapper.stories.ts +0 -58
- package/src/components/chart-wrapper/test/chart-wrapper.test.ts +0 -77
- package/src/components/checkbox/Checkbox.ts +0 -129
- package/src/components/checkbox/CheckboxGroup.ts +0 -57
- package/src/components/checkbox/checkbox-group.css +0 -29
- package/src/components/checkbox/checkbox.css +0 -81
- package/src/components/checkbox/leu-checkbox-group.ts +0 -11
- package/src/components/checkbox/leu-checkbox.ts +0 -11
- package/src/components/checkbox/stories/checkbox-group.stories.ts +0 -59
- package/src/components/checkbox/stories/checkbox.stories.ts +0 -72
- package/src/components/checkbox/test/checkbox-group.test.ts +0 -109
- package/src/components/checkbox/test/checkbox.test.ts +0 -247
- package/src/components/chip/Chip.ts +0 -19
- package/src/components/chip/ChipGroup.ts +0 -122
- package/src/components/chip/ChipLink.ts +0 -24
- package/src/components/chip/ChipRemovable.ts +0 -45
- package/src/components/chip/ChipSelectable.ts +0 -80
- package/src/components/chip/chip-group.css +0 -15
- package/src/components/chip/chip.css +0 -139
- package/src/components/chip/exports.ts +0 -4
- package/src/components/chip/leu-chip-group.ts +0 -11
- package/src/components/chip/leu-chip-link.ts +0 -11
- package/src/components/chip/leu-chip-removable.ts +0 -11
- package/src/components/chip/leu-chip-selectable.ts +0 -11
- package/src/components/chip/stories/chip-group.stories.ts +0 -159
- package/src/components/chip/stories/chip-link.stories.ts +0 -45
- package/src/components/chip/stories/chip-removable.stories.ts +0 -42
- package/src/components/chip/stories/chip-selectable.stories.ts +0 -54
- package/src/components/chip/test/chip-group.test.ts +0 -171
- package/src/components/chip/test/chip-link.test.ts +0 -54
- package/src/components/chip/test/chip-removable.test.ts +0 -105
- package/src/components/chip/test/chip-selectable.test.ts +0 -101
- package/src/components/chip/test/chip.test.ts +0 -22
- package/src/components/dialog/Dialog.ts +0 -86
- package/src/components/dialog/dialog.css +0 -157
- package/src/components/dialog/leu-dialog.ts +0 -11
- package/src/components/dialog/stories/dialog.stories.ts +0 -142
- package/src/components/dialog/test/dialog.test.ts +0 -85
- package/src/components/dropdown/Dropdown.ts +0 -152
- package/src/components/dropdown/dropdown.css +0 -16
- package/src/components/dropdown/leu-dropdown.ts +0 -11
- package/src/components/dropdown/stories/dropdown.stories.ts +0 -58
- package/src/components/dropdown/test/dropdown.test.ts +0 -59
- package/src/components/file-input/FileInput.ts +0 -324
- package/src/components/file-input/file-input.css +0 -118
- package/src/components/file-input/leu-file-input.ts +0 -11
- package/src/components/file-input/stories/file-input.stories.ts +0 -45
- package/src/components/file-input/test/file-input.test.ts +0 -62
- package/src/components/icon/Icon.ts +0 -47
- package/src/components/icon/icon.css +0 -10
- package/src/components/icon/leu-icon.ts +0 -11
- package/src/components/icon/paths.ts +0 -219
- package/src/components/icon/stories/icon.stories.ts +0 -79
- package/src/components/icon/test/icon.test.ts +0 -50
- package/src/components/input/Input.ts +0 -469
- package/src/components/input/input.css +0 -238
- package/src/components/input/leu-input.ts +0 -11
- package/src/components/input/stories/input.stories.ts +0 -204
- package/src/components/input/test/input.test.ts +0 -603
- package/src/components/menu/Menu.ts +0 -149
- package/src/components/menu/MenuItem.ts +0 -168
- package/src/components/menu/leu-menu-item.ts +0 -11
- package/src/components/menu/leu-menu.ts +0 -11
- package/src/components/menu/menu-item.css +0 -77
- package/src/components/menu/menu.css +0 -19
- package/src/components/menu/stories/menu-item.stories.ts +0 -81
- package/src/components/menu/stories/menu.stories.ts +0 -54
- package/src/components/menu/test/menu-item.test.ts +0 -210
- package/src/components/menu/test/menu.test.ts +0 -125
- package/src/components/message/Message.ts +0 -118
- package/src/components/message/leu-message.ts +0 -11
- package/src/components/message/message.css +0 -163
- package/src/components/message/stories/message.mdx +0 -76
- package/src/components/message/stories/message.stories.ts +0 -149
- package/src/components/message/test/message.test.ts +0 -96
- package/src/components/pagination/Pagination.ts +0 -192
- package/src/components/pagination/leu-pagination.ts +0 -11
- package/src/components/pagination/pagination.css +0 -54
- package/src/components/pagination/stories/pagination.stories.ts +0 -115
- package/src/components/pagination/test/pagination.test.ts +0 -210
- package/src/components/placeholder/Placeholder.ts +0 -33
- package/src/components/placeholder/leu-placeholder.ts +0 -11
- package/src/components/placeholder/placeholder.css +0 -59
- package/src/components/placeholder/stories/placeholder.stories.ts +0 -34
- package/src/components/placeholder/test/placeholder.test.ts +0 -31
- package/src/components/popup/Popup.ts +0 -264
- package/src/components/popup/leu-popup.ts +0 -11
- package/src/components/popup/popup.css +0 -24
- package/src/components/popup/stories/popup.stories.ts +0 -117
- package/src/components/popup/test/popup.test.ts +0 -90
- package/src/components/progress-bar/ProgressBar.ts +0 -52
- package/src/components/progress-bar/leu-progress-bar.ts +0 -11
- package/src/components/progress-bar/progress-bar.css +0 -97
- package/src/components/progress-bar/stories/progress-bar.stories.ts +0 -39
- package/src/components/progress-bar/test/progress-bar.test.ts +0 -61
- package/src/components/radio/Radio.ts +0 -59
- package/src/components/radio/RadioGroup.ts +0 -181
- package/src/components/radio/leu-radio-group.ts +0 -11
- package/src/components/radio/leu-radio.ts +0 -11
- package/src/components/radio/radio-group.css +0 -29
- package/src/components/radio/radio.css +0 -76
- package/src/components/radio/stories/radio-group.stories.ts +0 -54
- package/src/components/radio/stories/radio.stories.ts +0 -55
- package/src/components/radio/test/radio-group.test.ts +0 -83
- package/src/components/radio/test/radio.test.ts +0 -119
- package/src/components/range/Range.ts +0 -400
- package/src/components/range/leu-range.ts +0 -11
- package/src/components/range/range.css +0 -227
- package/src/components/range/stories/range.stories.ts +0 -185
- package/src/components/range/test/range.test.ts +0 -228
- package/src/components/scroll-top/ScrollTop.ts +0 -91
- package/src/components/scroll-top/leu-scroll-top.ts +0 -11
- package/src/components/scroll-top/scroll-top.css +0 -50
- package/src/components/scroll-top/stories/scroll-top.stories.ts +0 -217
- package/src/components/scroll-top/test/scroll-top.test.ts +0 -22
- package/src/components/select/Select.ts +0 -570
- package/src/components/select/leu-select.ts +0 -11
- package/src/components/select/select.css +0 -222
- package/src/components/select/stories/select.stories.ts +0 -173
- package/src/components/select/test/fixtures.ts +0 -162
- package/src/components/select/test/select.test.ts +0 -937
- package/src/components/spinner/Spinner.ts +0 -31
- package/src/components/spinner/leu-spinner.ts +0 -11
- package/src/components/spinner/spinner.css +0 -20
- package/src/components/spinner/stories/spinner.stories.ts +0 -29
- package/src/components/spinner/test/spinner.test.ts +0 -30
- package/src/components/tab/Tab.ts +0 -72
- package/src/components/tab/TabGroup.ts +0 -267
- package/src/components/tab/TabPanel.ts +0 -59
- package/src/components/tab/leu-tab-group.ts +0 -11
- package/src/components/tab/leu-tab-panel.ts +0 -11
- package/src/components/tab/leu-tab.ts +0 -11
- package/src/components/tab/stories/tab.stories.ts +0 -97
- package/src/components/tab/tab-group.css +0 -63
- package/src/components/tab/tab-panel.css +0 -10
- package/src/components/tab/tab.css +0 -54
- package/src/components/tab/test/tab-group.test.ts +0 -426
- package/src/components/tab/test/tab-panel.test.ts +0 -102
- package/src/components/tab/test/tab.test.ts +0 -139
- package/src/components/table/Table.ts +0 -253
- package/src/components/table/leu-table.ts +0 -11
- package/src/components/table/stories/table.stories.ts +0 -131
- package/src/components/table/table.css +0 -112
- package/src/components/table/test/table.test.ts +0 -37
- package/src/components/tag/Tag.ts +0 -28
- package/src/components/tag/leu-tag.ts +0 -11
- package/src/components/tag/stories/tag.stories.ts +0 -107
- package/src/components/tag/tag.css +0 -42
- package/src/components/tag/test/tag.test.ts +0 -28
- package/src/components/visually-hidden/VisuallyHidden.ts +0 -16
- package/src/components/visually-hidden/leu-visually-hidden.ts +0 -11
- package/src/components/visually-hidden/stories/visually-hidden.stories.ts +0 -22
- package/src/components/visually-hidden/test/visually-hidden.test.ts +0 -34
- package/src/components/visually-hidden/visually-hidden.css +0 -10
- package/src/docs/contributing.mdx +0 -154
- package/src/docs/installation.mdx +0 -35
- package/src/docs/theme.mdx +0 -400
- package/src/docs/usage.mdx +0 -73
- package/src/global.d.ts +0 -11
- package/src/index.ts +0 -29
- package/src/lib/LeuElement.ts +0 -43
- package/src/lib/a11y.ts +0 -26
- package/src/lib/hasSlotController.ts +0 -74
- package/src/lib/mixins/FormAssociatedMixin.ts +0 -115
- package/src/lib/styleMap.ts +0 -139
- package/src/lib/utils.ts +0 -45
- package/src/styles/common-styles.css +0 -14
- package/src/styles/custom-media.css +0 -6
- package/src/styles/font-definitions.json +0 -210
- package/src/styles/style.stories.ts +0 -64
- package/src/styles/theme.css +0 -90
- package/stat_zh.png +0 -0
- package/stylelint.config.mjs +0 -23
- package/tsconfig.build.json +0 -24
- package/tsconfig.json +0 -14
- package/tsdown.config.ts +0 -35
- package/web-test-runner.config.mjs +0 -102
package/src/docs/theme.mdx
DELETED
|
@@ -1,400 +0,0 @@
|
|
|
1
|
-
import { Meta, Markdown, Canvas } from "@storybook/addon-docs/blocks"
|
|
2
|
-
import React from "react"
|
|
3
|
-
|
|
4
|
-
import * as GridStories from "../styles/style.stories"
|
|
5
|
-
|
|
6
|
-
<Meta title="Introduction/Theme" />
|
|
7
|
-
|
|
8
|
-
export const ColorTable = ({ prefix, shades }) => {
|
|
9
|
-
return (
|
|
10
|
-
<table>
|
|
11
|
-
<thead>
|
|
12
|
-
<tr>
|
|
13
|
-
<th>Color</th>
|
|
14
|
-
<th>Property</th>
|
|
15
|
-
</tr>
|
|
16
|
-
</thead>
|
|
17
|
-
<tbody>
|
|
18
|
-
{shades.map((shade) => {
|
|
19
|
-
return (
|
|
20
|
-
<tr key={`${prefix}-${shade}`}>
|
|
21
|
-
<td
|
|
22
|
-
style={{
|
|
23
|
-
background:
|
|
24
|
-
"repeating-conic-gradient(var(--leu-color-black-10) 0% 25%, transparent 0% 50%) 50% / 20px 20px, white",
|
|
25
|
-
}}
|
|
26
|
-
>
|
|
27
|
-
<div
|
|
28
|
-
style={{
|
|
29
|
-
background: `var(--leu-color-${prefix}-${shade})`,
|
|
30
|
-
height: "1.5rem",
|
|
31
|
-
}}
|
|
32
|
-
></div>
|
|
33
|
-
</td>
|
|
34
|
-
<td>
|
|
35
|
-
--leu-color-{prefix}-{shade}
|
|
36
|
-
</td>
|
|
37
|
-
</tr>
|
|
38
|
-
)
|
|
39
|
-
})}
|
|
40
|
-
</tbody>
|
|
41
|
-
</table>
|
|
42
|
-
)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
# Theme
|
|
46
|
-
|
|
47
|
-
The styling of all the components rely on the theme stylesheet and its definitions. In order for the components to work and look right, you need to load the theme stylesheet globally.
|
|
48
|
-
The theme is a single stylesheet that just defines custom properties. It doesn't contain any global classes.
|
|
49
|
-
|
|
50
|
-
```html
|
|
51
|
-
<link rel="stylesheet" href="@statistikzh/leu/dist/theme.css" />
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
If you're "only" using the components then that's all you need to do.
|
|
55
|
-
|
|
56
|
-
The rest of the document explains what the theme contains and how it's structured.
|
|
57
|
-
This is helpful if you want to use the it to style your application or to build new components.
|
|
58
|
-
|
|
59
|
-
## Table of Contents
|
|
60
|
-
|
|
61
|
-
- [Design System](#design-system)
|
|
62
|
-
- [Quick start](#quick-start)
|
|
63
|
-
- [Structure of the file](#structure-of-the-file)
|
|
64
|
-
- [Custom property naming](#custom-property-naming)
|
|
65
|
-
- [Colors](#colors)
|
|
66
|
-
- [Box Shadows](#box-shadows)
|
|
67
|
-
- [z-index](#z-index)
|
|
68
|
-
- [Typography](#typography)
|
|
69
|
-
- [Layout](#layout)
|
|
70
|
-
|
|
71
|
-
---
|
|
72
|
-
|
|
73
|
-
## Design system
|
|
74
|
-
|
|
75
|
-
The theme is based on the official [design system](https://www.zh.ch/de/webangebote-entwickeln-und-gestalten.html). Every single custom property relates to a specific design token defined in the design system.
|
|
76
|
-
Currently there is no automatic workflow that generates the theme from the design system. The theme is manually updated when the design system changes.
|
|
77
|
-
If you spot any inconsistencies between the theme and the design system, please open an issue.
|
|
78
|
-
|
|
79
|
-
## Quick start
|
|
80
|
-
|
|
81
|
-
The following css snippet is a good starting point when you want to use the theme to style your application.
|
|
82
|
-
Details about the specific definitions can be found in the content below.
|
|
83
|
-
|
|
84
|
-
```css
|
|
85
|
-
html {
|
|
86
|
-
font-family: var(--leu-font-family-regular);
|
|
87
|
-
font-feature-settings: var(--leu-t-font-feature-settings);
|
|
88
|
-
|
|
89
|
-
/* Prevent browser from synthesizing font weights */
|
|
90
|
-
font-synthesis-weight: none;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
strong {
|
|
94
|
-
font-family: var(--leu-font-family-black);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/* Heading style mapping. Use whatever selector make sense in your project. */
|
|
98
|
-
h1 {
|
|
99
|
-
font: var(--leu-t-curve-huge-black-font);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
h2 {
|
|
103
|
-
font: var(--leu-t-curve-large-black-font);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
h3 {
|
|
107
|
-
font: var(--leu-t-curve-medium-black-font);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
h4 {
|
|
111
|
-
font: var(--leu-t-curve-regular-black-font);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/*
|
|
115
|
-
* Prevent "Flash of Unstyled Custom Elements" (FOUCE)
|
|
116
|
-
* https://www.abeautifulsite.net/posts/flash-of-undefined-custom-elements
|
|
117
|
-
*/
|
|
118
|
-
:not(:defined) {
|
|
119
|
-
visibility: hidden;
|
|
120
|
-
}
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
## Structure of the file
|
|
124
|
-
|
|
125
|
-
The theme contains custom properties for:
|
|
126
|
-
|
|
127
|
-
- Colors
|
|
128
|
-
- Box Shadows
|
|
129
|
-
- z-index
|
|
130
|
-
- Typography
|
|
131
|
-
- Grid
|
|
132
|
-
|
|
133
|
-
## Custom property naming
|
|
134
|
-
|
|
135
|
-
All custom properties of this theme are prefixed with `--leu`.
|
|
136
|
-
|
|
137
|
-
```css
|
|
138
|
-
:root {
|
|
139
|
-
--leu-color-black-100: #000;
|
|
140
|
-
}
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
## Colors
|
|
144
|
-
|
|
145
|
-
The colors are split into different categories (black, white, accent, functional).
|
|
146
|
-
Each of the categories have a specific prefix.
|
|
147
|
-
|
|
148
|
-
An overview of all the colors can be found in the [figma file](https://www.figma.com/design/d6Pv21UVUbnBs3AdcZijHmbN/KTZH-Design-System?node-id=278-297&p=f&t=9QQZarLNjSn1og6x-11).
|
|
149
|
-
|
|
150
|
-
### Shades of black
|
|
151
|
-
|
|
152
|
-
The design system uses two different kind of black shades. One with transparency and one without.
|
|
153
|
-
Consult the figma file to find out when to use which.
|
|
154
|
-
|
|
155
|
-
<ColorTable prefix="black" shades={[100, 80, 60, 40, 20, 10, 5, 0]} />
|
|
156
|
-
|
|
157
|
-
#### Shades with transparency
|
|
158
|
-
|
|
159
|
-
<ColorTable prefix="black-transp" shades={[80, 60, 40, 20, 10, 5]} />
|
|
160
|
-
|
|
161
|
-
### Shaeds of white
|
|
162
|
-
|
|
163
|
-
<ColorTable prefix="white-transp" shades={[90, 70, 40, 10]} />
|
|
164
|
-
|
|
165
|
-
### Accent colors
|
|
166
|
-
|
|
167
|
-
<ColorTable
|
|
168
|
-
prefix="accent"
|
|
169
|
-
shades={[
|
|
170
|
-
"blue",
|
|
171
|
-
"darkblue",
|
|
172
|
-
"turquoise",
|
|
173
|
-
"green",
|
|
174
|
-
"bordeaux",
|
|
175
|
-
"magenta",
|
|
176
|
-
"violet",
|
|
177
|
-
"gray",
|
|
178
|
-
]}
|
|
179
|
-
/>
|
|
180
|
-
<ColorTable
|
|
181
|
-
prefix="accent"
|
|
182
|
-
shades={[
|
|
183
|
-
"blue-soft",
|
|
184
|
-
"darkblue-soft",
|
|
185
|
-
"turquoise-soft",
|
|
186
|
-
"green-soft",
|
|
187
|
-
"bordeaux-soft",
|
|
188
|
-
"magenta-soft",
|
|
189
|
-
"violet-soft",
|
|
190
|
-
"gray-soft",
|
|
191
|
-
]}
|
|
192
|
-
/>
|
|
193
|
-
|
|
194
|
-
### Functional colors
|
|
195
|
-
|
|
196
|
-
<ColorTable prefix="func" shades={["cyan", "red", "green"]} />
|
|
197
|
-
|
|
198
|
-
## Box Shadows
|
|
199
|
-
|
|
200
|
-
The three different box shadow styles can directly be applied to the `box-shadow` property.
|
|
201
|
-
|
|
202
|
-
```css
|
|
203
|
-
box-shadow: var(--leu-box-shadow-short);
|
|
204
|
-
```
|
|
205
|
-
|
|
206
|
-
<div style={{ display: "flex", gap: "1rem", flexWrap: "wrap" }}>
|
|
207
|
-
{["short", "regular", "long"].map((shadow) => (
|
|
208
|
-
<div
|
|
209
|
-
key={shadow}
|
|
210
|
-
style={{
|
|
211
|
-
boxShadow: `var(--leu-box-shadow-${shadow})`,
|
|
212
|
-
padding: "1rem",
|
|
213
|
-
flex: 1,
|
|
214
|
-
}}
|
|
215
|
-
>
|
|
216
|
-
--leu-box-shadow-{shadow}
|
|
217
|
-
</div>
|
|
218
|
-
))}
|
|
219
|
-
</div>
|
|
220
|
-
|
|
221
|
-
## z-index
|
|
222
|
-
|
|
223
|
-
TODO
|
|
224
|
-
|
|
225
|
-
## Typography
|
|
226
|
-
|
|
227
|
-
The design system is based on the [Inter](https://rsms.me/inter/) font family. It just uses the `regular` and `black` weights.
|
|
228
|
-
The font files and the font face declaration are not part of the package. You need to include them in your application.
|
|
229
|
-
|
|
230
|
-
## Font family naming
|
|
231
|
-
|
|
232
|
-
Each weight has a unique font family name. The `@font-face` declaration has to match this naming.
|
|
233
|
-
|
|
234
|
-
<table>
|
|
235
|
-
<tbody>
|
|
236
|
-
<tr>
|
|
237
|
-
<td>regular</td>
|
|
238
|
-
<td>InterRegular</td>
|
|
239
|
-
</tr>
|
|
240
|
-
<tr>
|
|
241
|
-
<td>black</td>
|
|
242
|
-
<td>InterBlack</td>
|
|
243
|
-
</tr>
|
|
244
|
-
</tbody>
|
|
245
|
-
</table>
|
|
246
|
-
|
|
247
|
-
In the theme those two definitions including fallbacks are defined as custom properties.
|
|
248
|
-
|
|
249
|
-
```css
|
|
250
|
-
h1 {
|
|
251
|
-
font-family: var(--leu-font-family-black);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
p {
|
|
255
|
-
font-family: var(--leu-font-family-regular);
|
|
256
|
-
}
|
|
257
|
-
```
|
|
258
|
-
|
|
259
|
-
### OpenType features
|
|
260
|
-
|
|
261
|
-
Inter has a lot of OpenType features and the design system makes use of that.
|
|
262
|
-
To have the correct features applied, you need to set the `font-feature-settings` property.
|
|
263
|
-
|
|
264
|
-
```css
|
|
265
|
-
h1 {
|
|
266
|
-
font-feature-settings: var(--leu-t-font-feature-settings);
|
|
267
|
-
}
|
|
268
|
-
```
|
|
269
|
-
|
|
270
|
-
### Font styles
|
|
271
|
-
|
|
272
|
-
The ["Typografie" page of the figma file](https://www.figma.com/design/d6Pv21UVUbnBs3AdcZijHmbN/KTZH-Design-System?node-id=17336-82304&t=dL03yolQ7l8e6eow-11) lists all the font style definitions that are used in the design system.
|
|
273
|
-
A single style definition consists of the following properties:
|
|
274
|
-
|
|
275
|
-
<table>
|
|
276
|
-
<thead>
|
|
277
|
-
<tr>
|
|
278
|
-
<th>Property</th>
|
|
279
|
-
<th>Definition</th>
|
|
280
|
-
</tr>
|
|
281
|
-
</thead>
|
|
282
|
-
<tbody>
|
|
283
|
-
<tr>
|
|
284
|
-
<td>name</td>
|
|
285
|
-
<td>
|
|
286
|
-
Identifier of the style. Will not be applied to any css property. Sadly
|
|
287
|
-
the names don't follow an easy understandable pattern.
|
|
288
|
-
</td>
|
|
289
|
-
</tr>
|
|
290
|
-
<tr>
|
|
291
|
-
<td>weight</td>
|
|
292
|
-
<td>
|
|
293
|
-
Applies to the `font-weight` css property. Is either `regular` or
|
|
294
|
-
`black`. Not every style has a regular weight.
|
|
295
|
-
</td>
|
|
296
|
-
</tr>
|
|
297
|
-
<tr>
|
|
298
|
-
<td>size</td>
|
|
299
|
-
<td>Applies to the `font-size` css property. Is a `rem` value.</td>
|
|
300
|
-
</tr>
|
|
301
|
-
<tr>
|
|
302
|
-
<td>line height</td>
|
|
303
|
-
<td>Applies to the `line-height` css property. Is a unitless value.</td>
|
|
304
|
-
</tr>
|
|
305
|
-
<tr>
|
|
306
|
-
<td>spacing</td>
|
|
307
|
-
<td>Can be applied to the `margin` property. Is a `rem` value.</td>
|
|
308
|
-
</tr>
|
|
309
|
-
</tbody>
|
|
310
|
-
</table>
|
|
311
|
-
|
|
312
|
-
For each property of each font style definition there is a corresponding custom property in the theme.
|
|
313
|
-
The name of the custom properties follow the following pattern:
|
|
314
|
-
|
|
315
|
-
```css
|
|
316
|
-
--leu-t-{name}-{weight}-{property}
|
|
317
|
-
|
|
318
|
-
/* Example: line-height of the "large" style with the weight "regular" */
|
|
319
|
-
--leu-t-large-regular-line-height;
|
|
320
|
-
|
|
321
|
-
/* Example: font-size of the "biggerBig" style with the weight "black" */
|
|
322
|
-
--leu-t-bigger-big-regular-black;
|
|
323
|
-
|
|
324
|
-
/* Example: spacing of the "small" style with the weight "regular" */
|
|
325
|
-
--leu-t-small-regular-spacing;
|
|
326
|
-
```
|
|
327
|
-
|
|
328
|
-
There is also a custom property that can be applied to the `font` shortcut property.
|
|
329
|
-
It sets the `font-family`, `font-size` and `line-height` properties in a single line.
|
|
330
|
-
|
|
331
|
-
```css
|
|
332
|
-
h1 {
|
|
333
|
-
font: var(--leu-t-big-black-font);
|
|
334
|
-
}
|
|
335
|
-
```
|
|
336
|
-
|
|
337
|
-
#### Responsive scaling
|
|
338
|
-
|
|
339
|
-
There are cases where an element keeps the same font size on all breakpoints. Most of the times this is not a desireable behaviour.
|
|
340
|
-
The design system defines this, with what they call "curves". They are a definition of which font style should be applied on which breakpoint.
|
|
341
|
-
|
|
342
|
-
Every "curve" is defined as a custom property. They automatically change its value depending on the current breakpoint.
|
|
343
|
-
|
|
344
|
-
They can be accessed with the same properties like the font styles mentioned above.
|
|
345
|
-
|
|
346
|
-
```css
|
|
347
|
-
h1 {
|
|
348
|
-
font: var(--leu-t-curve-large-black-font);
|
|
349
|
-
}
|
|
350
|
-
```
|
|
351
|
-
|
|
352
|
-
## Layout
|
|
353
|
-
|
|
354
|
-
As the theme only consist of custom properties, it isn't possible to provide a full set of grid classes.
|
|
355
|
-
Instead the theme contains just five necessary values that can be applied directly.
|
|
356
|
-
This approach helps us to keep the css footprint as small as possible.
|
|
357
|
-
Most components don't need a grid anyway and those who do mostly have a very simple configuration.
|
|
358
|
-
Alternatively you can use the variables to build your own classes. You can find a possible implementation in this [GitHub Gist](https://gist.github.com/daenub/735d657cc0bf297e9a7d2015f003084c).
|
|
359
|
-
|
|
360
|
-
The official design system uses a 6 columns system on smaller screens.
|
|
361
|
-
For simplicity we use a 12 column grid for all breakpoints.
|
|
362
|
-
|
|
363
|
-
<table>
|
|
364
|
-
<thead>
|
|
365
|
-
<tr>
|
|
366
|
-
<th>Property</th>
|
|
367
|
-
<th>Definition</th>
|
|
368
|
-
</tr>
|
|
369
|
-
</thead>
|
|
370
|
-
<tbody>
|
|
371
|
-
<tr>
|
|
372
|
-
<td>`--leu-grid-gap`</td>
|
|
373
|
-
<td>The gap between the columns (responsive)</td>
|
|
374
|
-
</tr>
|
|
375
|
-
<tr>
|
|
376
|
-
<td>`--leu-grid-max-width`</td>
|
|
377
|
-
<td>Maximum width of the grid container</td>
|
|
378
|
-
</tr>
|
|
379
|
-
<tr>
|
|
380
|
-
<td>`--leu-grid-template-columns`</td>
|
|
381
|
-
<td>Defines 12 equal sized columns</td>
|
|
382
|
-
</tr>
|
|
383
|
-
<tr>
|
|
384
|
-
<td>`--leu-grid-columns-full`</td>
|
|
385
|
-
<td>
|
|
386
|
-
Preset for a cell that takes up the whole width of it's container
|
|
387
|
-
(responsive)
|
|
388
|
-
</td>
|
|
389
|
-
</tr>
|
|
390
|
-
<tr>
|
|
391
|
-
<td>`--leu-grid-columns-offset`</td>
|
|
392
|
-
<td>
|
|
393
|
-
Preset for offset cells. This configuration is used a lot on zh.ch
|
|
394
|
-
content pages.
|
|
395
|
-
</td>
|
|
396
|
-
</tr>
|
|
397
|
-
</tbody>
|
|
398
|
-
</table>
|
|
399
|
-
|
|
400
|
-
<Canvas of={GridStories.Regular} />
|
package/src/docs/usage.mdx
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { Meta, Markdown } from "@storybook/addon-docs/blocks"
|
|
2
|
-
|
|
3
|
-
<Meta title="Introduction/Usage" />
|
|
4
|
-
|
|
5
|
-
# Usage
|
|
6
|
-
|
|
7
|
-
All components of the leu library are built as web components. This means that you can use them like any other native HTML element. You're not restricted to a specific framework or library.
|
|
8
|
-
|
|
9
|
-
## Theme and fonts
|
|
10
|
-
|
|
11
|
-
In order for the components to work and look right, you need to load the theme stylesheet and the font definitions globally.
|
|
12
|
-
The theme file is part of the package (`dist/theme.css`).
|
|
13
|
-
The fonts on the other hand are not part of the package. See the [theme documentation](?path=/docs/introduction-theme--docs) for more information.
|
|
14
|
-
|
|
15
|
-
If you have an environment that resolves bare module imports, you can access the theme stylesheet like this:
|
|
16
|
-
|
|
17
|
-
```html
|
|
18
|
-
<link rel="stylesheet" href="@statistikzh/leu/dist/theme.css" />
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## Loading components
|
|
22
|
-
|
|
23
|
-
Every single component that you want to use has to be loaded individually.
|
|
24
|
-
This is to ensure that only the components that are used in the application end up in the bundle.
|
|
25
|
-
|
|
26
|
-
The library doesn't contain a file that loads all components at once.
|
|
27
|
-
|
|
28
|
-
In most cases you can load the desired component with an import statement.
|
|
29
|
-
Every file that starts with `leu-` will define the containing custom element (`customElements.define()`) as a side effect.
|
|
30
|
-
|
|
31
|
-
```js
|
|
32
|
-
import "@statistikzh/leu/leu-input.js"
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
### Waiting for the component to be ready
|
|
36
|
-
|
|
37
|
-
Depending on your environment and how you load a component, you might need to know when a component is defined.
|
|
38
|
-
The `customElements.whenDefined` method can be used for this. It returns a promise that resolves when the custom element is defined.
|
|
39
|
-
|
|
40
|
-
```js
|
|
41
|
-
customElements.whenDefined("leu-input").then(() => {
|
|
42
|
-
console.log("leu-input is ready")
|
|
43
|
-
})
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
## Framworks
|
|
47
|
-
|
|
48
|
-
[Custom Elments Everywhere](https://custom-elements-everywhere.com/) gives a good overview of the support of custom elements in different frameworks.
|
|
49
|
-
|
|
50
|
-
### React
|
|
51
|
-
|
|
52
|
-
React added [full support for custom elements in version 19](https://react.dev/blog/2024/12/05/react-19).
|
|
53
|
-
leu is therefore not usable with React versions below 19.
|
|
54
|
-
|
|
55
|
-
### Vue
|
|
56
|
-
|
|
57
|
-
Vue has full support for custom elements. Their [documentation](https://vuejs.org/guide/extras/web-components) explains how to set up a project so that custom elements are not resolved as vue components.
|
|
58
|
-
|
|
59
|
-
## Code completion
|
|
60
|
-
|
|
61
|
-
The leu package contains a file called `vscode.html-custom-data.json` that can be used to describe its custom elements to Visual Studio Code. This enables code completion for leu components. To enable it, you need to tell VS Code where the file is.
|
|
62
|
-
|
|
63
|
-
1. If it doesn’t already exist, create a folder called .vscode at the root of your project
|
|
64
|
-
2. If it doesn’t already exist, create a file inside that folder called settings.json
|
|
65
|
-
3. Add the following to the file
|
|
66
|
-
|
|
67
|
-
```json
|
|
68
|
-
{
|
|
69
|
-
"html.customData": [
|
|
70
|
-
"./node_modules/@statistikzh/leu/dist/vscode.html-custom-data.json"
|
|
71
|
-
]
|
|
72
|
-
}
|
|
73
|
-
```
|
package/src/global.d.ts
DELETED
package/src/index.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export * from "./components/accordion/Accordion.js"
|
|
2
|
-
export * from "./components/button/Button.js"
|
|
3
|
-
export * from "./components/button-group/ButtonGroup.js"
|
|
4
|
-
export * from "./components/chart-wrapper/ChartWrapper.js"
|
|
5
|
-
export * from "./components/checkbox/Checkbox.js"
|
|
6
|
-
export * from "./components/checkbox/CheckboxGroup.js"
|
|
7
|
-
export * from "./components/chip/exports.js"
|
|
8
|
-
export * from "./components/dialog/Dialog.js"
|
|
9
|
-
export * from "./components/dropdown/Dropdown.js"
|
|
10
|
-
export * from "./components/file-input/FileInput.js"
|
|
11
|
-
export * from "./components/icon/Icon.js"
|
|
12
|
-
export * from "./components/input/Input.js"
|
|
13
|
-
export * from "./components/menu/Menu.js"
|
|
14
|
-
export * from "./components/menu/MenuItem.js"
|
|
15
|
-
export * from "./components/message/Message.js"
|
|
16
|
-
export * from "./components/pagination/Pagination.js"
|
|
17
|
-
export * from "./components/placeholder/Placeholder.js"
|
|
18
|
-
export * from "./components/popup/Popup.js"
|
|
19
|
-
export * from "./components/progress-bar/ProgressBar.js"
|
|
20
|
-
export * from "./components/radio/Radio.js"
|
|
21
|
-
export * from "./components/radio/RadioGroup.js"
|
|
22
|
-
export * from "./components/range/Range.js"
|
|
23
|
-
export * from "./components/scroll-top/ScrollTop.js"
|
|
24
|
-
export * from "./components/select/Select.js"
|
|
25
|
-
export * from "./components/spinner/Spinner.js"
|
|
26
|
-
export * from "./components/table/Table.js"
|
|
27
|
-
export * from "./components/tag/Tag.js"
|
|
28
|
-
export * from "./components/visually-hidden/VisuallyHidden.js"
|
|
29
|
-
export * from "./lib/LeuElement.js"
|
package/src/lib/LeuElement.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { CSSResultGroup, LitElement } from "lit"
|
|
2
|
-
import commonStyles from "../styles/common-styles.css?inline"
|
|
3
|
-
|
|
4
|
-
export class LeuElement extends LitElement {
|
|
5
|
-
static version = __LEU_VERSION__
|
|
6
|
-
|
|
7
|
-
static dependencies: Record<string, typeof LeuElement> = {}
|
|
8
|
-
|
|
9
|
-
static styles: CSSResultGroup = commonStyles
|
|
10
|
-
|
|
11
|
-
static define(
|
|
12
|
-
name: string,
|
|
13
|
-
constructor = this,
|
|
14
|
-
options: ElementDefinitionOptions = {},
|
|
15
|
-
) {
|
|
16
|
-
Object.entries(this.dependencies).forEach(([n, c]) => c.define(n))
|
|
17
|
-
|
|
18
|
-
const currentlyRegisteredConstructor = customElements.get(name) as
|
|
19
|
-
| CustomElementConstructor
|
|
20
|
-
| typeof LeuElement
|
|
21
|
-
|
|
22
|
-
if (currentlyRegisteredConstructor === undefined) {
|
|
23
|
-
customElements.define(name, constructor, options)
|
|
24
|
-
return
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
if (currentlyRegisteredConstructor !== constructor) {
|
|
28
|
-
console.warn(
|
|
29
|
-
`The custom element with the name <${name}> is already registered with a different constructor. This can happen when the same element has been loaded from different modules (e.g. multiple CDN requests or bundles).`,
|
|
30
|
-
)
|
|
31
|
-
return
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (
|
|
35
|
-
"version" in currentlyRegisteredConstructor &&
|
|
36
|
-
currentlyRegisteredConstructor.version !== constructor.version
|
|
37
|
-
) {
|
|
38
|
-
console.warn(
|
|
39
|
-
`The custom element with the name <${name}> is already defined with the same constructor but a different version (${currentlyRegisteredConstructor.version}).`,
|
|
40
|
-
)
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
package/src/lib/a11y.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* All roles that are associated with a aria-checked attribute
|
|
3
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-checked
|
|
4
|
-
*/
|
|
5
|
-
export const ARIA_CHECKED_ROLES = [
|
|
6
|
-
"checkbox",
|
|
7
|
-
"menuitemcheckbox",
|
|
8
|
-
"menuitemradio",
|
|
9
|
-
"option",
|
|
10
|
-
"radio",
|
|
11
|
-
"switch",
|
|
12
|
-
] as const
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* All roles that are associated with a aria-selected attribute
|
|
16
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-selected
|
|
17
|
-
*/
|
|
18
|
-
export const ARIA_SELECTED_ROLES = [
|
|
19
|
-
"gridcell",
|
|
20
|
-
"option",
|
|
21
|
-
"row",
|
|
22
|
-
"tab",
|
|
23
|
-
"columnheader",
|
|
24
|
-
"rowheader",
|
|
25
|
-
"treeitem",
|
|
26
|
-
] as const
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Thanks Shoelace!
|
|
3
|
-
* Source: https://github.com/shoelace-style/shoelace/blob/next/src/internal/slot.ts
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { ReactiveController, ReactiveControllerHost } from "lit"
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* A reactive controller that determines when slots exist.
|
|
10
|
-
*/
|
|
11
|
-
export class HasSlotController implements ReactiveController {
|
|
12
|
-
host: ReactiveControllerHost & Element
|
|
13
|
-
|
|
14
|
-
slotNames: string[]
|
|
15
|
-
|
|
16
|
-
constructor(host: ReactiveControllerHost & Element, slotNames: string[]) {
|
|
17
|
-
this.host = host
|
|
18
|
-
host.addController(this)
|
|
19
|
-
|
|
20
|
-
this.slotNames = slotNames
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
private hasDefaultSlot() {
|
|
24
|
-
return [...this.host.childNodes].some((node) => {
|
|
25
|
-
if (node.nodeType === node.TEXT_NODE && node.textContent.trim() !== "") {
|
|
26
|
-
return true
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (node.nodeType === node.ELEMENT_NODE) {
|
|
30
|
-
const el = node
|
|
31
|
-
|
|
32
|
-
// If it doesn't have a slot attribute, it's part of the default slot
|
|
33
|
-
if (!el.hasAttribute("slot")) {
|
|
34
|
-
return true
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return false
|
|
39
|
-
})
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
private hasNamedSlot(name: string) {
|
|
43
|
-
return this.host.querySelector(`:scope > [slot="${name}"]`) !== null
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
test(slotName: string) {
|
|
47
|
-
return slotName === "[default]"
|
|
48
|
-
? this.hasDefaultSlot()
|
|
49
|
-
: this.hasNamedSlot(slotName)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
hostConnected() {
|
|
53
|
-
this.host.shadowRoot.addEventListener("slotchange", this.handleSlotChange)
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
hostDisconnected() {
|
|
57
|
-
this.host.shadowRoot.removeEventListener(
|
|
58
|
-
"slotchange",
|
|
59
|
-
this.handleSlotChange,
|
|
60
|
-
)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
private handleSlotChange = (event: Event) => {
|
|
64
|
-
const slot = event.target
|
|
65
|
-
|
|
66
|
-
if (
|
|
67
|
-
slot instanceof HTMLSlotElement &&
|
|
68
|
-
((this.slotNames.includes("[default]") && !slot.name) ||
|
|
69
|
-
(slot.name && this.slotNames.includes(slot.name)))
|
|
70
|
-
) {
|
|
71
|
-
this.host.requestUpdate()
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|