Files
stack/apps/web/src/components/ui/button.tsx
T

28 lines
1.1 KiB
TypeScript

import { Button as BaseButton } from "@mosaic/ui";
import type { ButtonProps as BaseButtonProps } from "@mosaic/ui";
import type { ReactNode, ButtonHTMLAttributes } from "react";
// Extend Button to support additional variants
type ExtendedVariant = "default" | "primary" | "secondary" | "danger" | "ghost" | "outline" | "destructive" | "link";
export interface ButtonProps extends Omit<BaseButtonProps, "variant" | "size"> {
variant?: ExtendedVariant;
size?: "sm" | "md" | "lg" | "icon";
children: ReactNode;
}
// Map extended variants to base variants
const variantMap: Record<string, "primary" | "secondary" | "danger" | "ghost"> = {
"default": "primary",
"outline": "ghost",
"destructive": "danger",
"link": "ghost",
};
export function Button({ variant = "primary", size = "md", ...props }: ButtonProps) {
const mappedVariant = variantMap[variant] || variant;
const mappedSize = size === "icon" ? "sm" : size;
return <BaseButton variant={mappedVariant as "primary" | "secondary" | "danger" | "ghost"} size={mappedSize as "sm" | "md" | "lg"} {...props} />;
}