eca619b79a
✨ Created complete atoms library (21 components): - Buttons: Button, IconButton with variants (primary, secondary, danger, ghost) - Inputs: TextInput, SearchInput, Textarea with validation support - Typography: Heading (h1-h6), Text (variants), Caption - Badges: Badge (5 variants), PriceBadge (formatted pricing) - Dividers: Horizontal/vertical separators 🎯 Updated existing components to use atoms: - CartProduct: Now uses Button, Text, Caption atoms - ReviewModal: Now uses Button, Textarea, Heading, Text atoms 📚 Added comprehensive documentation: - components/atoms/ATOMS.md: Complete atoms reference guide - Usage examples, theming, import patterns, accessibility 🏗️ Architecture improvements: - Foundation for molecules/organisms - Type-safe components with full TypeScript support - Consistent theming via CSS variables - Barrel exports for clean imports ✅ Verified: - npm run build: Success (✓ Compiled successfully) - npm run format: All files formatted - npm run lint: No new errors in atoms Next: Phase 2 - Create molecules (ProductCard, FormField, SearchBar, etc.) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
51 lines
1.3 KiB
TypeScript
51 lines
1.3 KiB
TypeScript
"use client";
|
|
|
|
import type { ButtonProps } from "./Button.types";
|
|
|
|
export default function Button({
|
|
variant = "primary",
|
|
size = "md",
|
|
icon,
|
|
iconPosition = "left",
|
|
disabled = false,
|
|
children,
|
|
className = "",
|
|
...props
|
|
}: ButtonProps) {
|
|
const baseStyles =
|
|
"font-semibold rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed inline-flex items-center justify-center gap-1.5";
|
|
|
|
const variants = {
|
|
primary:
|
|
"bg-(--color-primary) text-white hover:bg-(--color-primary-dark) active:scale-95",
|
|
secondary:
|
|
"border border-(--color-border) hover:bg-(--color-border-light) active:scale-95",
|
|
danger: "bg-red-500 text-white hover:bg-red-600 active:scale-95",
|
|
ghost: "bg-transparent hover:bg-(--color-border-light) active:scale-95",
|
|
};
|
|
|
|
const sizes = {
|
|
sm: "px-3 py-1.5 text-xs",
|
|
md: "px-4 py-2 text-sm",
|
|
lg: "px-6 py-3 text-base",
|
|
};
|
|
|
|
const iconClasses = "text-sm shrink-0";
|
|
|
|
return (
|
|
<button
|
|
className={`${baseStyles} ${variants[variant]} ${sizes[size]} ${className}`}
|
|
disabled={disabled}
|
|
{...props}
|
|
>
|
|
{icon && iconPosition === "left" && (
|
|
<i className={`fa-solid ${icon} ${iconClasses}`}></i>
|
|
)}
|
|
{children}
|
|
{icon && iconPosition === "right" && (
|
|
<i className={`fa-solid ${icon} ${iconClasses}`}></i>
|
|
)}
|
|
</button>
|
|
);
|
|
}
|