fix: resolve TypeScript errors in migrated components
This commit is contained in:
26
apps/web/src/components/ui/button.tsx
Normal file
26
apps/web/src/components/ui/button.tsx
Normal file
@@ -0,0 +1,26 @@
|
||||
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 = "primary" | "secondary" | "danger" | "ghost" | "outline" | "destructive" | "link";
|
||||
|
||||
export interface ButtonProps extends Omit<BaseButtonProps, "variant"> {
|
||||
variant?: ExtendedVariant;
|
||||
size?: "sm" | "md" | "lg" | "icon";
|
||||
children: ReactNode;
|
||||
}
|
||||
|
||||
// Map extended variants to base variants
|
||||
const variantMap: Record<string, "primary" | "secondary" | "danger" | "ghost"> = {
|
||||
"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} />;
|
||||
}
|
||||
Reference in New Issue
Block a user