hezarfen_frontend
Clone
https://git.tahinli.com/archive/hezarfen_frontend.git
0 watching0 forksTypeScript5.5 MiB5fcd955Burak Boduroğlu2 months ago730 commits
| 1 | import { cva, type VariantProps } from "class-variance-authority"; |
| 2 | import type { ComponentProps, ParentProps } from "solid-js"; |
| 3 | import { splitProps } from "solid-js"; |
| 4 | import { cn } from "@/lib/cn"; |
| 5 | |
| 6 | const badgeVariants = cva( |
| 7 | "inline-flex h-5 min-h-5 items-center rounded-full border px-2 text-xs font-semibold leading-none transition-colors focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-1", |
| 8 | { |
| 9 | variants: { |
| 10 | variant: { |
| 11 | default: "border-transparent bg-primary text-primary-foreground shadow-sm", |
| 12 | secondary: "border-transparent bg-secondary text-secondary-foreground", |
| 13 | outline: "border-border text-foreground", |
| 14 | destructive: "border-transparent bg-destructive/90 text-destructive-foreground", |
| 15 | success: "border-transparent bg-success/15 text-success-text", |
| 16 | warning: "border-transparent bg-warning/15 text-warning-text", |
| 17 | info: "border-transparent bg-info/15 text-info-text", |
| 18 | }, |
| 19 | }, |
| 20 | defaultVariants: { |
| 21 | variant: "default", |
| 22 | }, |
| 23 | }, |
| 24 | ); |
| 25 | |
| 26 | export type BadgeProps = ParentProps< |
| 27 | ComponentProps<"div"> & VariantProps<typeof badgeVariants> |
| 28 | >; |
| 29 | |
| 30 | export function Badge(props: BadgeProps) { |
| 31 | const [local, rest] = splitProps(props, ["class", "variant", "children"]); |
| 32 | return ( |
| 33 | <div data-slot="badge" class={cn(badgeVariants({ variant: local.variant }), local.class)} {...rest}> |
| 34 | {local.children} |
| 35 | </div> |
| 36 | ); |
| 37 | } |