# All files / lib/grid col.tsx

100% Statements 12/12
100% Branches 4/4
100% Functions 1/1
100% Lines 10/10

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
    322x

    2x

    2x
    3x
    3x
    3x
    3x

    3x

    2x

    2ximport * as React from "react";
    import {CSSProperties, FunctionComponent} from "react";
    import sc from 'utils/classname';

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

    const Col: FunctionComponent<IProps> = (props) => {
      const {className, style, ...restProps} =  props;
      const offset = props.offset ? `w-col-offset-${props.offset}` : undefined;
      const colClassName = sc('w-col', `w-col-${props.span}`, offset);
      const padding = props.gutter ? `0 ${props.gutter/2}px` : undefined;

      return (
        <div className={colClassName} style={{padding}}>
          <div className={className} style={style} {...restProps}>
            {props.children}
          </div>
        </div>
      );
    };

    Col.defaultProps = {
      span: 24
    };

    export default Col;