From dfe9fee56aa850eb69c4d05873b0e3c0a8ca0441 Mon Sep 17 00:00:00 2001 From: Hermann_Kitio Date: Sat, 18 Apr 2026 00:56:13 +0300 Subject: [PATCH] =?UTF-8?q?feat(design-system):=20Button=20+=20Badge=20sha?= =?UTF-8?q?dcn=20remapp=C3=A9s=20tokens=20Direction=20H=20(Sprint=200.5=20?= =?UTF-8?q?=C3=A9tape=204)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components.json | 10 ++--- src/shared/components/ui/badge.tsx | 48 ++++++++++++++++++++++ src/shared/components/ui/button.tsx | 64 +++++++++++++++++++++++++++++ 3 files changed, 117 insertions(+), 5 deletions(-) create mode 100644 src/shared/components/ui/badge.tsx create mode 100644 src/shared/components/ui/button.tsx diff --git a/components.json b/components.json index 18e6574..10d45fb 100644 --- a/components.json +++ b/components.json @@ -11,11 +11,11 @@ "prefix": "" }, "aliases": { - "components": "@/shared/components", - "utils": "@/shared/lib/utils", - "ui": "@/shared/components/ui", - "lib": "@/shared/lib", - "hooks": "@/shared/hooks" + "components": "src/shared/components", + "utils": "src/shared/lib/utils", + "ui": "src/shared/components/ui", + "lib": "src/shared/lib", + "hooks": "src/shared/hooks" }, "iconLibrary": "lucide" } diff --git a/src/shared/components/ui/badge.tsx b/src/shared/components/ui/badge.tsx new file mode 100644 index 0000000..8c12c58 --- /dev/null +++ b/src/shared/components/ui/badge.tsx @@ -0,0 +1,48 @@ +import * as React from "react" +import { cva, type VariantProps } from "class-variance-authority" +import { Slot } from "radix-ui" + +import { cn } from "@/shared/lib/utils" + +const badgeVariants = cva( + "inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:border-expria focus-visible:ring-[3px] focus-visible:ring-expria/30 aria-invalid:border-danger aria-invalid:ring-danger/20 dark:aria-invalid:ring-danger/40 [&>svg]:pointer-events-none [&>svg]:size-3", + { + variants: { + variant: { + default: "bg-expria text-white [a&]:hover:bg-expria/90", + secondary: + "bg-canvas-2 text-ink-1 [a&]:hover:bg-canvas-2/90", + destructive: + "bg-danger text-white focus-visible:ring-danger/20 dark:bg-danger/60 dark:focus-visible:ring-danger/40 [a&]:hover:bg-danger/90", + outline: + "border-line text-ink-2 [a&]:hover:bg-canvas-2 [a&]:hover:text-ink-1", + ghost: "[a&]:hover:bg-canvas-2 [a&]:hover:text-ink-1", + link: "text-expria underline-offset-4 [a&]:hover:underline", + }, + }, + defaultVariants: { + variant: "default", + }, + } +) + +function Badge({ + className, + variant = "default", + asChild = false, + ...props +}: React.ComponentProps<"span"> & + VariantProps & { asChild?: boolean }) { + const Comp = asChild ? Slot.Root : "span" + + return ( + + ) +} + +export { Badge, badgeVariants } diff --git a/src/shared/components/ui/button.tsx b/src/shared/components/ui/button.tsx new file mode 100644 index 0000000..a6f59f9 --- /dev/null +++ b/src/shared/components/ui/button.tsx @@ -0,0 +1,64 @@ +import * as React from "react" +import { cva, type VariantProps } from "class-variance-authority" +import { Slot } from "radix-ui" + +import { cn } from "@/shared/lib/utils" + +const buttonVariants = cva( + "inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:border-expria focus-visible:ring-[3px] focus-visible:ring-expria/30 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-danger aria-invalid:ring-danger/20 dark:aria-invalid:ring-danger/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", + { + variants: { + variant: { + default: "bg-expria text-white hover:bg-expria/90", + destructive: + "bg-danger text-white hover:bg-danger/90 focus-visible:ring-danger/20 dark:bg-danger/60 dark:focus-visible:ring-danger/40", + outline: + "border bg-surface shadow-xs hover:bg-canvas-2 hover:text-ink-1 dark:border-line dark:bg-surface/30 dark:hover:bg-surface/50", + secondary: + "bg-canvas-2 text-ink-1 hover:bg-canvas-2/80", + ghost: + "hover:bg-canvas-2 hover:text-ink-1 dark:hover:bg-canvas-2/50", + link: "text-expria underline-offset-4 hover:underline", + }, + size: { + default: "h-9 px-4 py-2 has-[>svg]:px-3", + xs: "h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3", + sm: "h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5", + lg: "h-10 rounded-md px-6 has-[>svg]:px-4", + icon: "size-9", + "icon-xs": "size-6 rounded-md [&_svg:not([class*='size-'])]:size-3", + "icon-sm": "size-8", + "icon-lg": "size-10", + }, + }, + defaultVariants: { + variant: "default", + size: "default", + }, + } +) + +function Button({ + className, + variant = "default", + size = "default", + asChild = false, + ...props +}: React.ComponentProps<"button"> & + VariantProps & { + asChild?: boolean + }) { + const Comp = asChild ? Slot.Root : "button" + + return ( + + ) +} + +export { Button, buttonVariants }