@statistikzh/leu 0.14.0 → 0.14.1

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 (129) hide show
  1. package/.storybook/preview.js +11 -0
  2. package/CHANGELOG.md +11 -0
  3. package/README.md +0 -67
  4. package/dist/Accordion.d.ts +1 -1
  5. package/dist/Accordion.d.ts.map +1 -1
  6. package/dist/Accordion.js +7 -5
  7. package/dist/Button.d.ts +1 -1
  8. package/dist/Button.js +2 -2
  9. package/dist/ButtonGroup.d.ts +1 -1
  10. package/dist/ButtonGroup.js +1 -1
  11. package/dist/Checkbox.d.ts +1 -1
  12. package/dist/Checkbox.js +1 -1
  13. package/dist/CheckboxGroup.d.ts +1 -1
  14. package/dist/CheckboxGroup.js +1 -1
  15. package/dist/Chip.d.ts +1 -1
  16. package/dist/Chip.js +1 -1
  17. package/dist/ChipGroup.d.ts +1 -1
  18. package/dist/ChipGroup.js +1 -1
  19. package/dist/ChipLink.js +1 -1
  20. package/dist/ChipRemovable.js +1 -1
  21. package/dist/ChipSelectable.js +1 -1
  22. package/dist/Dialog.d.ts +1 -1
  23. package/dist/Dialog.js +2 -2
  24. package/dist/Dropdown.d.ts +1 -1
  25. package/dist/Dropdown.js +2 -2
  26. package/dist/Icon.d.ts +1 -1
  27. package/dist/Icon.js +1 -1
  28. package/dist/Input.d.ts +2 -2
  29. package/dist/Input.d.ts.map +1 -1
  30. package/dist/Input.js +4 -5
  31. package/dist/{LeuElement-BjGpKQpe.d.ts → LeuElement-DH0PPSMq.d.ts} +1 -1
  32. package/dist/LeuElement-DH0PPSMq.d.ts.map +1 -0
  33. package/dist/{LeuElement-BjGpKQpe.js → LeuElement-DH0PPSMq.js} +1 -1
  34. package/dist/Menu.d.ts +1 -1
  35. package/dist/Menu.js +1 -1
  36. package/dist/MenuItem.d.ts +1 -1
  37. package/dist/MenuItem.js +1 -1
  38. package/dist/Pagination.d.ts +1 -1
  39. package/dist/Pagination.js +2 -2
  40. package/dist/Popup.d.ts +1 -1
  41. package/dist/Popup.js +1 -1
  42. package/dist/Radio.d.ts +1 -1
  43. package/dist/Radio.js +1 -1
  44. package/dist/RadioGroup.d.ts +1 -1
  45. package/dist/RadioGroup.js +1 -1
  46. package/dist/Range.d.ts +1 -1
  47. package/dist/Range.js +1 -1
  48. package/dist/ScrollTop.d.ts +1 -1
  49. package/dist/ScrollTop.js +2 -2
  50. package/dist/Select.d.ts +1 -5
  51. package/dist/Select.d.ts.map +1 -1
  52. package/dist/Select.js +3 -16
  53. package/dist/Spinner.d.ts +1 -1
  54. package/dist/Spinner.js +1 -1
  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/{hasSlotController-DvFw2NdC.d.ts → hasSlotController-CYd5tWew.d.ts} +1 -1
  60. package/dist/{hasSlotController-DvFw2NdC.d.ts.map → hasSlotController-CYd5tWew.d.ts.map} +1 -1
  61. package/dist/{hasSlotController-DvFw2NdC.js → hasSlotController-CYd5tWew.js} +1 -1
  62. package/dist/index.d.ts +1 -1
  63. package/dist/index.js +2 -2
  64. package/dist/leu-accordion.js +1 -1
  65. package/dist/leu-button-group.js +1 -1
  66. package/dist/leu-button.js +2 -2
  67. package/dist/leu-checkbox-group.js +1 -1
  68. package/dist/leu-checkbox.js +1 -1
  69. package/dist/leu-chip-group.js +1 -1
  70. package/dist/leu-chip-link.js +1 -1
  71. package/dist/leu-chip-removable.js +1 -1
  72. package/dist/leu-chip-selectable.js +1 -1
  73. package/dist/leu-dialog.js +2 -2
  74. package/dist/leu-dropdown.js +2 -2
  75. package/dist/leu-icon.js +1 -1
  76. package/dist/leu-input.js +1 -1
  77. package/dist/leu-menu-item.js +1 -1
  78. package/dist/leu-menu.js +1 -1
  79. package/dist/leu-pagination.js +2 -2
  80. package/dist/leu-popup.js +1 -1
  81. package/dist/leu-radio-group.js +1 -1
  82. package/dist/leu-radio.js +1 -1
  83. package/dist/leu-range.js +1 -1
  84. package/dist/leu-scroll-top.js +2 -2
  85. package/dist/leu-select.js +2 -2
  86. package/dist/leu-spinner.js +1 -1
  87. package/dist/leu-table.js +2 -2
  88. package/dist/leu-visually-hidden.js +1 -1
  89. package/dist/vscode.html-custom-data.json +1 -1
  90. package/dist/vue/index.d.ts +0 -1
  91. package/dist/web-types.json +2 -2
  92. package/package.json +3 -3
  93. package/scripts/generate-component/templates/stories/[name].stories.js +1 -1
  94. package/src/components/accordion/Accordion.js +1 -1
  95. package/src/components/accordion/accordion.css +6 -3
  96. package/src/components/accordion/stories/accordion.stories.js +7 -6
  97. package/src/components/button/stories/button.stories.js +1 -1
  98. package/src/components/button-group/stories/button-group.stories.js +1 -1
  99. package/src/components/checkbox/stories/checkbox-group.stories.js +1 -1
  100. package/src/components/checkbox/stories/checkbox.stories.js +1 -1
  101. package/src/components/chip/stories/chip-group.stories.js +1 -1
  102. package/src/components/chip/stories/chip-link.stories.js +1 -1
  103. package/src/components/chip/stories/chip-removable.stories.js +1 -1
  104. package/src/components/chip/stories/chip-selectable.stories.js +1 -1
  105. package/src/components/dialog/stories/dialog.stories.js +1 -1
  106. package/src/components/dropdown/stories/dropdown.stories.js +1 -1
  107. package/src/components/icon/stories/icon.stories.js +1 -1
  108. package/src/components/input/Input.js +1 -1
  109. package/src/components/input/input.css +2 -2
  110. package/src/components/input/stories/input.stories.js +1 -2
  111. package/src/components/menu/stories/menu-item.stories.js +1 -1
  112. package/src/components/menu/stories/menu.stories.js +1 -1
  113. package/src/components/pagination/stories/pagination.stories.js +1 -1
  114. package/src/components/popup/stories/popup.stories.js +1 -1
  115. package/src/components/radio/stories/radio-group.stories.js +1 -1
  116. package/src/components/radio/stories/radio.stories.js +1 -1
  117. package/src/components/range/stories/range-slider.stories.js +1 -1
  118. package/src/components/scroll-top/stories/scroll-top.stories.js +1 -1
  119. package/src/components/select/Select.js +1 -17
  120. package/src/components/select/stories/select.stories.js +2 -2
  121. package/src/components/spinner/stories/spinner.stories.js +1 -1
  122. package/src/components/table/stories/table.stories.js +1 -1
  123. package/src/components/visually-hidden/stories/visually-hidden.stories.js +1 -1
  124. package/src/docs/contributing.mdx +154 -0
  125. package/src/docs/installation.mdx +35 -0
  126. package/src/docs/theme.mdx +349 -0
  127. package/src/docs/usage.mdx +73 -0
  128. package/src/styles/style.stories.js +1 -1
  129. package/dist/LeuElement-BjGpKQpe.d.ts.map +0 -1
