Skip to content

Commit 0d59efb

Browse files
committed
Refactor Button component to define ButtonProps type separately for improved readability
1 parent 883c508 commit 0d59efb

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

frontend/components/ui/button.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,18 @@ const buttonVariants = cva(
3535
}
3636
)
3737

38+
type ButtonProps = React.ComponentProps<"button"> &
39+
VariantProps<typeof buttonVariants> & {
40+
asChild?: boolean
41+
};
42+
3843
function Button({
3944
className,
4045
variant,
4146
size,
4247
asChild = false,
4348
...props
44-
}: React.ComponentProps<"button"> &
45-
VariantProps<typeof buttonVariants> & {
46-
asChild?: boolean
47-
}) {
49+
}: ButtonProps) {
4850
const Comp = asChild ? Slot : "button"
4951

5052
return (
@@ -57,3 +59,4 @@ function Button({
5759
}
5860

5961
export { Button, buttonVariants }
62+
export type { ButtonProps }

0 commit comments

Comments
 (0)