Header.jsx 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // @flow
  2. // Copyright 2017 The go-ethereum Authors
  3. // This file is part of the go-ethereum library.
  4. //
  5. // The go-ethereum library is free software: you can redistribute it and/or modify
  6. // it under the terms of the GNU Lesser General Public License as published by
  7. // the Free Software Foundation, either version 3 of the License, or
  8. // (at your option) any later version.
  9. //
  10. // The go-ethereum library is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. // GNU Lesser General Public License for more details.
  14. //
  15. // You should have received a copy of the GNU Lesser General Public License
  16. // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
  17. import React, {Component} from 'react';
  18. import withStyles from 'material-ui/styles/withStyles';
  19. import AppBar from 'material-ui/AppBar';
  20. import Toolbar from 'material-ui/Toolbar';
  21. import IconButton from 'material-ui/IconButton';
  22. import Icon from 'material-ui/Icon';
  23. import MenuIcon from 'material-ui-icons/Menu';
  24. import Typography from 'material-ui/Typography';
  25. // styles contains the constant styles of the component.
  26. const styles = {
  27. header: {
  28. height: '8%',
  29. },
  30. toolbar: {
  31. height: '100%',
  32. },
  33. };
  34. // themeStyles returns the styles generated from the theme for the component.
  35. const themeStyles = (theme: Object) => ({
  36. header: {
  37. backgroundColor: theme.palette.grey[900],
  38. color: theme.palette.getContrastText(theme.palette.grey[900]),
  39. zIndex: theme.zIndex.appBar,
  40. },
  41. toolbar: {
  42. paddingLeft: theme.spacing.unit,
  43. paddingRight: theme.spacing.unit,
  44. },
  45. title: {
  46. paddingLeft: theme.spacing.unit,
  47. fontSize: 3 * theme.spacing.unit,
  48. },
  49. });
  50. export type Props = {
  51. classes: Object, // injected by withStyles()
  52. switchSideBar: () => void,
  53. };
  54. // Header renders the header of the dashboard.
  55. class Header extends Component<Props> {
  56. render() {
  57. const {classes} = this.props;
  58. return (
  59. <AppBar position='static' className={classes.header} style={styles.header}>
  60. <Toolbar className={classes.toolbar} style={styles.toolbar}>
  61. <IconButton onClick={this.props.switchSideBar}>
  62. <Icon>
  63. <MenuIcon />
  64. </Icon>
  65. </IconButton>
  66. <Typography type='title' color='inherit' noWrap className={classes.title}>
  67. Go Ethereum Dashboard
  68. </Typography>
  69. </Toolbar>
  70. </AppBar>
  71. );
  72. }
  73. }
  74. export default withStyles(themeStyles)(Header);