nukeop/nuclear

View on GitHub
packages/ui/lib/components/TrackTable/Cells/FavoriteCell.tsx

Summary

Maintainability
A
35 mins
Test Coverage
import React, { TdHTMLAttributes } from 'react';
import cx from 'classnames';
import { CellProps } from 'react-table';

import { TrackTableExtraProps } from '../types';
import { Button } from '../../..';
import { Track } from '../../../types';
import styles from '../styles.scss';

const FavoriteCell: React.FC<CellProps<Track> & TrackTableExtraProps<Track>> = ({
  cell,
  row,
  value,
  onAddToFavorites,
  onRemoveFromFavorites
}) => <td {...cell.getCellProps() as TdHTMLAttributes<HTMLTableCellElement>} className={cx(styles.favorite_cell, styles.narrow)}>
  <Button
    basic
    borderless
    circular
    size='tiny' icon={value ? 'heart' : 'heart outline'}
    onClick={() =>  value ? onRemoveFromFavorites(row.original) : onAddToFavorites(row.original)}
  />
</td>;

export default FavoriteCell;