button fix

This commit is contained in:
Jun-te Kim 2026-01-19 13:43:58 +00:00
parent fe81ac9af1
commit 1f8c6e0c5b

View file

@ -2,6 +2,7 @@
import { ReactNode, forwardRef } from "react";
import clsx from "clsx";
import type { ComponentPropsWithoutRef } from "react";
const baseStyles = {
solid:
@ -39,27 +40,23 @@ const variantStyles: VariantStylesType = {
};
type ButtonInput = {
variant: "solid" | "outline";
variant?: "solid" | "outline";
color: "cyan" | "white" | "gray";
href: string;
} & JSX.IntrinsicElements["button"];
href?: string;
} & ComponentPropsWithoutRef<"button">;
interface Props {
children?: ReactNode;
}
export type Ref = HTMLButtonElement;
// write me a forwardRef to use the Button component
const Button = forwardRef<Ref, ButtonInput>(
({ variant = "solid", color, className, href, ...props }, ref) => {
className = clsx(
({ variant = "solid", color, className, ...props }, ref) => {
const classes = clsx(
baseStyles[variant],
variantStyles[variant][color],
className
className,
);
return <button ref={ref} className={className} {...props} />;
}
return <button ref={ref} className={classes} {...props} />;
},
);
Button.displayName = "Button";