|
| 1 | +import React, { PureComponent } from 'react'; |
| 2 | +import PropTypes from 'prop-types'; |
| 3 | +import Toolbar from 'material-ui/Toolbar'; |
| 4 | +import Grid from 'material-ui/Grid'; |
| 5 | +import { withStyles } from 'material-ui/styles'; |
| 6 | + |
| 7 | +import styles from './styles'; |
| 8 | + |
| 9 | +class TwoRowsAppBar extends PureComponent { |
| 10 | + static propTypes = { |
| 11 | + classes: PropTypes.shape({}), |
| 12 | + topLeftContent: PropTypes.oneOf(PropTypes.element, PropTypes.arrayOf(PropTypes.element)), |
| 13 | + topCenterContent: PropTypes.oneOf(PropTypes.element, PropTypes.arrayOf(PropTypes.element)), |
| 14 | + topRightContent: PropTypes.oneOf(PropTypes.element, PropTypes.arrayOf(PropTypes.element)), |
| 15 | + bottomLeftContent: PropTypes.oneOf(PropTypes.element, PropTypes.arrayOf(PropTypes.element)), |
| 16 | + bottomCenterContent: PropTypes.oneOf(PropTypes.element, PropTypes.arrayOf(PropTypes.element)), |
| 17 | + bottomRightContent: PropTypes.oneOf(PropTypes.element, PropTypes.arrayOf(PropTypes.element)), |
| 18 | + }; |
| 19 | + |
| 20 | + static defaultProps = { |
| 21 | + classes: {}, |
| 22 | + topLeftContent: null, |
| 23 | + topCenterContent: null, |
| 24 | + topRightContent: null, |
| 25 | + bottomLeftContent: null, |
| 26 | + bottomCenterContent: null, |
| 27 | + bottomRightContent: null, |
| 28 | + } |
| 29 | + |
| 30 | + render() { |
| 31 | + const { |
| 32 | + classes, |
| 33 | + topLeftContent, |
| 34 | + topCenterContent, |
| 35 | + topRightContent, |
| 36 | + bottomLeftContent, |
| 37 | + bottomCenterContent, |
| 38 | + bottomRightContent, |
| 39 | + } = this.props; |
| 40 | + return ( |
| 41 | + <Toolbar> |
| 42 | + <Grid container direction="column" className={classes.wrapper}> |
| 43 | + <Grid container className={classes.topRow} justify={'space-between'}> |
| 44 | + <Grid item xs={2} className={classes.left}> |
| 45 | + {topLeftContent} |
| 46 | + </Grid> |
| 47 | + <Grid item xs={8} className={classes.topCenter}> |
| 48 | + {topCenterContent} |
| 49 | + </Grid> |
| 50 | + <Grid item xs={2} className={classes.right}> |
| 51 | + {topRightContent} |
| 52 | + </Grid> |
| 53 | + </Grid> |
| 54 | + <Grid container className={classes.bottomRow} justify={'space-between'}> |
| 55 | + <Grid item xs={2} className={classes.left}> |
| 56 | + {bottomLeftContent} |
| 57 | + </Grid> |
| 58 | + <Grid item xs={8} className={classes.bottomCenter}> |
| 59 | + {bottomCenterContent} |
| 60 | + </Grid> |
| 61 | + <Grid item xs={2} className={classes.right}> |
| 62 | + {bottomRightContent} |
| 63 | + </Grid> |
| 64 | + </Grid> |
| 65 | + </Grid> |
| 66 | + </Toolbar> |
| 67 | + ); |
| 68 | + } |
| 69 | +} |
| 70 | + |
| 71 | +export default withStyles(styles)(TwoRowsAppBar); |
0 commit comments