ChartRow.jsx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // @flow
  2. // Copyright 2018 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 type {ChildrenArray} from 'react';
  19. import Grid from '@material-ui/core/Grid';
  20. // styles contains the constant styles of the component.
  21. const styles = {
  22. container: {
  23. flexWrap: 'nowrap',
  24. height: '100%',
  25. maxWidth: '100%',
  26. margin: 0,
  27. },
  28. item: {
  29. flex: 1,
  30. padding: 0,
  31. },
  32. };
  33. export type Props = {
  34. children: ChildrenArray<React$Element<any>>,
  35. };
  36. // ChartRow renders a row of equally sized responsive charts.
  37. class ChartRow extends Component<Props> {
  38. render() {
  39. return (
  40. <Grid container direction='row' style={styles.container} justify='space-between'>
  41. {React.Children.map(this.props.children, child => (
  42. <Grid item xs style={styles.item}>
  43. {child}
  44. </Grid>
  45. ))}
  46. </Grid>
  47. );
  48. }
  49. }
  50. export default ChartRow;