All files / ts/components/forms button.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 21x 28x 7x                               7x           20x   20x  
import * as classNames from 'classnames';
import * as React from 'react';
import { HTMLProps, PureComponent } from 'react';
import { ComponentProps } from '../../types';
 
export interface ButtonProps extends ComponentProps, HTMLProps<HTMLElement> {
  /**
   * Set the style `display: block;`.
   */
  block?: boolean;
  /**
   * Make the button large
   */
  large?: boolean;
  /**
   * Make the button small
   */
  small?: boolean;
}
 
/**
 * Used in place of a standard `button` tag, this component adds additional styles and effects.
 */
export class Button extends PureComponent<ButtonProps, {}> {
  public render () {
    const {
      children,
      className,
      block,
      large,
      small,
      component: Component = 'button',
      ...remainingProps
    } = this.props;
 
    const myClassNames = [
      'button',
      block ? 'block' : null,
      small ? 'small' : null,
      large ? 'large' : null,
      className
    ];
 
    return (
      <Component {...remainingProps} className={classNames(myClassNames)}>
        {children}
      </Component>
    );
  }
}
 
export default Button;