All files / ts/components/tables table-cell.tsx

100% Statements 15/15
100% Branches 4/4
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 3820x 20x 20x 20x   20x               20x 20x 27x 27x 9x             9x                   20x   20x  
import * as classNames from 'classnames';
import * as React from 'react';
import { HTMLProps, PureComponent } from 'react';
import { NBSP } from '../../constants';
import { BaseTableCellProps } from '../../types';
import { shouldNotBeRendered } from '../../utils';
 
export type TableCellProps = BaseTableCellProps & HTMLProps<HTMLElement>;
 
/**
 * Table cell component with additional styles & functionality, used within table rows.
 * See the [Table](#table) section for a full example.
 */
export class TableCell extends PureComponent<TableCellProps, {}> {
  public render () {
    const {
      className,
      children,
      style,
      width,
      component: Component = 'td',
      ...remainingProps
    } = this.props;
 
    return (
      <Component
        {...remainingProps}
        className={classNames('table-cell', className)}
        style={{width, maxWidth: width, minWidth: width, ...style}}
      >
        {shouldNotBeRendered(children) ? NBSP : children}
      </Component>
    );
  }
}
 
export default TableCell;