From d8ef95cdfbabd90b7ee81efd05abddc9981c03b4 Mon Sep 17 00:00:00 2001 From: Madison Date: Fri, 10 Oct 2025 13:06:02 -0500 Subject: [PATCH] fix button --- docs/src/components/mdx/button.tsx | 82 +++++++++++++++++------------- 1 file changed, 48 insertions(+), 34 deletions(-) diff --git a/docs/src/components/mdx/button.tsx b/docs/src/components/mdx/button.tsx index 444b4db65..8252b180f 100644 --- a/docs/src/components/mdx/button.tsx +++ b/docs/src/components/mdx/button.tsx @@ -3,54 +3,68 @@ import * as React from "react"; import { cn } from "../../lib/cn"; import { buttonVariants } from "../ui/button"; -type ButtonProps = React.ButtonHTMLAttributes & { +type BaseButtonProps = { color?: 'primary' | 'secondary' | 'outline' | 'ghost', size?: 'sm' | 'icon' | 'icon-sm', icon?: React.ReactNode, - href?: string, children: React.ReactNode, } -export const Button = React.forwardRef( - ({ className, color = 'secondary', size = 'sm', icon, href, children, ...props }, ref) => { - const buttonContent = ( - <> - {icon && {icon}} - {children} - - ); +type ButtonAsButton = BaseButtonProps & + React.ButtonHTMLAttributes & { + href?: never, + }; - const buttonClasses = cn( - buttonVariants({ - color, - size, - className: 'gap-2 no-underline hover:no-underline' - }), - className - ); +type ButtonAsLink = BaseButtonProps & + React.AnchorHTMLAttributes & { + href: string, + }; - if (href) { - return ( - )} - > - {buttonContent} - - ); - } +type ButtonProps = ButtonAsButton | ButtonAsLink; +export const Button = React.forwardRef< + HTMLButtonElement | HTMLAnchorElement, + ButtonProps +>(({ className, color = 'secondary', size = 'sm', icon, href, children, ...props }, ref) => { + const buttonContent = ( + <> + {icon && {icon}} + {children} + + ); + + const buttonClasses = cn( + buttonVariants({ + color, + size, + className: 'gap-2 no-underline hover:no-underline' + }), + className + ); + + if (href) { return ( - + ); } -); + + return ( + + ); +}); Button.displayName = "Button";