96 lines
2.4 KiB
JavaScript
96 lines
2.4 KiB
JavaScript
import _extends from 'babel-runtime/helpers/extends';
|
|
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
|
|
// @inheritedComponent Paper
|
|
|
|
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import classNames from 'classnames';
|
|
import withStyles from '../styles/withStyles';
|
|
import Paper from '../Paper';
|
|
import Typography from '../Typography';
|
|
import { emphasize } from '../styles/colorManipulator';
|
|
|
|
export const styles = theme => {
|
|
const emphasis = theme.palette.type === 'light' ? 0.8 : 0.98;
|
|
const backgroundColor = emphasize(theme.palette.background.default, emphasis);
|
|
|
|
return {
|
|
root: {
|
|
pointerEvents: 'initial',
|
|
color: theme.palette.getContrastText(backgroundColor),
|
|
backgroundColor,
|
|
display: 'flex',
|
|
alignItems: 'center',
|
|
flexWrap: 'wrap',
|
|
padding: `6px ${theme.spacing.unit * 3}px`,
|
|
[theme.breakpoints.up('md')]: {
|
|
minWidth: 288,
|
|
maxWidth: 568,
|
|
borderRadius: 2
|
|
},
|
|
[theme.breakpoints.down('sm')]: {
|
|
flexGrow: 1
|
|
}
|
|
},
|
|
message: {
|
|
padding: `${theme.spacing.unit}px 0`
|
|
},
|
|
action: {
|
|
display: 'flex',
|
|
alignItems: 'center',
|
|
marginLeft: 'auto',
|
|
paddingLeft: theme.spacing.unit * 3,
|
|
marginRight: -theme.spacing.unit
|
|
}
|
|
};
|
|
};
|
|
|
|
function SnackbarContent(props) {
|
|
const { action, classes, className, message } = props,
|
|
other = _objectWithoutProperties(props, ['action', 'classes', 'className', 'message']);
|
|
|
|
return React.createElement(
|
|
Paper,
|
|
_extends({
|
|
component: Typography,
|
|
headlineMapping: {
|
|
body1: 'div'
|
|
},
|
|
role: 'alertdialog',
|
|
square: true,
|
|
elevation: 6,
|
|
className: classNames(classes.root, className)
|
|
}, other),
|
|
React.createElement(
|
|
'div',
|
|
{ className: classes.message },
|
|
message
|
|
),
|
|
action ? React.createElement(
|
|
'div',
|
|
{ className: classes.action },
|
|
action
|
|
) : null
|
|
);
|
|
}
|
|
|
|
SnackbarContent.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
/**
|
|
* The action to display.
|
|
*/
|
|
action: PropTypes.node,
|
|
/**
|
|
* Useful to extend the style applied to components.
|
|
*/
|
|
classes: PropTypes.object.isRequired,
|
|
/**
|
|
* @ignore
|
|
*/
|
|
className: PropTypes.string,
|
|
/**
|
|
* The message to display.
|
|
*/
|
|
message: PropTypes.node
|
|
} : {};
|
|
|
|
export default withStyles(styles, { name: 'MuiSnackbarContent' })(SnackbarContent); |