1 | import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
2 | import _extends from "@babel/runtime/helpers/esm/extends";
|
3 | import * as React from 'react';
|
4 | import PropTypes from 'prop-types';
|
5 | import clsx from 'clsx';
|
6 | import withStyles from '../styles/withStyles';
|
7 | import Paper from '../Paper';
|
8 | import { emphasize } from '../styles/colorManipulator';
|
9 | export const styles = theme => {
|
10 | const emphasis = theme.palette.type === 'light' ? 0.8 : 0.98;
|
11 | const backgroundColor = emphasize(theme.palette.background.default, emphasis);
|
12 | return {
|
13 |
|
14 | root: _extends({}, theme.typography.body2, {
|
15 | color: theme.palette.getContrastText(backgroundColor),
|
16 | backgroundColor,
|
17 | display: 'flex',
|
18 | alignItems: 'center',
|
19 | flexWrap: 'wrap',
|
20 | padding: '6px 16px',
|
21 | borderRadius: theme.shape.borderRadius,
|
22 | flexGrow: 1,
|
23 | [theme.breakpoints.up('sm')]: {
|
24 | flexGrow: 'initial',
|
25 | minWidth: 288
|
26 | }
|
27 | }),
|
28 |
|
29 |
|
30 | message: {
|
31 | padding: '8px 0'
|
32 | },
|
33 |
|
34 |
|
35 | action: {
|
36 | display: 'flex',
|
37 | alignItems: 'center',
|
38 | marginLeft: 'auto',
|
39 | paddingLeft: 16,
|
40 | marginRight: -8
|
41 | }
|
42 | };
|
43 | };
|
44 | const SnackbarContent = React.forwardRef(function SnackbarContent(props, ref) {
|
45 | const {
|
46 | action,
|
47 | classes,
|
48 | className,
|
49 | message,
|
50 | role = 'alert'
|
51 | } = props,
|
52 | other = _objectWithoutPropertiesLoose(props, ["action", "classes", "className", "message", "role"]);
|
53 |
|
54 | return React.createElement(Paper, _extends({
|
55 | role: role,
|
56 | square: true,
|
57 | elevation: 6,
|
58 | className: clsx(classes.root, className),
|
59 | ref: ref
|
60 | }, other), React.createElement("div", {
|
61 | className: classes.message
|
62 | }, message), action ? React.createElement("div", {
|
63 | className: classes.action
|
64 | }, action) : null);
|
65 | });
|
66 | process.env.NODE_ENV !== "production" ? SnackbarContent.propTypes = {
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 | |
73 |
|
74 |
|
75 | action: PropTypes.node,
|
76 |
|
77 | |
78 |
|
79 |
|
80 |
|
81 | classes: PropTypes.object,
|
82 |
|
83 | |
84 |
|
85 |
|
86 | className: PropTypes.string,
|
87 |
|
88 | |
89 |
|
90 |
|
91 | message: PropTypes.node,
|
92 |
|
93 | |
94 |
|
95 |
|
96 | role: PropTypes.string
|
97 | } : void 0;
|
98 | export default withStyles(styles, {
|
99 | name: 'MuiSnackbarContent'
|
100 | })(SnackbarContent); |
\ | No newline at end of file |