From c0fd8671e4630220ca8507815237ef92db2aa75b Mon Sep 17 00:00:00 2001 From: shafi54 <108669266+shafi-aviz@users.noreply.github.com> Date: Sat, 23 May 2026 14:47:12 +0530 Subject: [PATCH] common components --- apps/pharmanager/package.json | 1 + apps/pharmanager/src/components/ui/Button.tsx | 53 +++++++++++++++++++ apps/pharmanager/src/components/ui/Input.tsx | 39 ++++++++++++++ .../src/components/ui/Textarea.tsx | 36 +++++++++++++ apps/pharmanager/src/components/ui/index.ts | 3 ++ .../src/routes/distributors/$id.tsx | 18 +++---- .../src/routes/distributors/add.tsx | 23 ++++---- .../src/routes/distributors/index.tsx | 19 +++---- apps/pharmanager/src/routes/storage/$id.tsx | 18 +++---- apps/pharmanager/src/routes/storage/add.tsx | 52 +++++++++--------- apps/pharmanager/src/routes/storage/index.tsx | 19 +++---- 11 files changed, 203 insertions(+), 78 deletions(-) create mode 100644 apps/pharmanager/src/components/ui/Button.tsx create mode 100644 apps/pharmanager/src/components/ui/Input.tsx create mode 100644 apps/pharmanager/src/components/ui/Textarea.tsx create mode 100644 apps/pharmanager/src/components/ui/index.ts diff --git a/apps/pharmanager/package.json b/apps/pharmanager/package.json index 83f021e..fb2cd02 100644 --- a/apps/pharmanager/package.json +++ b/apps/pharmanager/package.json @@ -22,6 +22,7 @@ "@tanstack/react-router-devtools": "latest", "@tanstack/react-table": "^8.21.3", "@tanstack/router-plugin": "^1.132.0", + "class-variance-authority": "^0.7.1", "lucide-react": "^0.545.0", "react": "19.1.0", "react-dom": "19.1.0", diff --git a/apps/pharmanager/src/components/ui/Button.tsx b/apps/pharmanager/src/components/ui/Button.tsx new file mode 100644 index 0000000..1477ad7 --- /dev/null +++ b/apps/pharmanager/src/components/ui/Button.tsx @@ -0,0 +1,53 @@ +import { forwardRef, type ComponentPropsWithoutRef } from "react"; +import { cva, type VariantProps } from "class-variance-authority"; +import { cn } from "#/lib/cn"; + +export const buttonVariants = cva( + "inline-flex items-center justify-center gap-1.5 rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 disabled:opacity-50 disabled:pointer-events-none", + { + variants: { + variant: { + primary: "bg-blue-600 text-white hover:bg-blue-700", + danger: "bg-red-600 text-white hover:bg-red-700", + outline: + "border border-slate-200 bg-white text-slate-700 hover:bg-slate-50", + ghost: "text-slate-500 hover:bg-slate-100 hover:text-slate-900", + "ghost-blue": + "text-slate-500 hover:text-blue-600 hover:bg-blue-50", + "ghost-red": + "text-slate-500 hover:text-red-600 hover:bg-red-50", + "ghost-dark": + "text-slate-400 hover:bg-slate-800 hover:text-white", + }, + size: { + default: "px-4 py-2", + sm: "px-3 py-1.5 text-xs", + lg: "px-6 py-2.5", + icon: "w-8 h-8 p-0", + "icon-sm": "w-4 h-4 p-0 rounded-full", + }, + }, + defaultVariants: { + variant: "primary", + size: "default", + }, + }, +); + +export interface ButtonProps + extends ComponentPropsWithoutRef<"button">, + VariantProps {} + +export const Button = forwardRef( + ({ className, variant, size, ...props }, ref) => { + return ( +