import type { VariantProps } from 'class-variance-authority' import { cn } from '@admin/utils/shared/cn' import { Button as ButtonPrimitive } from '@base-ui/react/button' import { cva } from 'class-variance-authority' // text-box trimming never reaches a bare text node inside a flex container, so buttons without an // svg drop to inline-block (content-center/text-center replace the flex centering). A button that // keeps an icon stays flex, where its label span is blockified as a flex item and trims on its own. // Labels are sentence-cased in source, never by CSS: WebKit ignores a ::first-letter text-transform // under a parent text-transform, so a lowercase + first-letter:uppercase pair renders every label // fully lowercase on iPhone and iPad. // The `svg.lucide` base rule in admin-globals.css paints every icon `--foreground`, which is // invisible on the filled variants, so the class layer hands the icon back to the button's own text // colour; the destructive and warning variants override it again. // `key` is the raised keycap of the phone content-editor toolbars (Paper `Posts / New ยท Writing`): // a white cap on the hairline-and-lift `shadow-sm`, pressed to `bg-secondary` while its mark or // menu is on. const buttonVariants = cva( "group/button inline-flex shrink-0 items-center justify-center rounded border border-transparent bg-clip-padding font-medium whitespace-nowrap text-foreground transition-all outline-none select-none not-has-[svg]:inline-block not-has-[svg]:content-center not-has-[svg]:text-center focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none aria-invalid:border-destructive aria-invalid:ring-[3px] aria-invalid:ring-destructive/20 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg]:text-current [&_svg:not([class*='size-'])]:size-3.5", { variants: { variant: { default: 'bg-primary text-primary-foreground hover:bg-primary/80 disabled:bg-primary/50 disabled:text-primary-foreground/50', outline: 'border-border bg-input hover:border-foreground/10 hover:bg-accent hover:text-foreground disabled:bg-input/50 disabled:text-foreground/50 aria-expanded:bg-muted aria-expanded:text-foreground', secondary: 'bg-accent text-foreground hover:bg-accent disabled:bg-accent/50 disabled:text-foreground/50 aria-expanded:bg-accent aria-expanded:text-foreground', ghost: 'hover:border-border hover:bg-muted hover:text-foreground disabled:text-foreground/50 aria-expanded:bg-muted aria-expanded:text-foreground', destructive: 'bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 disabled:bg-destructive/5 disabled:text-destructive/50 [&_svg]:text-destructive disabled:[&_svg]:text-destructive/50', warning: 'border-warning/20 bg-warning/10 text-warning hover:bg-warning/15 focus-visible:border-warning/40 focus-visible:ring-warning/15 disabled:bg-warning/5 disabled:text-warning/50 [&_svg]:text-warning disabled:[&_svg]:text-warning/50', link: 'text-primary underline-offset-4 hover:underline disabled:text-primary/50', key: 'bg-card shadow-sm hover:bg-accent disabled:bg-card/50 disabled:text-foreground/50 aria-expanded:bg-secondary aria-pressed:bg-secondary data-[active-state=on]:bg-secondary' }, size: { default: 'h-9 gap-1.5 px-3 has-data-[icon=inline-end]:pr-2.5 has-data-[icon=inline-start]:pl-2.5', xs: "h-6 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2 [&_svg:not([class*='size-'])]:size-3.5", sm: 'h-8 gap-1.5 px-3 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2', lg: 'h-10 gap-1.5 px-4 has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3', icon: 'size-9', 'icon-xs': "size-6 [&_svg:not([class*='size-'])]:size-3.5", 'icon-sm': 'size-8', 'icon-lg': 'size-10' } }, defaultVariants: { variant: 'default', size: 'default' } } ) function Button({ className, variant = 'default', size = 'default', ...props }: ButtonPrimitive.Props & VariantProps) { return ( ) } export { Button, buttonVariants }