ksylvest/tights

View on GitHub
src/input.tsx

Summary

Maintainability
B
4 hrs
Test Coverage
A
100%
import { clsx } from "clsx";
import type { ComponentProps, FC } from "react";

import type { Color } from "./types/color";
import type { Size } from "./types/size";

type Props = {
  color?: Color;
  size?: Size;
  rounded?: boolean;
};

export const Input: FC<Omit<ComponentProps<"input">, keyof Props> & Props> = ({
  color,
  size,
  rounded,
  className,
  ...props
}) => (
  <input
    {...props}
    className={clsx(
      "input",
      color && `is-${color}`,
      size && `is-${size}`,
      rounded && "is-rounded",
      className,
    )}
  />
);