import type { HTMLAttributes, ReactNode } from "react";
type ButtonColor =
| "default"
| "custom"
| "primary"
| "secondary"
| "info"
| "success"
| "notice"
| "warning"
| "danger";
type ButtonVariant = "border" | "solid";
type ButtonSize = "2xs" | "xs" | "sm" | "md" | "auto";
export type ButtonProps = Omit<
HTMLAttributes,
"color" | "onChange"
> & {
innerClassName?: string;
color?: ButtonColor;
tone?: Exclude;
variant?: ButtonVariant;
isLoading?: boolean;
size?: ButtonSize;
justify?: "start" | "center";
type?: "button" | "submit";
disabled?: boolean;
title?: string;
leftSlot?: ReactNode;
rightSlot?: ReactNode;
};
function cx(...values: Array) {
return values.filter(Boolean).join(" ");
}
export function Button({
isLoading,
className,
innerClassName,
children,
color,
tone,
type = "button",
justify = "center",
size = "md",
variant = "solid",
leftSlot,
rightSlot,
disabled,
title,
onClick,
...props
}: ButtonProps) {
const resolvedColor = color ?? tone ?? "default";
const isDisabled = disabled || isLoading;
return (
);
}