@momentum-design/components 0.98.1 → 0.100.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/dist/browser/index.js +410 -271
- package/dist/browser/index.js.map +4 -4
- package/dist/components/card/card.styles.js +2 -2
- package/dist/components/toast/index.d.ts +11 -0
- package/dist/components/toast/index.js +8 -0
- package/dist/components/toast/toast.component.d.ts +101 -0
- package/dist/components/toast/toast.component.js +242 -0
- package/dist/components/toast/toast.constants.d.ts +26 -0
- package/dist/components/toast/toast.constants.js +28 -0
- package/dist/components/toast/toast.styles.d.ts +2 -0
- package/dist/components/toast/toast.styles.js +88 -0
- package/dist/components/toast/toast.types.d.ts +7 -0
- package/dist/components/toast/toast.types.js +1 -0
- package/dist/components/toast/toast.utils.d.ts +3 -0
- package/dist/components/toast/toast.utils.js +14 -0
- package/dist/custom-elements.json +4440 -4054
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/react/index.d.ts +5 -4
- package/dist/react/index.js +5 -4
- package/dist/react/toast/index.d.ts +45 -0
- package/dist/react/toast/index.js +53 -0
- package/package.json +1 -1
@@ -0,0 +1,101 @@
|
|
1
|
+
import type { CSSResult, PropertyValues } from 'lit';
|
2
|
+
import { nothing } from 'lit';
|
3
|
+
import { Component } from '../../models';
|
4
|
+
import type { TagName } from '../text/text.types';
|
5
|
+
import type { ToastVariant } from './toast.types';
|
6
|
+
declare const Toast_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/FooterMixin").FooterMixinInterface> & typeof Component;
|
7
|
+
/**
|
8
|
+
* `mdc-toast` is a lightweight, non-blocking alert used to inform users about application processes.
|
9
|
+
* It supports success, warning, error, and custom messages, and is designed to be controlled externally.
|
10
|
+
*
|
11
|
+
* **Note**: When using `slot="toast-body-normal"` and `slot="toast-body-detailed"`, it's strongly recommended to wrap the content with `<mdc-text tagname="span">`.
|
12
|
+
* If not used, ensure your custom content is styled appropriately to match the design and alignment expectations of the toast component.
|
13
|
+
*
|
14
|
+
* @dependency mdc-icon
|
15
|
+
* @dependency mdc-text
|
16
|
+
* @dependency mdc-button
|
17
|
+
* @dependency mdc-linkbutton
|
18
|
+
*
|
19
|
+
* @slot content-prefix - Slot for custom content before the icon (only for custom variant).
|
20
|
+
* @slot toast-body-normal - Slot for the main body content of the toast.
|
21
|
+
* @slot toast-body-detailed - Slot for additional detailed content, shown when expanded.
|
22
|
+
* @slot footer - Slot for custom footer content. Prefer using footer-button-primary and footer-button-secondary slots.
|
23
|
+
* @slot footer-button-primary - Slot for passing the primary variant of `mdc-button` in the footer.
|
24
|
+
* @slot footer-button-secondary - Slot for passing the secondary variant of `mdc-button` in the footer.
|
25
|
+
*
|
26
|
+
* @tagname mdc-toast
|
27
|
+
*
|
28
|
+
* @event close - (React: onClose) Dispatched when the Close Button is clicked using mouse or keyboard.
|
29
|
+
*
|
30
|
+
* @csspart content-container - The container for the toast's main content, including icon, text, and close button.
|
31
|
+
* @csspart toast-prefix-icon - The icon shown at the start of the toast, styled by variant.
|
32
|
+
* @csspart toast-content - The container for the header and body content of the toast.
|
33
|
+
* @csspart toast-header - The header text of the toast.
|
34
|
+
* @csspart footer - The container for the toast's footer, including toggle and action buttons.
|
35
|
+
* @csspart footer-button-toggle - The toggle button for showing/hiding detailed content.
|
36
|
+
* @csspart toast-close-btn - The close button for the toast.
|
37
|
+
*
|
38
|
+
* @cssproperty --mdc-toast-background-color - Background color of the toast.
|
39
|
+
* @cssproperty --mdc-toast-border-color - Border color of the toast.
|
40
|
+
* @cssproperty --mdc-toast-header-text-color - Color of the header text in the toast.
|
41
|
+
* @cssproperty --mdc-toast-icon-color - Color of the icon in the toast.
|
42
|
+
* @cssproperty --mdc-toast-elevation-3 - Elevation effect applied to the toast.
|
43
|
+
* @cssproperty --mdc-toast-width - Width of the toast.
|
44
|
+
* @cssproperty --mdc-toast-padding - Padding inside the toast.
|
45
|
+
*/
|
46
|
+
declare class Toast extends Toast_base {
|
47
|
+
/**
|
48
|
+
* Type of toast
|
49
|
+
* - Can be `custom`, `success`, `warning` or `error`.
|
50
|
+
* @default 'custom'
|
51
|
+
*/
|
52
|
+
variant: ToastVariant;
|
53
|
+
/**
|
54
|
+
* Defines aria-label attribute for close button accessibility
|
55
|
+
*/
|
56
|
+
closeButtonAriaLabel?: string;
|
57
|
+
/**
|
58
|
+
* Defines a string value to display as the title of the toast
|
59
|
+
*/
|
60
|
+
headerText?: string;
|
61
|
+
/**
|
62
|
+
* The html tag to be used for the header text
|
63
|
+
* @default 'h2'
|
64
|
+
*/
|
65
|
+
headerTagName: TagName;
|
66
|
+
/**
|
67
|
+
* Defines aria-label attribute when header is not used
|
68
|
+
*/
|
69
|
+
ariaLabel: string | null;
|
70
|
+
/**
|
71
|
+
* Defines the text shown on the linkbutton when detailed content is hidden.
|
72
|
+
*/
|
73
|
+
showMoreText?: string;
|
74
|
+
/**
|
75
|
+
* Defines the text shown on the linkbutton when detailed content is visible.
|
76
|
+
*/
|
77
|
+
showLessText?: string;
|
78
|
+
private isDetailVisible;
|
79
|
+
private hasDetailedSlot;
|
80
|
+
private detailedElements;
|
81
|
+
private hasFooterButtons;
|
82
|
+
/**
|
83
|
+
* Fired when Close Button is clicked using mouse or keyboard.
|
84
|
+
* This method dispatches the close event.
|
85
|
+
* It is used to notify that the toast should be closed.
|
86
|
+
*/
|
87
|
+
private closeToast;
|
88
|
+
private toggleDetailVisibility;
|
89
|
+
private updateDetailedSlotPresence;
|
90
|
+
private updateFooterButtonsPresence;
|
91
|
+
protected firstUpdated(changedProperties: PropertyValues): void;
|
92
|
+
protected renderIcon(iconName: string): import("lit-html").TemplateResult<1> | typeof nothing;
|
93
|
+
private shouldRenderToggleButton;
|
94
|
+
private renderToggleDetailButton;
|
95
|
+
protected renderHeader(): import("lit-html").TemplateResult<1> | typeof nothing;
|
96
|
+
protected handleFooterSlot(tagname: string, variant?: string | undefined): void;
|
97
|
+
protected renderFooter(): import("lit-html").TemplateResult<1>;
|
98
|
+
render(): import("lit-html").TemplateResult<1>;
|
99
|
+
static styles: Array<CSSResult>;
|
100
|
+
}
|
101
|
+
export default Toast;
|
@@ -0,0 +1,242 @@
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
6
|
+
};
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
9
|
+
};
|
10
|
+
import { html, nothing } from 'lit';
|
11
|
+
import { property, queryAssignedElements, state } from 'lit/decorators.js';
|
12
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
13
|
+
import { Component } from '../../models';
|
14
|
+
import { FooterMixin } from '../../utils/mixins/FooterMixin';
|
15
|
+
import { TYPE } from '../text/text.constants';
|
16
|
+
import { DEFAULTS } from './toast.constants';
|
17
|
+
import { getIconNameForVariant } from './toast.utils';
|
18
|
+
import styles from './toast.styles';
|
19
|
+
/**
|
20
|
+
* `mdc-toast` is a lightweight, non-blocking alert used to inform users about application processes.
|
21
|
+
* It supports success, warning, error, and custom messages, and is designed to be controlled externally.
|
22
|
+
*
|
23
|
+
* **Note**: When using `slot="toast-body-normal"` and `slot="toast-body-detailed"`, it's strongly recommended to wrap the content with `<mdc-text tagname="span">`.
|
24
|
+
* If not used, ensure your custom content is styled appropriately to match the design and alignment expectations of the toast component.
|
25
|
+
*
|
26
|
+
* @dependency mdc-icon
|
27
|
+
* @dependency mdc-text
|
28
|
+
* @dependency mdc-button
|
29
|
+
* @dependency mdc-linkbutton
|
30
|
+
*
|
31
|
+
* @slot content-prefix - Slot for custom content before the icon (only for custom variant).
|
32
|
+
* @slot toast-body-normal - Slot for the main body content of the toast.
|
33
|
+
* @slot toast-body-detailed - Slot for additional detailed content, shown when expanded.
|
34
|
+
* @slot footer - Slot for custom footer content. Prefer using footer-button-primary and footer-button-secondary slots.
|
35
|
+
* @slot footer-button-primary - Slot for passing the primary variant of `mdc-button` in the footer.
|
36
|
+
* @slot footer-button-secondary - Slot for passing the secondary variant of `mdc-button` in the footer.
|
37
|
+
*
|
38
|
+
* @tagname mdc-toast
|
39
|
+
*
|
40
|
+
* @event close - (React: onClose) Dispatched when the Close Button is clicked using mouse or keyboard.
|
41
|
+
*
|
42
|
+
* @csspart content-container - The container for the toast's main content, including icon, text, and close button.
|
43
|
+
* @csspart toast-prefix-icon - The icon shown at the start of the toast, styled by variant.
|
44
|
+
* @csspart toast-content - The container for the header and body content of the toast.
|
45
|
+
* @csspart toast-header - The header text of the toast.
|
46
|
+
* @csspart footer - The container for the toast's footer, including toggle and action buttons.
|
47
|
+
* @csspart footer-button-toggle - The toggle button for showing/hiding detailed content.
|
48
|
+
* @csspart toast-close-btn - The close button for the toast.
|
49
|
+
*
|
50
|
+
* @cssproperty --mdc-toast-background-color - Background color of the toast.
|
51
|
+
* @cssproperty --mdc-toast-border-color - Border color of the toast.
|
52
|
+
* @cssproperty --mdc-toast-header-text-color - Color of the header text in the toast.
|
53
|
+
* @cssproperty --mdc-toast-icon-color - Color of the icon in the toast.
|
54
|
+
* @cssproperty --mdc-toast-elevation-3 - Elevation effect applied to the toast.
|
55
|
+
* @cssproperty --mdc-toast-width - Width of the toast.
|
56
|
+
* @cssproperty --mdc-toast-padding - Padding inside the toast.
|
57
|
+
*/
|
58
|
+
class Toast extends FooterMixin(Component) {
|
59
|
+
constructor() {
|
60
|
+
super(...arguments);
|
61
|
+
/**
|
62
|
+
* Type of toast
|
63
|
+
* - Can be `custom`, `success`, `warning` or `error`.
|
64
|
+
* @default 'custom'
|
65
|
+
*/
|
66
|
+
this.variant = DEFAULTS.VARIANT;
|
67
|
+
/**
|
68
|
+
* The html tag to be used for the header text
|
69
|
+
* @default 'h2'
|
70
|
+
*/
|
71
|
+
this.headerTagName = DEFAULTS.HEADER_TAG_NAME;
|
72
|
+
/**
|
73
|
+
* Defines aria-label attribute when header is not used
|
74
|
+
*/
|
75
|
+
this.ariaLabel = null;
|
76
|
+
this.isDetailVisible = false;
|
77
|
+
this.hasDetailedSlot = false;
|
78
|
+
this.hasFooterButtons = '';
|
79
|
+
}
|
80
|
+
/**
|
81
|
+
* Fired when Close Button is clicked using mouse or keyboard.
|
82
|
+
* This method dispatches the close event.
|
83
|
+
* It is used to notify that the toast should be closed.
|
84
|
+
*/
|
85
|
+
closeToast() {
|
86
|
+
const closeEvent = new CustomEvent('close', {
|
87
|
+
bubbles: true,
|
88
|
+
composed: true,
|
89
|
+
detail: { id: this.id },
|
90
|
+
});
|
91
|
+
this.dispatchEvent(closeEvent);
|
92
|
+
}
|
93
|
+
toggleDetailVisibility() {
|
94
|
+
this.isDetailVisible = !this.isDetailVisible;
|
95
|
+
}
|
96
|
+
updateDetailedSlotPresence() {
|
97
|
+
var _a, _b;
|
98
|
+
this.hasDetailedSlot = (_b = (_a = this.detailedElements) === null || _a === void 0 ? void 0 : _a.some((el) => { var _a; return (_a = el.textContent) === null || _a === void 0 ? void 0 : _a.trim(); })) !== null && _b !== void 0 ? _b : false;
|
99
|
+
}
|
100
|
+
updateFooterButtonsPresence() {
|
101
|
+
var _a, _b, _c, _d;
|
102
|
+
this.hasFooterButtons = ((_b = (_a = this.footerButtonPrimary) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0 ||
|
103
|
+
((_d = (_c = this.footerButtonSecondary) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0) > 0 ||
|
104
|
+
this.shouldRenderToggleButton() ? 'has-footer-buttons' : '';
|
105
|
+
}
|
106
|
+
firstUpdated(changedProperties) {
|
107
|
+
super.firstUpdated(changedProperties);
|
108
|
+
this.updateDetailedSlotPresence();
|
109
|
+
}
|
110
|
+
renderIcon(iconName) {
|
111
|
+
if (!iconName)
|
112
|
+
return nothing;
|
113
|
+
return html `
|
114
|
+
<mdc-icon
|
115
|
+
name="${iconName}"
|
116
|
+
size="${DEFAULTS.PREFIX_ICON_SIZE}"
|
117
|
+
part="toast-prefix-icon"
|
118
|
+
></mdc-icon>
|
119
|
+
`;
|
120
|
+
}
|
121
|
+
shouldRenderToggleButton() {
|
122
|
+
return this.hasDetailedSlot && this.showMoreText && this.showLessText;
|
123
|
+
}
|
124
|
+
renderToggleDetailButton() {
|
125
|
+
if (!this.shouldRenderToggleButton())
|
126
|
+
return nothing;
|
127
|
+
return html `
|
128
|
+
<mdc-linkbutton
|
129
|
+
part="footer-button-toggle"
|
130
|
+
@click="${this.toggleDetailVisibility}"
|
131
|
+
icon-name="${this.isDetailVisible ? DEFAULTS.ARROW_UP_BOLD : DEFAULTS.ARROW_DOWN_BOLD}"
|
132
|
+
>
|
133
|
+
${this.isDetailVisible ? this.showLessText : this.showMoreText}
|
134
|
+
</mdc-linkbutton>
|
135
|
+
`;
|
136
|
+
}
|
137
|
+
renderHeader() {
|
138
|
+
return this.headerText
|
139
|
+
? html `
|
140
|
+
<mdc-text
|
141
|
+
part="toast-header"
|
142
|
+
tagname="${this.headerTagName}"
|
143
|
+
type="${TYPE.BODY_LARGE_BOLD}"
|
144
|
+
>
|
145
|
+
${this.headerText}
|
146
|
+
</mdc-text>
|
147
|
+
`
|
148
|
+
: nothing;
|
149
|
+
}
|
150
|
+
handleFooterSlot(tagname, variant) {
|
151
|
+
super.handleFooterSlot(tagname, variant);
|
152
|
+
this.updateFooterButtonsPresence();
|
153
|
+
}
|
154
|
+
renderFooter() {
|
155
|
+
this.updateFooterButtonsPresence();
|
156
|
+
return html ` <slot name="footer">
|
157
|
+
<div part="footer" class="${this.hasFooterButtons}">
|
158
|
+
${this.renderToggleDetailButton()}
|
159
|
+
<slot
|
160
|
+
name="footer-button-secondary"
|
161
|
+
@slotchange=${() => this.handleFooterSlot(DEFAULTS.BUTTON, DEFAULTS.SECONDARY_BUTTON)}
|
162
|
+
></slot>
|
163
|
+
<slot
|
164
|
+
name="footer-button-primary"
|
165
|
+
@slotchange=${() => this.handleFooterSlot(DEFAULTS.BUTTON, DEFAULTS.PRIMARY_BUTTON)}
|
166
|
+
></slot>
|
167
|
+
</div>
|
168
|
+
</slot>`;
|
169
|
+
}
|
170
|
+
render() {
|
171
|
+
var _a;
|
172
|
+
return html `
|
173
|
+
<div part="content-container">
|
174
|
+
${this.variant === DEFAULTS.VARIANT
|
175
|
+
? html `<slot name="content-prefix"></slot>`
|
176
|
+
: html `${this.renderIcon((_a = getIconNameForVariant(this.variant)) !== null && _a !== void 0 ? _a : '')}`}
|
177
|
+
<div part="toast-content">
|
178
|
+
${this.renderHeader()}
|
179
|
+
<slot name="toast-body-normal"></slot>
|
180
|
+
<div ?hidden="${!this.isDetailVisible}">
|
181
|
+
<slot name="toast-body-detailed"></slot>
|
182
|
+
</div>
|
183
|
+
</div>
|
184
|
+
<mdc-button
|
185
|
+
part="toast-close-btn"
|
186
|
+
prefix-icon="${DEFAULTS.CANCEL_ICON}"
|
187
|
+
variant="${DEFAULTS.TERTIARY_BUTTON}"
|
188
|
+
size="${DEFAULTS.CLOSE_ICON_SIZE}"
|
189
|
+
aria-label="${ifDefined(this.closeButtonAriaLabel)}"
|
190
|
+
@click="${this.closeToast}"
|
191
|
+
></mdc-button>
|
192
|
+
</div>
|
193
|
+
${this.renderFooter()}
|
194
|
+
`;
|
195
|
+
}
|
196
|
+
}
|
197
|
+
Toast.styles = [...Component.styles, ...styles];
|
198
|
+
__decorate([
|
199
|
+
property({ type: String, reflect: true }),
|
200
|
+
__metadata("design:type", String)
|
201
|
+
], Toast.prototype, "variant", void 0);
|
202
|
+
__decorate([
|
203
|
+
property({ type: String, attribute: 'close-button-aria-label' }),
|
204
|
+
__metadata("design:type", String)
|
205
|
+
], Toast.prototype, "closeButtonAriaLabel", void 0);
|
206
|
+
__decorate([
|
207
|
+
property({ type: String, reflect: true, attribute: 'header-text' }),
|
208
|
+
__metadata("design:type", String)
|
209
|
+
], Toast.prototype, "headerText", void 0);
|
210
|
+
__decorate([
|
211
|
+
property({ type: String, reflect: true, attribute: 'header-tag-name' }),
|
212
|
+
__metadata("design:type", String)
|
213
|
+
], Toast.prototype, "headerTagName", void 0);
|
214
|
+
__decorate([
|
215
|
+
property({ type: String, reflect: true, attribute: 'aria-label' }),
|
216
|
+
__metadata("design:type", Object)
|
217
|
+
], Toast.prototype, "ariaLabel", void 0);
|
218
|
+
__decorate([
|
219
|
+
property({ type: String, reflect: true, attribute: 'show-more-text' }),
|
220
|
+
__metadata("design:type", String)
|
221
|
+
], Toast.prototype, "showMoreText", void 0);
|
222
|
+
__decorate([
|
223
|
+
property({ type: String, reflect: true, attribute: 'show-less-text' }),
|
224
|
+
__metadata("design:type", String)
|
225
|
+
], Toast.prototype, "showLessText", void 0);
|
226
|
+
__decorate([
|
227
|
+
state(),
|
228
|
+
__metadata("design:type", Boolean)
|
229
|
+
], Toast.prototype, "isDetailVisible", void 0);
|
230
|
+
__decorate([
|
231
|
+
state(),
|
232
|
+
__metadata("design:type", Boolean)
|
233
|
+
], Toast.prototype, "hasDetailedSlot", void 0);
|
234
|
+
__decorate([
|
235
|
+
queryAssignedElements({ slot: 'toast-body-detailed', flatten: true }),
|
236
|
+
__metadata("design:type", Array)
|
237
|
+
], Toast.prototype, "detailedElements", void 0);
|
238
|
+
__decorate([
|
239
|
+
state(),
|
240
|
+
__metadata("design:type", String)
|
241
|
+
], Toast.prototype, "hasFooterButtons", void 0);
|
242
|
+
export default Toast;
|
@@ -0,0 +1,26 @@
|
|
1
|
+
declare const TAG_NAME: "mdc-toast";
|
2
|
+
declare const TOAST_VARIANT: {
|
3
|
+
readonly CUSTOM: "custom";
|
4
|
+
readonly SUCCESS: "success";
|
5
|
+
readonly WARNING: "warning";
|
6
|
+
readonly ERROR: "error";
|
7
|
+
};
|
8
|
+
declare const VARIANT_ICON_NAMES: {
|
9
|
+
readonly SUCCESS_ICON_NAME: "check-circle-bold";
|
10
|
+
readonly WARNING_ICON_NAME: "warning-bold";
|
11
|
+
readonly ERROR_ICON_NAME: "error-legacy-bold";
|
12
|
+
};
|
13
|
+
declare const DEFAULTS: {
|
14
|
+
readonly HEADER_TAG_NAME: "h2";
|
15
|
+
readonly CANCEL_ICON: "cancel-bold";
|
16
|
+
readonly ARROW_UP_BOLD: "arrow-up-bold";
|
17
|
+
readonly ARROW_DOWN_BOLD: "arrow-down-bold";
|
18
|
+
readonly PREFIX_ICON_SIZE: 1.5;
|
19
|
+
readonly CLOSE_ICON_SIZE: 20;
|
20
|
+
readonly BUTTON: "mdc-button";
|
21
|
+
readonly PRIMARY_BUTTON: "primary";
|
22
|
+
readonly SECONDARY_BUTTON: "secondary";
|
23
|
+
readonly TERTIARY_BUTTON: "tertiary";
|
24
|
+
readonly VARIANT: "custom";
|
25
|
+
};
|
26
|
+
export { TAG_NAME, TOAST_VARIANT, VARIANT_ICON_NAMES, DEFAULTS };
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import utils from '../../utils/tag-name';
|
2
|
+
import { BUTTON_VARIANTS, ICON_BUTTON_SIZES, TAG_NAME as BUTTON_TAGNAME } from '../button/button.constants';
|
3
|
+
const TAG_NAME = utils.constructTagName('toast');
|
4
|
+
const TOAST_VARIANT = {
|
5
|
+
CUSTOM: 'custom',
|
6
|
+
SUCCESS: 'success',
|
7
|
+
WARNING: 'warning',
|
8
|
+
ERROR: 'error',
|
9
|
+
};
|
10
|
+
const VARIANT_ICON_NAMES = {
|
11
|
+
SUCCESS_ICON_NAME: 'check-circle-bold',
|
12
|
+
WARNING_ICON_NAME: 'warning-bold',
|
13
|
+
ERROR_ICON_NAME: 'error-legacy-bold',
|
14
|
+
};
|
15
|
+
const DEFAULTS = {
|
16
|
+
HEADER_TAG_NAME: 'h2',
|
17
|
+
CANCEL_ICON: 'cancel-bold',
|
18
|
+
ARROW_UP_BOLD: 'arrow-up-bold',
|
19
|
+
ARROW_DOWN_BOLD: 'arrow-down-bold',
|
20
|
+
PREFIX_ICON_SIZE: 1.5,
|
21
|
+
CLOSE_ICON_SIZE: ICON_BUTTON_SIZES[20],
|
22
|
+
BUTTON: BUTTON_TAGNAME,
|
23
|
+
PRIMARY_BUTTON: BUTTON_VARIANTS.PRIMARY,
|
24
|
+
SECONDARY_BUTTON: BUTTON_VARIANTS.SECONDARY,
|
25
|
+
TERTIARY_BUTTON: BUTTON_VARIANTS.TERTIARY,
|
26
|
+
VARIANT: TOAST_VARIANT.CUSTOM,
|
27
|
+
};
|
28
|
+
export { TAG_NAME, TOAST_VARIANT, VARIANT_ICON_NAMES, DEFAULTS };
|
@@ -0,0 +1,88 @@
|
|
1
|
+
import { css } from 'lit';
|
2
|
+
const styles = css `
|
3
|
+
:host {
|
4
|
+
--mdc-toast-background-color: var(--mds-color-theme-background-solid-primary-normal);
|
5
|
+
--mdc-toast-border-color: var(--mds-color-theme-outline-primary-normal);
|
6
|
+
--mdc-toast-header-text-color: var(--mds-color-theme-text-primary-normal);
|
7
|
+
--mdc-toast-icon-color: var(--mdc-toast-header-text-color);
|
8
|
+
--mdc-toast-elevation-3: var(--mds-elevation-3);
|
9
|
+
--mdc-toast-width: 25rem;
|
10
|
+
--mdc-toast-padding: 1rem;
|
11
|
+
|
12
|
+
display: block;
|
13
|
+
width: var(--mdc-toast-width);
|
14
|
+
max-width: 100%;
|
15
|
+
padding: var(--mdc-toast-padding);
|
16
|
+
background-color: var(--mdc-toast-background-color);
|
17
|
+
border: 0.0625rem solid var(--mdc-toast-border-color);
|
18
|
+
border-radius: 0.5rem;
|
19
|
+
filter: var(--mdc-toast-elevation-3);
|
20
|
+
}
|
21
|
+
|
22
|
+
:host::part(toast-prefix-icon) {
|
23
|
+
color: var(--mdc-toast-icon-color);
|
24
|
+
}
|
25
|
+
|
26
|
+
:host([variant='success'])::part(toast-prefix-icon) {
|
27
|
+
--mdc-toast-icon-color: var(--mds-color-theme-text-success-normal);
|
28
|
+
}
|
29
|
+
|
30
|
+
:host([variant='warning'])::part(toast-prefix-icon) {
|
31
|
+
--mdc-toast-icon-color: var(--mds-color-theme-text-warning-normal);
|
32
|
+
}
|
33
|
+
|
34
|
+
:host([variant='error'])::part(toast-prefix-icon) {
|
35
|
+
--mdc-toast-icon-color: var(--mds-color-theme-text-error-normal);
|
36
|
+
}
|
37
|
+
|
38
|
+
:host::part(content-container) {
|
39
|
+
display: flex;
|
40
|
+
align-items: flex-start;
|
41
|
+
gap: 0.75rem;
|
42
|
+
align-self: stretch;
|
43
|
+
}
|
44
|
+
|
45
|
+
:host::part(toast-content) {
|
46
|
+
display: flex;
|
47
|
+
flex-direction: column;
|
48
|
+
justify-content: center;
|
49
|
+
align-items: flex-start;
|
50
|
+
gap: 0.25rem;
|
51
|
+
flex: 1 0 0;
|
52
|
+
align-self: stretch;
|
53
|
+
}
|
54
|
+
|
55
|
+
:host::part(toast-header) {
|
56
|
+
display: -webkit-box;
|
57
|
+
-webkit-box-orient: vertical;
|
58
|
+
-webkit-line-clamp: 2;
|
59
|
+
align-self: stretch;
|
60
|
+
overflow: hidden;
|
61
|
+
text-overflow: ellipsis;
|
62
|
+
color: var(--mdc-toast-header-text-color);
|
63
|
+
font-weight: 500;
|
64
|
+
font-size: var(--mds-font-size-body-large);
|
65
|
+
line-height: var(--mds-font-lineheight-body-large);
|
66
|
+
}
|
67
|
+
|
68
|
+
:host::part(footer) {
|
69
|
+
display: flex;
|
70
|
+
justify-content: flex-end;
|
71
|
+
align-items: center;
|
72
|
+
gap: 0.75rem;
|
73
|
+
align-self: stretch;
|
74
|
+
}
|
75
|
+
|
76
|
+
.has-footer-buttons {
|
77
|
+
margin-top: 1rem;
|
78
|
+
}
|
79
|
+
|
80
|
+
:host::part(footer-button-toggle) {
|
81
|
+
text-decoration: none;
|
82
|
+
}
|
83
|
+
|
84
|
+
mdc-text::part(text) {
|
85
|
+
margin: 0;
|
86
|
+
}
|
87
|
+
`;
|
88
|
+
export default [styles];
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { TOAST_VARIANT, VARIANT_ICON_NAMES } from './toast.constants';
|
2
|
+
const getIconNameForVariant = (variant) => {
|
3
|
+
switch (variant) {
|
4
|
+
case TOAST_VARIANT.SUCCESS:
|
5
|
+
return VARIANT_ICON_NAMES.SUCCESS_ICON_NAME;
|
6
|
+
case TOAST_VARIANT.WARNING:
|
7
|
+
return VARIANT_ICON_NAMES.WARNING_ICON_NAME;
|
8
|
+
case TOAST_VARIANT.ERROR:
|
9
|
+
return VARIANT_ICON_NAMES.ERROR_ICON_NAME;
|
10
|
+
default:
|
11
|
+
return null;
|
12
|
+
}
|
13
|
+
};
|
14
|
+
export { getIconNameForVariant };
|