github.com/sberex/go-sberex@v1.8.2-0.20181113200658-ed96ac38f7d7/dashboard/assets/components/ChartRow.jsx (about)

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