@@ -0,0 +1,349 @@
1
+ import { Meta, Markdown, Canvas } from "@storybook/blocks"
2
+
3
+ import * as GridStories from "../styles/style.stories.js"
4
+
5
+ <Meta title="Introduction/Theme" />
6
+
7
+ export const ColorTable = ({ prefix, shades }) => {
8
+ return (
9
+ <table>
10
+ <thead>
11
+ <tr>
12
+ <th>Color</th>
13
+ <th>Property</th>
14
+ </tr>
15
+ </thead>
16
+ <tbody>
17
+ {shades.map((shade) => {
18
+ return (
19
+ <tr>
20
+ <td
21
+ style={{
22
+ background:
23
+ "repeating-conic-gradient(var(--leu-color-black-10) 0% 25%, transparent 0% 50%) 50% / 20px 20px, white",
24
+ }}
25
+ >
26
+ <div
27
+ style={{
28
+ background: `var(--leu-color-${prefix}-${shade})`,
29
+ height: "1.5rem",
30
+ }}
31
+ ></div>
32
+ </td>
33
+ <td>
34
+ --leu-color-{prefix}-{shade}
35
+ </td>
36
+ </tr>
37
+ )
38
+ })}
39
+ </tbody>
40
+ </table>
41
+ )
42
+ }
43
+
44
+ # Theme
45
+
46
+ 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.
47
+ The theme is a single stylesheet that just defines custom properties. It doesn't contain any global classes.
48
+
49
+ ```html
50
+ <link rel="stylesheet" href="@statistikzh/leu/dist/theme.css" />
51
+ ```
52
+
53
+ If you're "only" using the components then that's all you need to do.
54
+
55
+ The rest of the document explains what the theme contains and how it's structured.
56
+ This is helpful if you want to use the it to style your application or to build new components.
57
+
58
+ ## Table of Contents
59
+
60
+ - [Design System](#design-system)
61
+ - [Structure of the file](#structure-of-the-file)
62
+ - [Custom property naming](#custom-property-naming)
63
+ - [Colors](#colors)
64
+ - [Box Shadows](#box-shadows)
65
+ - [z-index](#z-index)
66
+ - [Typography](#typography)
67
+ - [Layout](#layout)
68
+
69
+ ---
70
+
71
+ ## Design system
72
+
73
+ 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.
74
+ Currently there is no automatic workflow that generates the theme from the design system. The theme is manually updated when the design system changes.
75
+ If you spot any inconsistencies between the theme and the design system, please open an issue.
76
+
77
+ ## Structure of the file
78
+
79
+ The theme contains custom properties for:
80
+
81
+ - Colors
82
+ - Box Shadows
83
+ - z-index
84
+ - Typography
85
+ - Grid
86
+
87
+ ## Custom property naming
88
+
89
+ All custom properties of this theme are prefixed with `--leu`.
90
+
91
+ ```css
92
+ :root {
93
+ --leu-color-black-100: #000;
94
+ }
95
+ ```
96
+
97
+ ## Colors
98
+
99
+ The colors are split into different categories (black, white, accent, functional).
100
+ Each of the categories have a specific prefix.
101
+
102
+ 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).
103
+
104
+ ### Shades of black
105
+
106
+ The design system uses two different kind of black shades. One with transparency and one without.
107
+ Consult the figma file to find out when to use which.
108
+
109
+ <ColorTable prefix="black" shades={[100, 80, 60, 40, 20, 10, 5, 0]} />
110
+
111
+ #### Shades with transparency
112
+
113
+ <ColorTable prefix="black-transp" shades={[80, 60, 40, 20, 10, 5]} />
114
+
115
+ ### Shaeds of white
116
+
117
+ <ColorTable prefix="white-transp" shades={[90, 70, 40, 10]} />
118
+
119
+ ### Accent colors
120
+
121
+ <ColorTable
122
+ prefix="accent"
123
+ shades={[
124
+ "blue",
125
+ "darkblue",
126
+ "turquoise",
127
+ "green",
128
+ "bordeaux",
129
+ "magenta",
130
+ "violet",
131
+ "gray",
132
+ ]}
133
+ />
134
+ <ColorTable
135
+ prefix="accent"
136
+ shades={[
137
+ "blue-soft",
138
+ "darkblue-soft",
139
+ "turquoise-soft",
140
+ "green-soft",
141
+ "bordeaux-soft",
142
+ "magenta-soft",
143
+ "violet-soft",
144
+ "gray-soft",
145
+ ]}
146
+ />
147
+
148
+ ### Functional colors
149
+
150
+ <ColorTable prefix="func" shades={["cyan", "red", "green"]} />
151
+
152
+ ## Box Shadows
153
+
154
+ The three different box shadow styles can directly be applied to the `box-shadow` property.
155
+
156
+ ```css
157
+ box-shadow: var(--leu-box-shadow-short);
158
+ ```
159
+
160
+ <div style={{ display: "flex", gap: "1rem", flexWrap: "wrap" }}>
161
+ {["short", "regular", "long"].map((shadow) => (
162
+ <div
163
+ style={{
164
+ boxShadow: `var(--leu-box-shadow-${shadow})`,
165
+ padding: "1rem",
166
+ flex: 1,
167
+ }}
168
+ >
169
+ --leu-box-shadow-{shadow}
170
+ </div>
171
+ ))}
172
+ </div>
173
+
174
+ ## z-index
175
+
176
+ ## Typography
177
+
178
+ The design system is based on the [Inter](https://rsms.me/inter/) font family. It just uses the `regular` and `black` weights.
179
+ The font files and the font face declaration are not part of the package. You need to include them in your application.
180
+
181
+ ## Font family naming
182
+
183
+ Each weight has a unique font family name. The `@font-face` declaration has to match this naming.
184
+
185
+ <table>
186
+ <tr>
187
+ <td>regular</td>
188
+ <td>InterRegular</td>
189
+ </tr>
190
+ <tr>
191
+ <td>black</td>
192
+ <td>InterBlack</td>
193
+ </tr>
194
+ </table>
195
+
196
+ In the theme those two definitions including fallbacks are defined as custom properties.
197
+
198
+ ```css
199
+ h1 {
200
+ font-family: var(--leu-font-family-black);
201
+ }
202
+
203
+ p {
204
+ font-family: var(--leu-font-family-regular);
205
+ }
206
+ ```
207
+
208
+ ### OpenType features
209
+
210
+ Inter has a lot of OpenType features and the design system makes use of that.
211
+ To have the correct features applied, you need to set the `font-feature-settings` property.
212
+
213
+ ```css
214
+ h1 {
215
+ font-feature-settings: var(--leu-t-font-feature-settings);
216
+ }
217
+ ```
218
+
219
+ ### Font styles
220
+
221
+ 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.
222
+ A single style definition consists of the following properties:
223
+
224
+ <table>
225
+ <thead>
226
+ <tr>
227
+ <th>Property</th>
228
+ <th>Definition</th>
229
+ </tr>
230
+ </thead>
231
+ <tbody>
232
+ <tr>
233
+ <td>name</td>
234
+ <td>
235
+ Identifier of the style. Will not be applied to any css property. Sadly
236
+ the names don't follow an easy understandable pattern.
237
+ </td>
238
+ </tr>
239
+ <tr>
240
+ <td>weight</td>
241
+ <td>
242
+ Applies to the `font-weight` css property. Is either `regular` or
243
+ `black`. Not every style has a regular weight.
244
+ </td>
245
+ </tr>
246
+ <tr>
247
+ <td>size</td>
248
+ <td>Applies to the `font-size` css property. Is a `rem` value.</td>
249
+ </tr>
250
+ <tr>
251
+ <td>line height</td>
252
+ <td>Applies to the `line-height` css property. Is a unitless value.</td>
253
+ </tr>
254
+ <tr>
255
+ <td>spacing</td>
256
+ <td>Can be applied to the `margin` property. Is a `rem` value.</td>
257
+ </tr>
258
+ </tbody>
259
+ </table>
260
+
261
+ For each property of each font style definition there is a corresponding custom property in the theme.
262
+ The name of the custom properties follow the following pattern:
263
+
264
+ ```css
265
+ --leu-t-{name}-{weight}-{property}
266
+
267
+ /* Example: line-height of the "large" style with the weight "regular" */
268
+ --leu-t-large-regular-line-height;
269
+
270
+ /* Example: font-size of the "biggerBig" style with the weight "black" */
271
+ --leu-t-bigger-big-regular-black;
272
+
273
+ /* Example: spacing of the "small" style with the weight "regular" */
274
+ --leu-t-small-regular-spacing;
275
+ ```
276
+
277
+ There is also a custom property that can be applied to the `font` shortcut property.
278
+ It sets the `font-family`, `font-size` and `line-height` properties in a single line.
279
+
280
+ ```css
281
+ h1 {
282
+ font: var(--leu-t-big-black-font);
283
+ }
284
+ ```
285
+
286
+ #### Responsive scaling
287
+
288
+ There are cases where an element keeps the same font size on all breakpoints. Most of the times this is not a desireable behaviour.
289
+ The design system defines this, with what they call "curves". They are a definition of which font style should be applied on which breakpoint.
290
+
291
+ Every "curve" is defined as a custom property. They automatically change its value depending on the current breakpoint.
292
+
293
+ They can be accessed with the same properties like the font styles mentioned above.
294
+
295
+ ```css
296
+ h1 {
297
+ font: var(--leu-t-curve-large-black-font);
298
+ }
299
+ ```
300
+
301
+ ## Layout
302
+
303
+ As the theme only consist of custom properties, it isn't possible to provide a full set of grid classes.
304
+ Instead the theme contains just five necessary values that can be applied directly.
305
+ Most components don't need a grid anyway and those who do mostly have a very simple configuration.
306
+ Alternatively you can use to build your own classes for your application.
307
+ This aproach helps us to keep the css footprint small.
308
+
309
+ The official design system uses a 6 columns system on smaller screens.
310
+ For simplicity we use a 12 column grid for all breakpoints.
311
+
312
+ <table>
313
+ <thead>
314
+ <tr>
315
+ <th>Property</th>
316
+ <th>Definition</th>
317
+ </tr>
318
+ </thead>
319
+ <tbody>
320
+ <tr>
321
+ <td>`--leu-grid-gap`</td>
322
+ <td>The gap between the columns (responsive)</td>
323
+ </tr>
324
+ <tr>
325
+ <td>`--leu-grid-max-width`</td>
326
+ <td>Maximum width of the grid container</td>
327
+ </tr>
328
+ <tr>
329
+ <td>`--leu-grid-template-columns`</td>
330
+ <td>Defines 12 equal sized columns</td>
331
+ </tr>
332
+ <tr>
333
+ <td>`--leu-grid-columns-full`</td>
334
+ <td>
335
+ Preset for a cell that takes up the whole width of it's container
336
+ (responsive)
337
+ </td>
338
+ </tr>
339
+ <tr>
340
+ <td>`--leu-grid-columns-offset`</td>
341
+ <td>
342
+ Preset for offset cells. This configuration is used a lot on zh.ch
343
+ content pages.
344
+ </td>
345
+ </tr>
346
+ </tbody>
347
+ </table>
348
+
349
+ <Canvas of={GridStories.Regular} />
@@ -0,0 +1,73 @@
1
+ import { Meta, Markdown } from "@storybook/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
+ ```
@@ -1,7 +1,7 @@
1
1
  import { html } from "lit"
2
2
 
3
3
  export default {
4
- title: "Layout",
4
+ title: "Components/Layout",
5
5
  }
6
6
 
7
7
  function Template() {
@@ -1 +0,0 @@
1
- {"version":3,"file":"LeuElement-BjGpKQpe.d.ts","sourceRoot":"","sources":["LeuElement-BjGpKQpe.js"],"names":[],"mappings":"AAgDA;IACE,8EAcC;CACF;AA9DD,sEAaC;2BAf+B,KAAK"}