import React from "react"; import Link, { LinkProps } from "next/link"; import Icon from "@/components/Icon"; type CommonProps = { className?: string; icon?: string; children?: React.ReactNode; isBlack?: boolean; isWhite?: boolean; isRed?: boolean; isBlue?: boolean; isStroke?: boolean; isCircle?: boolean; }; type ButtonAsButton = { as?: "button"; } & React.ButtonHTMLAttributes; type ButtonAsAnchor = { as: "a"; } & React.AnchorHTMLAttributes; type ButtonAsLink = { as: "link"; } & LinkProps; type ButtonProps = CommonProps & (ButtonAsButton | ButtonAsAnchor | ButtonAsLink); const Button: React.FC = ({ className, icon, children, isBlack, isWhite, isRed, isBlue, isStroke, isCircle, as = "button", ...props }) => { const isLink = as === "link"; const Component: React.ElementType = isLink ? Link : as; return ( {icon && ( )} {children} ); }; export default Button;