@statistikzh/leu 0.15.1 → 0.17.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 +14 -0
- package/dist/Accordion.js +1 -1
- package/dist/Button.js +1 -1
- package/dist/ButtonGroup.js +1 -1
- package/dist/ChartWrapper.js +1 -1
- 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-B84x5CPL.js → LeuElement-BRZYxDjR.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/Tag.d.ts +17 -0
- package/dist/Tag.js +75 -0
- package/dist/VisuallyHidden.js +1 -1
- 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/components/tag/Tag.d.ts +13 -0
- package/dist/components/tag/Tag.d.ts.map +1 -0
- package/dist/components/tag/leu-tag.d.ts +3 -0
- package/dist/components/tag/leu-tag.d.ts.map +1 -0
- package/dist/components/tag/stories/tag.stories.d.ts +136 -0
- package/dist/components/tag/stories/tag.stories.d.ts.map +1 -0
- package/dist/components/tag/test/tag.test.d.ts +2 -0
- package/dist/components/tag/test/tag.test.d.ts.map +1 -0
- package/dist/index.js +1 -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-tag.d.ts +4 -0
- package/dist/leu-tag.js +9 -0
- package/dist/leu-visually-hidden.js +1 -1
- package/dist/vscode.html-custom-data.json +68 -11
- package/dist/vue/index.d.ts +72 -20
- package/dist/web-types.json +137 -28
- package/package.json +1 -1
- 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/components/tag/Tag.ts +28 -0
- package/src/components/tag/leu-tag.ts +5 -0
- package/src/components/tag/stories/tag.stories.ts +107 -0
- package/src/components/tag/tag.css +42 -0
- package/src/components/tag/test/tag.test.ts +28 -0
- package/src/docs/theme.mdx +49 -2
- package/src/styles/custom-media.css +1 -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.17.0",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"contributions": {
|
|
7
7
|
"html": {
|
|
@@ -65,33 +65,6 @@
|
|
|
65
65
|
"events": []
|
|
66
66
|
}
|
|
67
67
|
},
|
|
68
|
-
{
|
|
69
|
-
"name": "leu-button-group",
|
|
70
|
-
"description": "A radio input-like button group component.\nIt allows only one button to be active at a time.\n---\n\n\n### **Events:**\n - **input** - When the value of the group changes by clicking a button\n\n### **Slots:**\n - _default_ - Slot for the buttons",
|
|
71
|
-
"doc-url": "",
|
|
72
|
-
"attributes": [],
|
|
73
|
-
"slots": [{ "name": "", "description": "Slot for the buttons" }],
|
|
74
|
-
"events": [
|
|
75
|
-
{
|
|
76
|
-
"name": "input",
|
|
77
|
-
"description": "When the value of the group changes by clicking a button"
|
|
78
|
-
}
|
|
79
|
-
],
|
|
80
|
-
"js": {
|
|
81
|
-
"properties": [
|
|
82
|
-
{
|
|
83
|
-
"name": "value",
|
|
84
|
-
"description": "The value of the currently selected (active) button"
|
|
85
|
-
}
|
|
86
|
-
],
|
|
87
|
-
"events": [
|
|
88
|
-
{
|
|
89
|
-
"name": "input",
|
|
90
|
-
"description": "When the value of the group changes by clicking a button"
|
|
91
|
-
}
|
|
92
|
-
]
|
|
93
|
-
}
|
|
94
|
-
},
|
|
95
68
|
{
|
|
96
69
|
"name": "leu-button",
|
|
97
70
|
"description": "\n---\n\n\n### **Slots:**\n - **before** - The icon to display before the label\n- **after** - The icon to display after the label\n- _default_ - The label of the button or the icon if no label is set",
|
|
@@ -238,6 +211,33 @@
|
|
|
238
211
|
"events": []
|
|
239
212
|
}
|
|
240
213
|
},
|
|
214
|
+
{
|
|
215
|
+
"name": "leu-button-group",
|
|
216
|
+
"description": "A radio input-like button group component.\nIt allows only one button to be active at a time.\n---\n\n\n### **Events:**\n - **input** - When the value of the group changes by clicking a button\n\n### **Slots:**\n - _default_ - Slot for the buttons",
|
|
217
|
+
"doc-url": "",
|
|
218
|
+
"attributes": [],
|
|
219
|
+
"slots": [{ "name": "", "description": "Slot for the buttons" }],
|
|
220
|
+
"events": [
|
|
221
|
+
{
|
|
222
|
+
"name": "input",
|
|
223
|
+
"description": "When the value of the group changes by clicking a button"
|
|
224
|
+
}
|
|
225
|
+
],
|
|
226
|
+
"js": {
|
|
227
|
+
"properties": [
|
|
228
|
+
{
|
|
229
|
+
"name": "value",
|
|
230
|
+
"description": "The value of the currently selected (active) button"
|
|
231
|
+
}
|
|
232
|
+
],
|
|
233
|
+
"events": [
|
|
234
|
+
{
|
|
235
|
+
"name": "input",
|
|
236
|
+
"description": "When the value of the group changes by clicking a button"
|
|
237
|
+
}
|
|
238
|
+
]
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
241
|
{
|
|
242
242
|
"name": "leu-chart-wrapper",
|
|
243
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.",
|
|
@@ -969,6 +969,87 @@
|
|
|
969
969
|
"events": []
|
|
970
970
|
}
|
|
971
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
|
+
},
|
|
972
1053
|
{
|
|
973
1054
|
"name": "leu-pagination",
|
|
974
1055
|
"description": "\n---\n\n\n### **Events:**\n - **leu:pagechange**",
|
|
@@ -1433,6 +1514,34 @@
|
|
|
1433
1514
|
"events": []
|
|
1434
1515
|
}
|
|
1435
1516
|
},
|
|
1517
|
+
{
|
|
1518
|
+
"name": "leu-tag",
|
|
1519
|
+
"description": "\n---\n\n\n### **Slots:**\n - **default** - The label of the tag\n- **icon** - An icon to display in the tag\n\n### **CSS Properties:**\n - **--leu-tag-accent-color** - The color of the tag _(default: undefined)_",
|
|
1520
|
+
"doc-url": "",
|
|
1521
|
+
"attributes": [
|
|
1522
|
+
{
|
|
1523
|
+
"name": "variant",
|
|
1524
|
+
"value": {
|
|
1525
|
+
"type": "\"solid\" | \"outline\" | \"ghost\"",
|
|
1526
|
+
"default": "\"solid\""
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1529
|
+
],
|
|
1530
|
+
"slots": [
|
|
1531
|
+
{ "name": "default", "description": "The label of the tag" },
|
|
1532
|
+
{ "name": "icon", "description": "An icon to display in the tag" }
|
|
1533
|
+
],
|
|
1534
|
+
"events": [],
|
|
1535
|
+
"js": {
|
|
1536
|
+
"properties": [
|
|
1537
|
+
{
|
|
1538
|
+
"name": "variant",
|
|
1539
|
+
"type": "\"solid\" | \"outline\" | \"ghost\""
|
|
1540
|
+
}
|
|
1541
|
+
],
|
|
1542
|
+
"events": []
|
|
1543
|
+
}
|
|
1544
|
+
},
|
|
1436
1545
|
{
|
|
1437
1546
|
"name": "leu-visually-hidden",
|
|
1438
1547
|
"description": "\n---\n",
|
package/package.json
CHANGED
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
@import url("../../styles/custom-media.css");
|
|
2
|
+
|
|
3
|
+
:host {
|
|
4
|
+
font-family: var(--leu-font-family-regular);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.message {
|
|
8
|
+
position: relative;
|
|
9
|
+
display: flex;
|
|
10
|
+
flex-flow: row nowrap;
|
|
11
|
+
align-items: center;
|
|
12
|
+
|
|
13
|
+
padding: var(--_padding);
|
|
14
|
+
border-radius: 0.25rem;
|
|
15
|
+
overflow: hidden;
|
|
16
|
+
|
|
17
|
+
background-color: var(--leu-color-black-0);
|
|
18
|
+
color: var(--_accent-color);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.message::before {
|
|
22
|
+
content: "";
|
|
23
|
+
position: absolute;
|
|
24
|
+
inset-block-start: 0;
|
|
25
|
+
inset-inline-start: 0;
|
|
26
|
+
width: 0.25rem;
|
|
27
|
+
height: 100%;
|
|
28
|
+
background-color: var(--_accent-color);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.message--error {
|
|
32
|
+
--_accent-color: var(--leu-message-accent-color, var(--leu-color-func-red));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.message--warning {
|
|
36
|
+
--_accent-color: var(--leu-message-accent-color, var(--leu-color-func-red));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.message--success {
|
|
40
|
+
--_accent-color: var(--leu-message-accent-color, var(--leu-color-func-green));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.message--info {
|
|
44
|
+
--_accent-color: var(
|
|
45
|
+
--leu-message-accent-color,
|
|
46
|
+
var(--leu-color-accent-violet)
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.message--filled {
|
|
51
|
+
background-color: var(--_accent-color);
|
|
52
|
+
color: var(--leu-color-black-0);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.message--filled::before {
|
|
56
|
+
content: none;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.message--regular {
|
|
60
|
+
--_padding: 0.75rem;
|
|
61
|
+
--_icon-size: 24px;
|
|
62
|
+
|
|
63
|
+
@media (--viewport-large) {
|
|
64
|
+
--_padding: 1rem;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.message--large {
|
|
69
|
+
--_padding: 1rem;
|
|
70
|
+
--_icon-size: 32px;
|
|
71
|
+
|
|
72
|
+
@media (--viewport-small-max) {
|
|
73
|
+
flex-flow: column;
|
|
74
|
+
align-items: start;
|
|
75
|
+
gap: 0.75rem;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@media (--viewport-regular) {
|
|
79
|
+
--_padding: 1.25rem;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@media (--viewport-large) {
|
|
83
|
+
--_padding: 1.5rem;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.message--popup {
|
|
88
|
+
box-shadow: var(--leu-box-shadow-regular);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.message__icon {
|
|
92
|
+
--leu-icon-size: var(--_icon-size);
|
|
93
|
+
|
|
94
|
+
display: block;
|
|
95
|
+
flex: 0 0 min-content;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.message__content {
|
|
99
|
+
flex: 1 1 auto;
|
|
100
|
+
font: var(--leu-t-curve-small-regular-font);
|
|
101
|
+
margin: 0 0.5rem;
|
|
102
|
+
|
|
103
|
+
@media (--viewport-regular) {
|
|
104
|
+
margin-inline: 0.75rem;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
@media (--viewport-large) {
|
|
108
|
+
margin-inline: 1rem;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.message--large .message__content {
|
|
113
|
+
@media (--viewport-small-max) {
|
|
114
|
+
margin-inline: 0;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.message__content ::slotted(strong) {
|
|
119
|
+
font-family: var(--leu-font-family-black);
|
|
120
|
+
font-weight: normal;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.message__cta {
|
|
124
|
+
display: block;
|
|
125
|
+
flex: 0 0 min-content;
|
|
126
|
+
margin-inline-end: 0.5rem;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.message__remove {
|
|
130
|
+
flex: 0 0 min-content;
|
|
131
|
+
border: none;
|
|
132
|
+
background: none;
|
|
133
|
+
padding: 0;
|
|
134
|
+
color: var(--leu-color-black-60);
|
|
135
|
+
cursor: pointer;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.message__remove:where(:hover, :focus-visible) {
|
|
139
|
+
color: var(--leu-color-black-40);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.message--filled .message__remove {
|
|
143
|
+
color: var(--leu-color-black-0);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.message--filled .message__remove:where(:hover, :focus-visible) {
|
|
147
|
+
color: var(--leu-color-white-transp-70);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.message--large .message__remove {
|
|
151
|
+
position: absolute;
|
|
152
|
+
inset-block-start: var(--_padding);
|
|
153
|
+
inset-inline-end: var(--_padding);
|
|
154
|
+
|
|
155
|
+
@media (--viewport-regular) {
|
|
156
|
+
position: static;
|
|
157
|
+
inset: auto;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.message__remove-icon {
|
|
162
|
+
--leu-icon-size: 1.5rem;
|
|
163
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Canvas, Meta, Controls } from "@storybook/addon-docs/blocks"
|
|
2
|
+
|
|
3
|
+
import * as MessageStories from "./message.stories"
|
|
4
|
+
|
|
5
|
+
<Meta of={MessageStories} />
|
|
6
|
+
|
|
7
|
+
# Message
|
|
8
|
+
|
|
9
|
+
A message component that can be used to display feedback, alerts, or important information to the user.
|
|
10
|
+
|
|
11
|
+
[Meldungen | Design System | zh.ch](https://www.zh.ch/de/webangebote-entwickeln-und-gestalten/inhalt/designsystem/komponenten/meldungen.zhweb-noredirect.zhweb-cache.html?node-id=18369%3A164719&node-id=18369%3A163396&node-id=18369%3A166594&search=meldung) <br />
|
|
12
|
+
|
|
13
|
+
## Background
|
|
14
|
+
|
|
15
|
+
The message can appear with a colored background or with a white background. The appearance depends on the `type` attribute:
|
|
16
|
+
|
|
17
|
+
`success` and `warning` will have a colored background.
|
|
18
|
+
|
|
19
|
+
<Canvas of={MessageStories.Success} />
|
|
20
|
+
<Canvas of={MessageStories.Error} />
|
|
21
|
+
|
|
22
|
+
While `error` and `info` will have a white background.
|
|
23
|
+
|
|
24
|
+
<Canvas of={MessageStories.Warning} />
|
|
25
|
+
<Canvas of={MessageStories.Info} />
|
|
26
|
+
|
|
27
|
+
## Content
|
|
28
|
+
|
|
29
|
+
The text content can simply be passed into the default slot. The optional title of the message has to be marked up with a `<strong>` tag.
|
|
30
|
+
|
|
31
|
+
```html
|
|
32
|
+
<leu-message>
|
|
33
|
+
<strong>Title of the message</strong><br />
|
|
34
|
+
This is the content of the message. It can span multiple lines.
|
|
35
|
+
</leu-message>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Size
|
|
39
|
+
|
|
40
|
+
The message component can be rendered in two sizes: `small` and `large`.
|
|
41
|
+
The `small` size does not allow for a call to action button and a title.
|
|
42
|
+
|
|
43
|
+
## Call to action button
|
|
44
|
+
|
|
45
|
+
A call to action button can added to the message by using the `cta` slot. This is only allowed for the `large` size.
|
|
46
|
+
Be aware that you have to set the `inverted` attribute on the button if you use it on a colored background.
|
|
47
|
+
The component does not handle any events of the button.
|
|
48
|
+
|
|
49
|
+
## Remove button
|
|
50
|
+
|
|
51
|
+
With setting the `removable` attribute, a close button will be displayed in the top right corner of the message.
|
|
52
|
+
The component does not remove itself from the DOM, but it will dispatch a `leu:remove` event when the close button is clicked.
|
|
53
|
+
|
|
54
|
+
## Popup / Toast
|
|
55
|
+
|
|
56
|
+
If you use the message as a toast or lay it over other content, you can set the `popup` attribute.
|
|
57
|
+
This will add box shadow to the message.
|
|
58
|
+
|
|
59
|
+
<Canvas of={MessageStories.Popup} />
|
|
60
|
+
|
|
61
|
+
## Custom accent colored
|
|
62
|
+
|
|
63
|
+
While `success`, `warning`, and `error` have a predefined accent color, you can set a custom accent color for the `info` type.
|
|
64
|
+
Just set the `--leu-message-accent-color` css custom property on the message element.
|
|
65
|
+
|
|
66
|
+
<Canvas of={MessageStories.CustomColor} />
|
|
67
|
+
|
|
68
|
+
## Accessibility
|
|
69
|
+
|
|
70
|
+
We have decided to not use the `role="alert"` or the
|
|
71
|
+
`aria-live` attribute as the message component can be used in various contexts.
|
|
72
|
+
We simply can't predict which role or which `aria-live` value would make sense.
|
|
73
|
+
Please ensure that you add the appropriate role or attribute yourself.
|
|
74
|
+
|
|
75
|
+
<Controls />
|
|
76
|
+
```
|