-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAlert.js
More file actions
42 lines (41 loc) · 1.69 KB
/
Alert.js
File metadata and controls
42 lines (41 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const react_1 = __importDefault(require("react"));
const styles_1 = require("@mui/material/styles");
const Text_1 = __importDefault(require("../elements/Text"));
const StyledAlert = (0, styles_1.styled)('article')(({ theme, variant = 'primary', maxWidth }) => ({
backgroundColor: theme.components.alert[variant].background,
maxWidth: maxWidth !== null && maxWidth !== void 0 ? maxWidth : 'unset',
borderTop: `1px solid ${theme.components.alert[variant].border}`,
width: '100%',
boxSizing: 'border-box',
padding: 8,
wordBreak: 'break-word',
}));
const AlertTitle = (0, styles_1.styled)('h5')({
marginBottom: 10,
});
function Alert({ variant = 'primary', title, message, id = undefined, className = undefined, children, maxWidth, }) {
const msgComponent = typeof message === 'string' ? react_1.default.createElement(Text_1.default, { variant: "body2" }, message) : message;
return (react_1.default.createElement(StyledAlert, { id: id, className: className, variant: variant, maxWidth: maxWidth },
title && react_1.default.createElement(AlertTitle, null, title),
msgComponent,
children));
}
exports.default = Alert;
/*
@todo check with design if we want to use icons in the alert
export const variantIcon = {
success: 'check-circle',
warning: 'exclamation-circle',
error: 'exclamation-circle',
info: 'info-circle',
}
<FontAwesomeIcon className={classes.icon}>
{variantIcon[variant]}
</FontAwesomeIcon>
*/
//# sourceMappingURL=Alert.js.map