All files / src/utils comparisonMode.tsx

100% Statements 23/23
100% Branches 7/7
100% Functions 1/1
100% Lines 23/23

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 461x               1x               1x 6x   6x 6x 6x 2x   4x   6x 6x 2x   4x   6x 6x 2x   4x 4x 4x 4x   6x   6x 6x  
import {
  CookingIcon,
  DislikedIcon,
  FoodCoverIcon,
  LikedIcon,
  SelectedDislikeIcon,
  SelectedLikeIcon,
} from '@/components/icons/reacts';
import { ChartKey } from '@/types';
 
/**
 * Returns the correct icon component based on current selection.
 *
 * @param selected - Current selected ChartKey
 * @param key - ChartKey for this button
 */
export const getComparisonIcon = (selected: ChartKey, key: ChartKey) => {
  const defaultIconProps = { width: 22.5, height: 22.5 };
 
  const iconMap = {
    [ChartKey.SLOT]:
      selected === ChartKey.SLOT ? (
        <FoodCoverIcon className="text-secondary-150 w-6" />
      ) : (
        <CookingIcon {...defaultIconProps} className="text-primary-550" />
      ),
    [ChartKey.LIKE]:
      selected === ChartKey.LIKE ? (
        <LikedIcon className="text-primary-350 w-[22px]" />
      ) : (
        <SelectedLikeIcon {...defaultIconProps} className="text-primary-550" />
      ),
    [ChartKey.DISLIKE]:
      selected === ChartKey.DISLIKE ? (
        <DislikedIcon className="text-primary-550 w-[23px]" />
      ) : (
        <SelectedDislikeIcon
          {...defaultIconProps}
          className="text-primary-550"
        />
      ),
  };
 
  return iconMap[key];
};