import { Component } from 'react'; import cx from 'classnames'; import ConfigContext from './ConfigContext'; import LayoutBreakpointContext from './BreakPointContext'; import { getValueForBreakpoint } from './screen-breakpoints'; export interface ILayoutRowProps { className?: string; justify?: | 'start' | 'center' | 'end' | 'space-around' | 'space-between' | 'space-evenly'; align?: 'start' | 'center' | 'end'; style?: React.CSSProperties; } export class LayoutRow extends Component { static defaultProps = { justify: 'start', align: 'start', }; render() { const { className, style, justify, align, ...others } = this.props; const classes = cx( { 'zent-row': true, }, `zent-row-justify-${justify}`, `zent-row-align-${align}`, className ); return ( {breakpoints => ( {config => { const colGutter = getValueForBreakpoint( breakpoints, config.colGutter ); const rowGutter = getValueForBreakpoint( breakpoints, config.rowGutter ); let rowStyles = style; if (colGutter > 0) { const width = -(colGutter / 2); rowStyles = { ...rowStyles, marginLeft: width, marginRight: width, }; } if (rowGutter && rowGutter > 0) { const height = rowGutter / 2; rowStyles = { ...rowStyles, paddingTop: height, paddingBottom: height, }; } return (
{this.props.children}
); }}
)}
); } } export default LayoutRow;