import Link from "next/link"; import React, { ElementType } from "react"; import { useBackgroundColor } from "../BackgroundColor"; import { Chevron } from "../icons/Chevron"; import classes from "./index.module.scss"; export type Props = { label?: string; appearance?: "default" | "primary" | "secondary"; el?: "button" | "link" | "a"; onClick?: () => void; href?: string; newTab?: boolean; className?: string; }; export const Button: React.FC = ({ el = "button", label, newTab, href, appearance, className: classNameFromProps, }) => { const backgroundColor = useBackgroundColor(); const newTabProps = newTab ? { target: "_blank", rel: "noopener noreferrer" } : {}; const className = [ classNameFromProps, classes[`appearance--${appearance}`], classes[`${appearance}--${backgroundColor}`], classes.button, ] .filter(Boolean) .join(" "); const content = (
{label}
); if (el === "link") { return ( {content} ); } const Element: ElementType = el; return ( {content} ); };