import classNames from "@lib/classNames"; import Link, { LinkProps } from "next/link"; import React from "react"; type HTMLAnchorProps = React.AnchorHTMLAttributes; type HTMLButtonProps = React.ButtonHTMLAttributes; type SVGComponent = React.FunctionComponent>; export type ButtonProps = { color?: "primary" | "secondary" | "minimal"; size?: "base" | "sm" | "lg" | "fab"; loading?: boolean; disabled?: boolean; onClick?: (event: React.MouseEvent) => void; StartIcon?: SVGComponent; EndIcon?: SVGComponent; } & ((Omit & { href: LinkProps["href"] }) | (HTMLButtonProps & { href?: never })); export const Button = function Button(props: ButtonProps) { const { loading = false, color = "primary", size = "base", StartIcon, EndIcon, // attributes propagated from `HTMLAnchorProps` or `HTMLButtonProps` ...passThroughProps } = props; // Buttons are **always** disabled if we're in a `loading` state const disabled = props.disabled || loading; // If pass an `href`-attr is passed it's ``, otherwise it's a `