@statistikzh/leu 0.15.0 → 0.16.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/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +16 -0
- package/dist/Accordion.js +1 -1
- package/dist/Button.js +1 -1
- package/dist/ButtonGroup.js +1 -1
- package/dist/ChartWrapper.js +40 -29
- package/dist/Checkbox.js +1 -1
- package/dist/CheckboxGroup.js +1 -1
- package/dist/Chip.js +1 -1
- package/dist/ChipGroup.js +1 -1
- package/dist/ChipLink.js +1 -1
- package/dist/ChipRemovable.js +1 -1
- package/dist/ChipSelectable.js +1 -1
- package/dist/Dialog.js +1 -1
- package/dist/Dropdown.js +1 -1
- package/dist/Icon.js +1 -1
- package/dist/Input.js +1 -1
- package/dist/{LeuElement-BhAmogDy.js → LeuElement-C0BZ_nPB.js} +1 -1
- package/dist/Menu.js +1 -1
- package/dist/MenuItem.js +1 -1
- package/dist/Message.d.ts +63 -0
- package/dist/Message.js +268 -0
- package/dist/Pagination.js +1 -1
- package/dist/Placeholder.js +1 -1
- package/dist/Popup.js +1 -1
- package/dist/Radio.js +1 -1
- package/dist/RadioGroup.js +1 -1
- package/dist/Range.js +1 -1
- package/dist/ScrollTop.js +1 -1
- package/dist/Select.js +1 -1
- package/dist/Spinner.js +1 -1
- package/dist/Table.js +1 -1
- package/dist/VisuallyHidden.js +1 -1
- package/dist/components/{visualization → chart-wrapper}/ChartWrapper.d.ts.map +1 -1
- package/dist/components/{visualization → chart-wrapper}/leu-chart-wrapper.d.ts.map +1 -1
- package/dist/components/{visualization → chart-wrapper}/stories/chart-wrapper.stories.d.ts +19 -0
- package/dist/components/{visualization → chart-wrapper}/stories/chart-wrapper.stories.d.ts.map +1 -1
- package/dist/components/chart-wrapper/test/chart-wrapper.test.d.ts.map +1 -0
- package/dist/components/message/Message.d.ts +59 -0
- package/dist/components/message/Message.d.ts.map +1 -0
- package/dist/components/message/leu-message.d.ts +3 -0
- package/dist/components/message/leu-message.d.ts.map +1 -0
- package/dist/components/message/stories/message.stories.d.ts +179 -0
- package/dist/components/message/stories/message.stories.d.ts.map +1 -0
- package/dist/components/message/test/message.test.d.ts +2 -0
- package/dist/components/message/test/message.test.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/leu-accordion.js +1 -1
- package/dist/leu-button-group.js +1 -1
- package/dist/leu-button.js +1 -1
- package/dist/leu-chart-wrapper.js +1 -1
- package/dist/leu-checkbox-group.js +1 -1
- package/dist/leu-checkbox.js +1 -1
- package/dist/leu-chip-group.js +1 -1
- package/dist/leu-chip-link.js +1 -1
- package/dist/leu-chip-removable.js +1 -1
- package/dist/leu-chip-selectable.js +1 -1
- package/dist/leu-dialog.js +1 -1
- package/dist/leu-dropdown.js +1 -1
- package/dist/leu-icon.js +1 -1
- package/dist/leu-input.js +1 -1
- package/dist/leu-menu-item.js +1 -1
- package/dist/leu-menu.js +1 -1
- package/dist/leu-message.d.ts +5 -0
- package/dist/leu-message.js +12 -0
- package/dist/leu-pagination.js +1 -1
- package/dist/leu-placeholder.js +1 -1
- package/dist/leu-popup.js +1 -1
- package/dist/leu-radio-group.js +1 -1
- package/dist/leu-radio.js +1 -1
- package/dist/leu-range.js +1 -1
- package/dist/leu-scroll-top.js +1 -1
- package/dist/leu-select.js +1 -1
- package/dist/leu-spinner.js +1 -1
- package/dist/leu-table.js +1 -1
- package/dist/leu-visually-hidden.js +1 -1
- package/dist/theme.css +18 -18
- package/dist/vscode.html-custom-data.json +54 -17
- package/dist/vue/index.d.ts +55 -23
- package/dist/web-types.json +125 -44
- package/package.json +1 -1
- package/release-please-config.json +1 -0
- package/scripts/postcss-leu-font-styles.cjs +10 -10
- package/src/components/{visualization → chart-wrapper}/ChartWrapper.ts +13 -10
- package/src/components/{visualization → chart-wrapper}/chart-wrapper.css +20 -11
- package/src/components/{visualization → chart-wrapper}/stories/chart-wrapper.stories.ts +7 -1
- package/src/components/{visualization → chart-wrapper}/test/chart-wrapper.test.ts +13 -10
- package/src/components/message/Message.ts +118 -0
- package/src/components/message/leu-message.ts +5 -0
- package/src/components/message/message.css +163 -0
- package/src/components/message/stories/message.mdx +76 -0
- package/src/components/message/stories/message.stories.ts +149 -0
- package/src/components/message/test/message.test.ts +96 -0
- package/src/docs/contributing.mdx +1 -1
- package/src/index.ts +1 -0
- package/src/styles/custom-media.css +1 -0
- package/src/styles/theme.css +89 -1
- package/dist/components/visualization/test/chart-wrapper.test.d.ts.map +0 -1
- package/src/styles/custom-properties.css +0 -89
- /package/dist/components/{visualization → chart-wrapper}/ChartWrapper.d.ts +0 -0
- /package/dist/components/{visualization → chart-wrapper}/leu-chart-wrapper.d.ts +0 -0
- /package/dist/components/{visualization → chart-wrapper}/test/chart-wrapper.test.d.ts +0 -0
- /package/src/components/{visualization → chart-wrapper}/leu-chart-wrapper.ts +0 -0
package/dist/web-types.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json",
|
|
3
3
|
"name": "@statistikzh/leu",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.16.0",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"contributions": {
|
|
7
7
|
"html": {
|
|
@@ -238,6 +238,49 @@
|
|
|
238
238
|
]
|
|
239
239
|
}
|
|
240
240
|
},
|
|
241
|
+
{
|
|
242
|
+
"name": "leu-chart-wrapper",
|
|
243
|
+
"description": "A wrapper element for charts.\n---\n\n\n### **Slots:**\n - **title** - The title of the chart. Use a heading tag (h2-4) depending on your context.\n- **description** - A description of the chart. Content is wrapped in a `<p>` tag by the component.\n- **chart** - The actual chart\n- **caption** - A caption for the chart, e.g. a source or explanation of the data.\n- **download** - A download button or dropdown to export the chart in different formats.",
|
|
244
|
+
"doc-url": "",
|
|
245
|
+
"attributes": [
|
|
246
|
+
{
|
|
247
|
+
"name": "pending",
|
|
248
|
+
"description": "Whether the chart is currently loading or not.\nWhen set to `true`, a spinner will be shown in the chart container.",
|
|
249
|
+
"value": { "type": "boolean", "default": "false" }
|
|
250
|
+
}
|
|
251
|
+
],
|
|
252
|
+
"slots": [
|
|
253
|
+
{
|
|
254
|
+
"name": "title",
|
|
255
|
+
"description": "The title of the chart. Use a heading tag (h2-4) depending on your context."
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
"name": "description",
|
|
259
|
+
"description": "A description of the chart. Content is wrapped in a `<p>` tag by the component."
|
|
260
|
+
},
|
|
261
|
+
{ "name": "chart", "description": "The actual chart" },
|
|
262
|
+
{
|
|
263
|
+
"name": "caption",
|
|
264
|
+
"description": "A caption for the chart, e.g. a source or explanation of the data."
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
"name": "download",
|
|
268
|
+
"description": "A download button or dropdown to export the chart in different formats."
|
|
269
|
+
}
|
|
270
|
+
],
|
|
271
|
+
"events": [],
|
|
272
|
+
"js": {
|
|
273
|
+
"properties": [
|
|
274
|
+
{
|
|
275
|
+
"name": "pending",
|
|
276
|
+
"description": "Whether the chart is currently loading or not.\nWhen set to `true`, a spinner will be shown in the chart container.",
|
|
277
|
+
"type": "boolean"
|
|
278
|
+
},
|
|
279
|
+
{ "name": "hasSlotController" }
|
|
280
|
+
],
|
|
281
|
+
"events": []
|
|
282
|
+
}
|
|
283
|
+
},
|
|
241
284
|
{
|
|
242
285
|
"name": "leu-checkbox",
|
|
243
286
|
"description": "\n---\n",
|
|
@@ -926,6 +969,87 @@
|
|
|
926
969
|
"events": []
|
|
927
970
|
}
|
|
928
971
|
},
|
|
972
|
+
{
|
|
973
|
+
"name": "leu-message",
|
|
974
|
+
"description": "\n---\n\n\n### **Events:**\n - **leu:remove** - Fired when the close button is clicked.\n\n### **Slots:**\n - **default** - The content of the message. The title of the message should marked up with a `<strong>` tag.\n- **cta** - A call to action button that is only allowed for `size=large`\n\n### **CSS Properties:**\n - **--leu-message-accent-color** - Sets the color of the message. According to the design system, it is only allowd for `info` _(default: undefined)_",
|
|
975
|
+
"doc-url": "",
|
|
976
|
+
"attributes": [
|
|
977
|
+
{
|
|
978
|
+
"name": "type",
|
|
979
|
+
"description": "The type of the message. `error` and `success` will be displayed as filled boxes.",
|
|
980
|
+
"value": {
|
|
981
|
+
"type": "\"error\" | \"success\" | \"info\" | \"warning\"",
|
|
982
|
+
"default": "\"success\""
|
|
983
|
+
}
|
|
984
|
+
},
|
|
985
|
+
{
|
|
986
|
+
"name": "size",
|
|
987
|
+
"description": "The size of the message. A call to action button is only allowed for `large` messages.",
|
|
988
|
+
"value": {
|
|
989
|
+
"type": "\"regular\" | \"large\"",
|
|
990
|
+
"default": "\"regular\""
|
|
991
|
+
}
|
|
992
|
+
},
|
|
993
|
+
{
|
|
994
|
+
"name": "removable",
|
|
995
|
+
"description": "Wheter the message is removable or not. The component will not remove itself when the close button is clicked.",
|
|
996
|
+
"value": { "type": "boolean", "default": "false" }
|
|
997
|
+
},
|
|
998
|
+
{
|
|
999
|
+
"name": "popup",
|
|
1000
|
+
"description": "Wheter the message is used as a popup or not. This will add a drop shadow but will not position the message absolutely.",
|
|
1001
|
+
"value": { "type": "boolean", "default": "false" }
|
|
1002
|
+
}
|
|
1003
|
+
],
|
|
1004
|
+
"slots": [
|
|
1005
|
+
{
|
|
1006
|
+
"name": "default",
|
|
1007
|
+
"description": "The content of the message. The title of the message should marked up with a `<strong>` tag."
|
|
1008
|
+
},
|
|
1009
|
+
{
|
|
1010
|
+
"name": "cta",
|
|
1011
|
+
"description": "A call to action button that is only allowed for `size=large`"
|
|
1012
|
+
}
|
|
1013
|
+
],
|
|
1014
|
+
"events": [
|
|
1015
|
+
{
|
|
1016
|
+
"name": "leu:remove",
|
|
1017
|
+
"type": "CustomEvent",
|
|
1018
|
+
"description": "Fired when the close button is clicked."
|
|
1019
|
+
}
|
|
1020
|
+
],
|
|
1021
|
+
"js": {
|
|
1022
|
+
"properties": [
|
|
1023
|
+
{
|
|
1024
|
+
"name": "type",
|
|
1025
|
+
"description": "The type of the message. `error` and `success` will be displayed as filled boxes.",
|
|
1026
|
+
"type": "\"error\" | \"success\" | \"info\" | \"warning\""
|
|
1027
|
+
},
|
|
1028
|
+
{
|
|
1029
|
+
"name": "size",
|
|
1030
|
+
"description": "The size of the message. A call to action button is only allowed for `large` messages.",
|
|
1031
|
+
"type": "\"regular\" | \"large\""
|
|
1032
|
+
},
|
|
1033
|
+
{
|
|
1034
|
+
"name": "removable",
|
|
1035
|
+
"description": "Wheter the message is removable or not. The component will not remove itself when the close button is clicked.",
|
|
1036
|
+
"type": "boolean"
|
|
1037
|
+
},
|
|
1038
|
+
{
|
|
1039
|
+
"name": "popup",
|
|
1040
|
+
"description": "Wheter the message is used as a popup or not. This will add a drop shadow but will not position the message absolutely.",
|
|
1041
|
+
"type": "boolean"
|
|
1042
|
+
}
|
|
1043
|
+
],
|
|
1044
|
+
"events": [
|
|
1045
|
+
{
|
|
1046
|
+
"name": "leu:remove",
|
|
1047
|
+
"type": "CustomEvent",
|
|
1048
|
+
"description": "Fired when the close button is clicked."
|
|
1049
|
+
}
|
|
1050
|
+
]
|
|
1051
|
+
}
|
|
1052
|
+
},
|
|
929
1053
|
{
|
|
930
1054
|
"name": "leu-pagination",
|
|
931
1055
|
"description": "\n---\n\n\n### **Events:**\n - **leu:pagechange**",
|
|
@@ -1390,49 +1514,6 @@
|
|
|
1390
1514
|
"events": []
|
|
1391
1515
|
}
|
|
1392
1516
|
},
|
|
1393
|
-
{
|
|
1394
|
-
"name": "leu-chart-wrapper",
|
|
1395
|
-
"description": "A wrapper element for charts.\n---\n\n\n### **Slots:**\n - **title** - The title of the chart. Use a heading tag (h2-4) depending on your context.\n- **description** - A description of the chart. Content is wrapped in a `<p>` tag by the component.\n- **chart** - The actual chart\n- **caption** - A caption for the chart, e.g. a source or explanation of the data.\n- **download** - A download button or dropdown to export the chart in different formats.",
|
|
1396
|
-
"doc-url": "",
|
|
1397
|
-
"attributes": [
|
|
1398
|
-
{
|
|
1399
|
-
"name": "pending",
|
|
1400
|
-
"description": "Whether the chart is currently loading or not.\nWhen set to `true`, a spinner will be shown in the chart container.",
|
|
1401
|
-
"value": { "type": "boolean", "default": "false" }
|
|
1402
|
-
}
|
|
1403
|
-
],
|
|
1404
|
-
"slots": [
|
|
1405
|
-
{
|
|
1406
|
-
"name": "title",
|
|
1407
|
-
"description": "The title of the chart. Use a heading tag (h2-4) depending on your context."
|
|
1408
|
-
},
|
|
1409
|
-
{
|
|
1410
|
-
"name": "description",
|
|
1411
|
-
"description": "A description of the chart. Content is wrapped in a `<p>` tag by the component."
|
|
1412
|
-
},
|
|
1413
|
-
{ "name": "chart", "description": "The actual chart" },
|
|
1414
|
-
{
|
|
1415
|
-
"name": "caption",
|
|
1416
|
-
"description": "A caption for the chart, e.g. a source or explanation of the data."
|
|
1417
|
-
},
|
|
1418
|
-
{
|
|
1419
|
-
"name": "download",
|
|
1420
|
-
"description": "A download button or dropdown to export the chart in different formats."
|
|
1421
|
-
}
|
|
1422
|
-
],
|
|
1423
|
-
"events": [],
|
|
1424
|
-
"js": {
|
|
1425
|
-
"properties": [
|
|
1426
|
-
{
|
|
1427
|
-
"name": "pending",
|
|
1428
|
-
"description": "Whether the chart is currently loading or not.\nWhen set to `true`, a spinner will be shown in the chart container.",
|
|
1429
|
-
"type": "boolean"
|
|
1430
|
-
},
|
|
1431
|
-
{ "name": "hasSlotController" }
|
|
1432
|
-
],
|
|
1433
|
-
"events": []
|
|
1434
|
-
}
|
|
1435
|
-
},
|
|
1436
1517
|
{
|
|
1437
1518
|
"name": "leu-visually-hidden",
|
|
1438
1519
|
"description": "\n---\n",
|
package/package.json
CHANGED
|
@@ -35,20 +35,20 @@ function generateCustomPropertyDeclarations({
|
|
|
35
35
|
{
|
|
36
36
|
type: "font",
|
|
37
37
|
name: varFont,
|
|
38
|
-
value: `var(${varFontSize}) / var(${varLineHeight}) var(${varFontFamily})`,
|
|
38
|
+
value: `normal var(${varFontSize}) / var(${varLineHeight}) var(${varFontFamily})`,
|
|
39
39
|
},
|
|
40
40
|
]
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
function curveStepDeclarations(curvePrefix, stepStyle) {
|
|
44
44
|
const fontSizeVar = stepStyle.declarations.find(
|
|
45
|
-
(s) => s.type === "fontSize"
|
|
45
|
+
(s) => s.type === "fontSize",
|
|
46
46
|
).name
|
|
47
47
|
const lineHeightVar = stepStyle.declarations.find(
|
|
48
|
-
(s) => s.type === "lineHeight"
|
|
48
|
+
(s) => s.type === "lineHeight",
|
|
49
49
|
).name
|
|
50
50
|
const spacingVar = stepStyle.declarations.find(
|
|
51
|
-
(s) => s.type === "spacing"
|
|
51
|
+
(s) => s.type === "spacing",
|
|
52
52
|
).name
|
|
53
53
|
const fontVar = stepStyle.declarations.find((s) => s.type === "font").name
|
|
54
54
|
|
|
@@ -93,8 +93,8 @@ async function createLeuFontStyleNodes(file, postcss, nodeSource) {
|
|
|
93
93
|
const fontStyleNodes = fontStyleDeclarations.flatMap((style) =>
|
|
94
94
|
style.declarations.map(
|
|
95
95
|
({ name, value }) =>
|
|
96
|
-
new postcss.Declaration({ prop: name, value, source: nodeSource })
|
|
97
|
-
)
|
|
96
|
+
new postcss.Declaration({ prop: name, value, source: nodeSource }),
|
|
97
|
+
),
|
|
98
98
|
)
|
|
99
99
|
|
|
100
100
|
const curveNodes = curves.flatMap((curve) =>
|
|
@@ -105,12 +105,12 @@ async function createLeuFontStyleNodes(file, postcss, nodeSource) {
|
|
|
105
105
|
const [viewport, styleName] = step
|
|
106
106
|
|
|
107
107
|
const stepStyle = fontStyleDeclarations.find(
|
|
108
|
-
(s) => s.name === styleName && s.fontWeight === fontWeight
|
|
108
|
+
(s) => s.name === styleName && s.fontWeight === fontWeight,
|
|
109
109
|
)
|
|
110
110
|
|
|
111
111
|
const nodes = curveStepDeclarations(curvePrefix, stepStyle).map(
|
|
112
112
|
({ prop, value }) =>
|
|
113
|
-
new postcss.Declaration({ prop, value, source: nodeSource })
|
|
113
|
+
new postcss.Declaration({ prop, value, source: nodeSource }),
|
|
114
114
|
)
|
|
115
115
|
|
|
116
116
|
return viewport === null
|
|
@@ -122,7 +122,7 @@ async function createLeuFontStyleNodes(file, postcss, nodeSource) {
|
|
|
122
122
|
source: nodeSource,
|
|
123
123
|
})
|
|
124
124
|
})
|
|
125
|
-
})
|
|
125
|
+
}),
|
|
126
126
|
)
|
|
127
127
|
|
|
128
128
|
return [...fontStyleNodes, ...curveNodes]
|
|
@@ -143,7 +143,7 @@ module.exports = () => ({
|
|
|
143
143
|
const nodes = await createLeuFontStyleNodes(
|
|
144
144
|
path.resolve(rootDir, jsonFile),
|
|
145
145
|
postcss,
|
|
146
|
-
atRule.source
|
|
146
|
+
atRule.source,
|
|
147
147
|
)
|
|
148
148
|
|
|
149
149
|
atRule.replaceWith(nodes)
|
|
@@ -47,27 +47,30 @@ export class LeuChartWrapper extends LeuElement {
|
|
|
47
47
|
const hasDownload = this.hasSlotController.test("download")
|
|
48
48
|
|
|
49
49
|
return html`
|
|
50
|
-
<figure>
|
|
51
|
-
<slot name="title" class="
|
|
50
|
+
<figure class="chart-wrapper">
|
|
51
|
+
<slot name="title" class="chart-wrapper__title"></slot>
|
|
52
52
|
${hasDescription
|
|
53
|
-
? html`<slot
|
|
53
|
+
? html`<slot
|
|
54
|
+
name="description"
|
|
55
|
+
class="chart-wrapper__description"
|
|
56
|
+
></slot>`
|
|
54
57
|
: nothing}
|
|
55
|
-
<div class="chart-
|
|
56
|
-
<slot name="chart" class="chart"></slot>
|
|
58
|
+
<div class="chart-wrapper__container">
|
|
59
|
+
<slot name="chart" class="chart-wrapper__chart"></slot>
|
|
57
60
|
${this.pending
|
|
58
|
-
? html`<div class="
|
|
59
|
-
<leu-spinner class="
|
|
61
|
+
? html`<div class="chart-wrapper__spinner-container">
|
|
62
|
+
<leu-spinner class="chart-wrapper__spinner"></leu-spinner>
|
|
60
63
|
</div>`
|
|
61
64
|
: nothing}
|
|
62
65
|
</div>
|
|
63
66
|
${hasCaption
|
|
64
67
|
? html`<figcaption>
|
|
65
|
-
<slot name="caption" class="
|
|
68
|
+
<slot name="caption" class="chart-wrapper__caption"></slot>
|
|
66
69
|
</figcaption>`
|
|
67
70
|
: nothing}
|
|
68
|
-
<hr class="
|
|
71
|
+
<hr class="chart-wrapper__ruler" />
|
|
69
72
|
${hasDownload
|
|
70
|
-
? html`<slot name="download" class="
|
|
73
|
+
? html`<slot name="download" class="chart-wrapper__download"></slot>`
|
|
71
74
|
: nothing}
|
|
72
75
|
</figure>
|
|
73
76
|
`
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
@import url("../../styles/custom-media.css");
|
|
2
2
|
|
|
3
|
-
.
|
|
3
|
+
.chart-wrapper {
|
|
4
|
+
display: block;
|
|
5
|
+
width: 100%;
|
|
6
|
+
margin: 0;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.chart-wrapper__title::slotted(h2) {
|
|
10
|
+
color: var(--leu-color-black-100);
|
|
4
11
|
font: var(--leu-t-curve-large-black-font);
|
|
5
12
|
margin: 0 0 0.75rem;
|
|
6
13
|
|
|
@@ -13,18 +20,20 @@
|
|
|
13
20
|
}
|
|
14
21
|
}
|
|
15
22
|
|
|
16
|
-
.
|
|
23
|
+
.chart-wrapper__title::slotted(h3) {
|
|
24
|
+
color: var(--leu-color-black-100);
|
|
17
25
|
font: var(--leu-t-curve-medium-black-font);
|
|
18
26
|
margin: 0 0 0.5rem;
|
|
19
27
|
}
|
|
20
28
|
|
|
21
|
-
.
|
|
29
|
+
.chart-wrapper__title::slotted(h4) {
|
|
30
|
+
color: var(--leu-color-black-100);
|
|
22
31
|
font: var(--leu-t-curve-regular-black-font);
|
|
23
32
|
margin: 0 0 0.5rem;
|
|
24
33
|
}
|
|
25
34
|
|
|
26
|
-
.
|
|
27
|
-
.chart {
|
|
35
|
+
.chart-wrapper__description,
|
|
36
|
+
.chart-wrapper__chart {
|
|
28
37
|
display: block;
|
|
29
38
|
margin-bottom: 0.75rem;
|
|
30
39
|
|
|
@@ -37,17 +46,17 @@
|
|
|
37
46
|
}
|
|
38
47
|
}
|
|
39
48
|
|
|
40
|
-
.
|
|
49
|
+
.chart-wrapper__description {
|
|
41
50
|
font: var(--leu-t-curve-small-regular-font);
|
|
42
51
|
color: var(--leu-color-black-60);
|
|
43
52
|
}
|
|
44
53
|
|
|
45
|
-
.
|
|
54
|
+
.chart-wrapper__caption {
|
|
46
55
|
font: var(--leu-t-curve-tiny-regular-font);
|
|
47
56
|
color: var(--leu-color-black-60);
|
|
48
57
|
}
|
|
49
58
|
|
|
50
|
-
.
|
|
59
|
+
.chart-wrapper__ruler {
|
|
51
60
|
display: block;
|
|
52
61
|
border: none;
|
|
53
62
|
border-top: 1px solid var(--leu-color-black-transp-20);
|
|
@@ -58,16 +67,16 @@
|
|
|
58
67
|
}
|
|
59
68
|
}
|
|
60
69
|
|
|
61
|
-
.
|
|
70
|
+
.chart-wrapper__download {
|
|
62
71
|
display: block;
|
|
63
72
|
margin-left: -0.5rem;
|
|
64
73
|
}
|
|
65
74
|
|
|
66
|
-
.chart-
|
|
75
|
+
.chart-wrapper__container {
|
|
67
76
|
position: relative;
|
|
68
77
|
}
|
|
69
78
|
|
|
70
|
-
.
|
|
79
|
+
.chart-wrapper__spinner-container {
|
|
71
80
|
position: absolute;
|
|
72
81
|
top: 0;
|
|
73
82
|
left: 0;
|
|
@@ -50,25 +50,28 @@ describe("LeuChartWrapper", () => {
|
|
|
50
50
|
it("conditionally renders slots", async () => {
|
|
51
51
|
let el = await defaultFixture()
|
|
52
52
|
|
|
53
|
-
expect(el.shadowRoot.querySelector(".
|
|
54
|
-
expect(el.shadowRoot.querySelector(".
|
|
55
|
-
expect(el.shadowRoot.querySelector(".
|
|
53
|
+
expect(el.shadowRoot.querySelector(".chart-wrapper__description")).to.exist
|
|
54
|
+
expect(el.shadowRoot.querySelector(".chart-wrapper__caption")).to.exist
|
|
55
|
+
expect(el.shadowRoot.querySelector(".chart-wrapper__download")).to.exist
|
|
56
56
|
|
|
57
57
|
el = await fixture(html`<leu-chart-wrapper></leu-chart-wrapper>`)
|
|
58
58
|
|
|
59
|
-
expect(el.shadowRoot.querySelector(".
|
|
60
|
-
|
|
61
|
-
expect(el.shadowRoot.querySelector(".
|
|
59
|
+
expect(el.shadowRoot.querySelector(".chart-wrapper__description")).not.to
|
|
60
|
+
.exist
|
|
61
|
+
expect(el.shadowRoot.querySelector(".chart-wrapper__caption")).not.to.exist
|
|
62
|
+
expect(el.shadowRoot.querySelector(".chart-wrapper__download")).not.to.exist
|
|
62
63
|
|
|
63
64
|
// Check that the title and chart slots are always present
|
|
64
|
-
expect(el.shadowRoot.querySelector(".
|
|
65
|
-
expect(el.shadowRoot.querySelector(".chart")).to.exist
|
|
65
|
+
expect(el.shadowRoot.querySelector(".chart-wrapper__title")).to.exist
|
|
66
|
+
expect(el.shadowRoot.querySelector(".chart-wrapper__chart")).to.exist
|
|
66
67
|
})
|
|
67
68
|
|
|
68
69
|
it("shows a spinner when pending is set", async () => {
|
|
69
70
|
const el = await defaultFixture({ pending: true })
|
|
70
71
|
|
|
71
|
-
expect(el.shadowRoot.querySelector(".
|
|
72
|
-
|
|
72
|
+
expect(el.shadowRoot.querySelector(".chart-wrapper__spinner-container")).to
|
|
73
|
+
.exist
|
|
74
|
+
expect(el.shadowRoot.querySelector("leu-spinner.chart-wrapper__spinner")).to
|
|
75
|
+
.exist
|
|
73
76
|
})
|
|
74
77
|
})
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { html, nothing } from "lit"
|
|
2
|
+
import { property } from "lit/decorators.js"
|
|
3
|
+
import { classMap } from "lit/directives/class-map.js"
|
|
4
|
+
|
|
5
|
+
import { LeuElement } from "../../lib/LeuElement.js"
|
|
6
|
+
|
|
7
|
+
import styles from "./message.css"
|
|
8
|
+
import { LeuIcon } from "../icon/Icon.js"
|
|
9
|
+
import { HasSlotController } from "../../lib/hasSlotController.js"
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @tagname leu-message
|
|
13
|
+
* @cssprop --leu-message-accent-color - Sets the color of the message. According to the design system, it is only allowd for `info`
|
|
14
|
+
* @slot [default] - The content of the message. The title of the message should marked up with a `<strong>` tag.
|
|
15
|
+
* @slot cta - A call to action button that is only allowed for `size=large`
|
|
16
|
+
* @fires leu:remove - Fired when the close button is clicked.
|
|
17
|
+
*/
|
|
18
|
+
export class LeuMessage extends LeuElement {
|
|
19
|
+
static styles = [LeuElement.styles, styles]
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
static shadowRootOptions = {
|
|
25
|
+
...LeuElement.shadowRootOptions,
|
|
26
|
+
delegatesFocus: true,
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
static dependencies = {
|
|
33
|
+
"leu-icon": LeuIcon,
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
39
|
+
static iconToTypeMap = {
|
|
40
|
+
info: "getInformation",
|
|
41
|
+
error: "caution",
|
|
42
|
+
success: "confirm",
|
|
43
|
+
warning: "caution",
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The type of the message. `error` and `success` will be displayed as filled boxes.
|
|
48
|
+
*/
|
|
49
|
+
@property({ type: String, reflect: true })
|
|
50
|
+
type: "error" | "success" | "info" | "warning" = "success"
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The size of the message. A call to action button is only allowed for `large` messages.
|
|
54
|
+
*/
|
|
55
|
+
@property({ type: String, reflect: true })
|
|
56
|
+
size: "regular" | "large" = "regular"
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Wheter the message is removable or not. The component will not remove itself when the close button is clicked.
|
|
60
|
+
*/
|
|
61
|
+
@property({ type: Boolean, reflect: true })
|
|
62
|
+
removable: boolean = false
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Wheter the message is used as a popup or not. This will add a drop shadow but will not position the message absolutely.
|
|
66
|
+
*/
|
|
67
|
+
@property({ type: Boolean, reflect: true })
|
|
68
|
+
popup: boolean = false
|
|
69
|
+
|
|
70
|
+
private hasSlotController = new HasSlotController(this, ["cta"])
|
|
71
|
+
|
|
72
|
+
protected renderIcon() {
|
|
73
|
+
const name = LeuMessage.iconToTypeMap[this.type]
|
|
74
|
+
|
|
75
|
+
return html`<leu-icon class="message__icon" name=${name}></leu-icon>`
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
protected handleRemove() {
|
|
79
|
+
this.dispatchEvent(
|
|
80
|
+
new CustomEvent("leu:remove", {
|
|
81
|
+
bubbles: true,
|
|
82
|
+
composed: true,
|
|
83
|
+
}),
|
|
84
|
+
)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
render() {
|
|
88
|
+
const hasCta = this.hasSlotController.test("cta")
|
|
89
|
+
const classes = classMap({
|
|
90
|
+
message: true,
|
|
91
|
+
"message--filled": this.type === "error" || this.type === "success",
|
|
92
|
+
"message--popup": this.popup,
|
|
93
|
+
[`message--${this.size}`]: true,
|
|
94
|
+
[`message--${this.type}`]: true,
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
return html`
|
|
98
|
+
<div class="${classes}">
|
|
99
|
+
${this.renderIcon()}
|
|
100
|
+
<p class="message__content">
|
|
101
|
+
<slot></slot>
|
|
102
|
+
</p>
|
|
103
|
+
${hasCta
|
|
104
|
+
? html`<slot class="message__cta" name="cta"></slot>`
|
|
105
|
+
: nothing}
|
|
106
|
+
${this.removable
|
|
107
|
+
? html`<button
|
|
108
|
+
class="message__remove"
|
|
109
|
+
aria-label="Meldung schliessen"
|
|
110
|
+
@click=${this.handleRemove}
|
|
111
|
+
>
|
|
112
|
+
<leu-icon class="message__remove-icon" name="close"></leu-icon>
|
|
113
|
+
</button>`
|
|
114
|
+
: nothing}
|
|
115
|
+
</div>
|
|
116
|
+
`
|
|
117
|
+
}
|
|
118
|
+
}
|