aboutsummaryrefslogtreecommitdiff
path: root/FrontEnd/src/components/Icon.tsx
blob: 2ac3a7ca3da4dc611c458162f7875cb9e4c26ed2 (plain)
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
import { ComponentPropsWithoutRef } from "react";
import classNames from "classnames";

import { ThemeColor } from "./common";

import "./Icon.css";

interface IconButtonProps extends ComponentPropsWithoutRef<"i"> {
  icon: string;
  color?: ThemeColor | "on-surface";
  size?: string | number;
}

export default function Icon(props: IconButtonProps) {
  const { icon, color, size, style, className, ...otherProps } = props;

  const colorName = color === "on-surface" ? "surface-on" : color;

  return (
    <i
      style={size != null ? { ...style, fontSize: size } : style}
      className={classNames(
        colorName && `cru-${colorName}`,
        `bi-${icon} cru-icon`,
        className,
      )}
      {...otherProps}
    />
  );
}