All files / ts/components/misc spaced-group.tsx

100% Statements 19/19
100% Branches 8/8
100% Functions 2/2
100% Lines 17/17

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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 5532x 32x 32x                                             32x 32x 6x 6x 6x 6x 6x 6x 12x 6x     6x               6x           32x   32x  
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;