All files / ts/components/grid container.tsx

100% Statements 15/15
100% Branches 6/6
100% Functions 2/2
100% Lines 13/13
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 33 34 35 36 37 38 39 40 41 4220x 20x 20x                                 20x 20x 15x 15x 5x           5x 5x   5x           20x   20x  
import * as classNames from 'classnames';
import * as React from 'react';
import { HTMLProps, PureComponent } from 'react';
import { ComponentProps } from '../../types';
 
export interface ContainerProps extends ComponentProps, HTMLProps<HTMLElement> {
  /**
   * Fill parent with no media queries to affect width.
   */
  fluid?: boolean;
  /**
   * Allows applying a background color with `@container-background` variable.
   */
  solid?: boolean;
}
 
/**
 * Used inside `NavBar`s or as the main wrapper for an application.
 */
export class Container extends PureComponent<ContainerProps, {}> {
  public render () {
    const {
      children,
      className,
      fluid,
      solid,
      component: Component = 'div',
      ...remainingProps
    } = this.props;
    const fluidClassName = fluid ? 'container-fluid' : 'container';
    const solidClassName = solid && 'solid';
 
    return (
      <Component {...remainingProps} className={classNames(fluidClassName, solidClassName, className)}>
        {children}
      </Component>
    );
  }
}
 
export default Container;