All files / ts/components spaced-group.tsx

100% Statements 13/13
100% Branches 8/8
100% Functions 2/2
100% Lines 11/11
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 42 43 44 45 46 47 48 49 50 51 52 5320x 20x 20x                                         20x 20x 18x 24x 6x                               6x           20x   20x  
import * as classNames from 'classnames';
import * as React from 'react';
import { HTMLProps, PureComponent } from 'react';
import { ComponentProps } from '../types';
 
export interface SpacedGroupProps extends ComponentProps, HTMLProps<HTMLElement> {
  /**
   * Set the group to `display: block;` so it fills its parent.
   */
  block?: boolean;
  /**
   * Reduced spacing between items.
   */
  small?: boolean;
  /**
   * Increased spacing between items.
   */
  large?: boolean;
}
 
/**
 * Component to contain & automatically add space between inline elements.
 */
export class SpacedGroup extends PureComponent<SpacedGroupProps, {}> {
  public render () {
    const {
      children,
      className,
      block,
      small,
      large,
      component: Component = 'span',
      ...remainingProps
    } = this.props;
 
    const myClassNames = [
      'spaced-group',
      block ? 'block' : null,
      small ? 'small' : null,
      large ? 'large' : null,
      className
    ]
 
    return (
      <Component {...remainingProps} className={classNames(myClassNames)}>
        {children}
      </Component>
    );
  }
}
 
export default SpacedGroup;