hezarfen_frontend
Clone
https://git.tahinli.com/archive/hezarfen_frontend.git
0 watching0 forksTypeScript5.5 MiBc35a83aBurak Boduroğlu4 months ago440 commits
| 1 | import { Button as ButtonPrimitive } from "@kobalte/core/button"; |
| 2 | import { cva, type VariantProps } from "class-variance-authority"; |
| 3 | import { type ComponentProps, type ValidComponent, splitProps } from "solid-js"; |
| 4 | import { cn } from "@/lib/cn"; |
| 5 | |
| 6 | export const buttonVariants = cva( |
| 7 | "inline-flex cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-semibold transition-all focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring/75 focus-visible:ring-offset-1 focus-visible:ring-offset-background active:scale-[0.98] disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50", |
| 8 | { |
| 9 | variants: { |
| 10 | variant: { |
| 11 | // Flat (no shadows), neutral fills, subtle hairline outlines. |
| 12 | default: "bg-primary text-primary-foreground hover:bg-primary/90", |
| 13 | destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90", |
| 14 | outline: |
| 15 | "border border-border/70 bg-transparent hover:border-border hover:bg-muted/60 hover:text-foreground", |
| 16 | secondary: "border border-border/60 bg-secondary text-secondary-foreground hover:bg-secondary/80", |
| 17 | ghost: "text-foreground/75 hover:bg-accent hover:text-accent-foreground focus-visible:bg-accent", |
| 18 | link: "text-primary underline-offset-4 hover:underline active:scale-100", |
| 19 | }, |
| 20 | size: { |
| 21 | default: "h-9 px-4 py-2", |
| 22 | sm: "h-8 rounded-md px-3 text-xs", |
| 23 | lg: "h-10 rounded-md px-8", |
| 24 | icon: "h-9 w-9", |
| 25 | }, |
| 26 | }, |
| 27 | defaultVariants: { |
| 28 | variant: "default", |
| 29 | size: "default", |
| 30 | }, |
| 31 | }, |
| 32 | ); |
| 33 | |
| 34 | export type ButtonProps<T extends ValidComponent = "button"> = ComponentProps< |
| 35 | typeof ButtonPrimitive<T> |
| 36 | > & |
| 37 | VariantProps<typeof buttonVariants>; |
| 38 | |
| 39 | export function Button<T extends ValidComponent = "button">(props: ButtonProps<T>) { |
| 40 | const [local, rest] = splitProps(props as ButtonProps, ["class", "variant", "size"]); |
| 41 | return ( |
| 42 | <ButtonPrimitive |
| 43 | class={cn(buttonVariants({ variant: local.variant, size: local.size }), local.class)} |
| 44 | {...rest} |
| 45 | /> |
| 46 | ); |
| 47 | } |