Header.jsx 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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/core/styles/withStyles';
  19. import AppBar from '@material-ui/core/AppBar';
  20. import Toolbar from '@material-ui/core/Toolbar';
  21. import IconButton from '@material-ui/core/IconButton';
  22. import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
  23. import {faBars} from '@fortawesome/free-solid-svg-icons';
  24. import Typography from '@material-ui/core/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. <FontAwesomeIcon icon={faBars} />
  63. </IconButton>
  64. <Typography type='title' color='inherit' noWrap className={classes.title}>
  65. Go Ethereum Dashboard
  66. </Typography>
  67. </Toolbar>
  68. </AppBar>
  69. );
  70. }
  71. }
  72. export default withStyles(themeStyles)(Header);