From 7ecead13d8553a96d6388a45672e2e3f7dfd4725 Mon Sep 17 00:00:00 2001 From: rajun Date: Tue, 27 Oct 2026 16:28:47 +0530 Subject: [PATCH] refactor: restyle button with theme variants and sizes --- app/components/ui/button.tsx | 61 ++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 34 deletions(-) diff --git a/app/components/ui/button.tsx b/app/components/ui/button.tsx index 42c61fb..bcef86c 100644 --- a/app/components/ui/button.tsx +++ b/app/components/ui/button.tsx @@ -1,52 +1,45 @@ -import * as React from 'react'; +import type { ComponentProps } from 'react'; import { Slot } from '@radix-ui/react-slot'; import { cva, type VariantProps } from 'class-variance-authority'; import { cn } from '~/lib/utils'; const buttonVariants = cva( - 'inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-xl text-sm font-semibold transition-all duration-200 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-neutral-700 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 active:scale-[0.98] cursor-pointer', + // A busy button (aria-busy) is disabled but keeps full colour while it works + 'inline-flex cursor-pointer items-center justify-center gap-2 whitespace-nowrap text-sm transition-colors duration-150 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 disabled:pointer-events-none disabled:opacity-40 aria-busy:disabled:opacity-100 [&_svg]:pointer-events-none [&_svg]:shrink-0', { variants: { variant: { - default: 'bg-orange-500 text-black shadow-[0_0_24px_rgba(249,115,22,0.15)] hover:bg-orange-400 hover:shadow-[0_0_32px_rgba(249,115,22,0.3)]', - destructive: 'bg-red-500/10 text-red-500 border border-red-500/20 hover:bg-red-500 hover:text-white', - outline: 'border border-neutral-800 bg-[#121212] text-neutral-400 hover:bg-neutral-900 hover:text-white hover:border-orange-500/40', - secondary: 'bg-neutral-800 text-neutral-300 hover:bg-neutral-750 hover:text-white', - ghost: 'hover:bg-neutral-850 hover:text-white text-neutral-400', - link: 'text-orange-500 underline-offset-4 hover:underline', + default: 'bg-primary font-semibold text-primary-foreground shadow-[0_4px_14px] shadow-primary/25 hover:bg-primary-hover aria-busy:bg-accent-600', + success: 'bg-success-strong font-semibold text-primary-foreground shadow-[0_4px_14px] shadow-success-strong/25', + secondary: 'bg-surface-control font-medium text-text-primary ring-1 ring-inset ring-border-control hover:bg-surface-hover', + destructive: 'bg-surface-control font-medium text-danger ring-1 ring-inset ring-border-control hover:bg-surface-hover', + ghost: 'font-medium text-text-subtle hover:bg-surface-hover hover:text-text-primary', + link: 'h-auto px-0 font-medium text-primary hover:text-primary-hover', + 'link-muted': 'text-text-secondary hover:text-primary', }, size: { - default: 'h-10 px-5 py-2.5', - sm: 'h-8 rounded-lg px-3 text-xs', - lg: 'h-12 rounded-xl px-8 text-base', - icon: 'h-9 w-9 rounded-lg', + default: 'h-9 rounded-control px-4', + sm: 'h-8 rounded-item px-3 text-xs', + lg: 'h-11 rounded-control px-6', + xl: 'h-12.5 rounded-field px-6 text-base shadow-[0_10px_28px] inset-shadow-[0_1px_0] inset-shadow-primary-foreground/20', + // Text-only buttons that sit inline with labels + inline: 'h-auto px-0', + icon: 'h-[30px] w-[30px] rounded-item', + 'icon-sm': 'h-[26px] w-[26px] rounded-option', + pill: 'h-[46px] rounded-full px-6 text-base shadow-[0_6px_16px] shadow-shadow/15', }, }, - defaultVariants: { - variant: 'default', - size: 'default', - }, - } + defaultVariants: { variant: 'default', size: 'default' }, + }, ); -export interface ButtonProps - extends React.ButtonHTMLAttributes, - VariantProps { +export interface ButtonProps extends ComponentProps<'button'>, VariantProps { asChild?: boolean; } -const Button = React.forwardRef( - ({ className, variant, size, asChild = false, ...props }, ref) => { - const Comp = asChild ? Slot : 'button'; - return ( - - ); - } -); -Button.displayName = 'Button'; +export function Button({ className, variant, size, asChild = false, ...props }: ButtonProps) { + const Comp = asChild ? Slot : 'button'; + return ; +} -export { Button, buttonVariants }; +export { buttonVariants };