All files / ts/components/tabs tab.tsx

100% Statements 13/13
100% Branches 4/4
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 3720x 20x 20x                             20x 20x 18x 12x 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 TabProps extends ComponentProps, HTMLProps<HTMLElement> {
  /**
   * Apply active `Tab` styles.
   */
  active?: boolean;
}
 
/**
 * Tab component for use within the `Tabs` component.
 * Easily style active tabs with the `active` prop.
 * See the [Tabs](#tabs) section for a full example.
 */
export class Tab extends PureComponent<TabProps, {}> {
  public render () {
    const {
      className,
      children,
      active,
      component: Component = 'li',
      ...remainingProps
    } = this.props;
 
    return (
      <Component {...remainingProps} className={classNames('tab', active && 'active', className)}>
        {children}
      </Component>
    );
  }
}
 
export default Tab;