mirror of
https://github.com/Hestia-Homes/assessment-model.git
synced 2026-06-30 12:55:02 +00:00
button fix
This commit is contained in:
parent
fe81ac9af1
commit
1f8c6e0c5b
1 changed files with 9 additions and 12 deletions
|
|
@ -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";
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue