github.com/rymuff/go-ethereum@v1.9.7/dashboard/assets/components/ChartRow.jsx (about)

     1  // @flow
     2  
     3  // Copyright 2018 The go-ethereum Authors
     4  // This file is part of the go-ethereum library.
     5  //
     6  // The go-ethereum library is free software: you can redistribute it and/or modify
     7  // it under the terms of the GNU Lesser General Public License as published by
     8  // the Free Software Foundation, either version 3 of the License, or
     9  // (at your option) any later version.
    10  //
    11  // The go-ethereum library is distributed in the hope that it will be useful,
    12  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    13  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    14  // GNU Lesser General Public License for more details.
    15  //
    16  // You should have received a copy of the GNU Lesser General Public License
    17  // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
    18  
    19  import React, {Component} from 'react';
    20  import type {ChildrenArray} from 'react';
    21  
    22  import Grid from '@material-ui/core/Grid';
    23  
    24  // styles contains the constant styles of the component.
    25  const styles = {
    26  	container: {
    27  		flexWrap: 'nowrap',
    28  		height:   '100%',
    29  		maxWidth: '100%',
    30  		margin:   0,
    31  	},
    32  	item: {
    33  		flex:    1,
    34  		padding: 0,
    35  	},
    36  };
    37  
    38  export type Props = {
    39  	children: ChildrenArray<React$Element<any>>,
    40  };
    41  
    42  // ChartRow renders a row of equally sized responsive charts.
    43  class ChartRow extends Component<Props> {
    44  	render() {
    45  		return (
    46  			<Grid container direction='row' style={styles.container} justify='space-between'>
    47  				{React.Children.map(this.props.children, child => (
    48  					<Grid item xs style={styles.item}>
    49  						{child}
    50  					</Grid>
    51  				))}
    52  			</Grid>
    53  		);
    54  	}
    55  }
    56  
    57  export default ChartRow;