# All files / lib/grid row.tsx

100% Statements 15/15
100% Branches 6/6
100% Functions 3/3
100% Lines 14/14

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    2x
    2x
    2x

    2x
    4x
    4x
    4x

    4x

    4x
    4x
    4x
    4x

    2x

    2ximport {CSSProperties, FunctionComponent, ReactElement} from "react";
    import * as React from "react";
    import Col from './col';
    import './index.scss';

    interface IProps {
      gutter?: number,
      className?: string,
      style?: CSSProperties
    }

    const Row: FunctionComponent<IProps> = (props) => {
      const children = React.Children.map(props.children, (child) => {
        const element = child as ReactElement<any>;
        return element.type === Col && React.cloneElement(element, {
          gutter: props.gutter
        });
      }).filter(i => i);

      const marginLeft = props.gutter ? `${-props.gutter / 2}px` : undefined;
      const marginRight = props.gutter ? `${-props.gutter / 2}px` : undefined;
      const {className, style} = props;
      return (
        <div className={`w-row ${className}`} style={{ marginLeft, marginRight, ...style }}>{children}</div>
      );
    };

    Row.defaultProps = {
      gutter: 0
    };

    export default Row;