Files
pastel-ui/components/color/ColorSwatch.tsx

67 lines
1.8 KiB
TypeScript
Raw Normal View History

feat: implement palette generation features Add complete palette generation system with multiple methods: **New Components:** - ColorSwatch component - Individual color display - Click to copy to clipboard - Hover effects with copy icon - Configurable sizes (sm, md, lg) - Optional color label display - Check icon on successful copy - PaletteGrid component - Grid display for color palettes - Responsive grid layout (3-6 columns) - Click handler for color selection - Empty state message - Flexible and reusable - Select component - Dropdown selector - Consistent styling with other inputs - Optional label support - Keyboard accessible - Focus ring styling **Palette Pages:** 1. Gradient Creator (/palettes/gradient) - Multiple color stop editor (add/remove) - Configurable step count (2-1000) - Color space selection (RGB, HSL, Lab, LCH, OkLab, OkLCH) - Live gradient preview bar - Full palette grid display - Interactive color pickers for each stop - Real-time generation 2. Distinct Colors (/palettes/distinct) - Count selector (2-100 colors) - Distance metric selection (CIE76, CIEDE2000) - Simulated annealing algorithm - Statistics display: - Minimum distance - Average distance - Generation time - Loading state with progress message - Quality metrics for generated palette 3. Palettes Dashboard (/palettes) - Overview of all palette generators - Feature cards with icons - "Coming Soon" badge for harmony palettes - Quick navigation to each generator - Feature highlights for each method **Features:** - All palette generators integrated with Pastel API - Toast notifications for success/error - Loading states during generation - Copy colors to clipboard - Responsive layouts - Empty states - Error handling **API Integration:** - useGenerateGradient mutation - useGenerateDistinct mutation - Proper error handling and loading states - Result caching with React Query Build successful! 3 new palette pages rendering. Next: Harmony palettes, accessibility tools, and named colors. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 11:38:20 +01:00
'use client';
import { cn } from '@/lib/utils/cn';
import { Check, Copy } from 'lucide-react';
import { useState } from 'react';
import { toast } from 'sonner';
interface ColorSwatchProps {
color: string;
size?: 'sm' | 'md' | 'lg';
showLabel?: boolean;
onClick?: () => void;
className?: string;
}
export function ColorSwatch({
color,
size = 'md',
showLabel = true,
onClick,
className,
}: ColorSwatchProps) {
const [copied, setCopied] = useState(false);
const sizeClasses = {
sm: 'h-12 w-12',
md: 'h-16 w-16',
lg: 'h-24 w-24',
};
const handleCopy = (e: React.MouseEvent) => {
e.stopPropagation();
navigator.clipboard.writeText(color);
setCopied(true);
toast.success(`Copied ${color}`);
setTimeout(() => setCopied(false), 2000);
};
return (
<div className={cn('flex flex-col items-center gap-2', className)}>
<button
className={cn(
feat: add comprehensive visual improvements and polished UI Major visual enhancements for professional look and feel: **New Components:** - Skeleton component for loading states - Pulse animation - Reusable for any content type - Consistent styling **Enhanced Animations:** - Added 8 new custom animations: - fade-in (smoother 0.3s) - slide-up/down (enhanced 0.4s) - slide-in-right/left (directional) - scale-in (zoom effect) - bounce-gentle (subtle bounce) - shimmer (loading effect) **Global Visual Improvements:** - Smooth theme transitions (200ms cubic-bezier) - Custom scrollbar styling with hover states - Smooth scroll behavior enabled - Theme transitioning class to prevent flash - Better transition timing functions **Component Enhancements:** 1. Home Page: - Staggered fade-in animations (0s, 0.1s, 0.2s-0.4s delays) - Scale animations on feature cards - Hover effects with shadow and border color change - Responsive padding adjustments - Enhanced button hover (scale + shadow) 2. ColorSwatch: - Improved hover scale (105% → 110%) - Added shadow on hover - Backdrop blur on overlay - Active state scale down (95%) - Smoother transitions (200ms) - Scale-in animation for copy icon 3. Button Component: - Active state scale down effect - Shadow on hover for primary/destructive - Border color change on outline hover - Smoother transitions (200ms) - Focus ring offset for better visibility **Micro-interactions:** - All buttons have active:scale-95 - Cards lift on hover with shadows - Smooth color transitions on theme switch - Icons animate on appearance - Links scale up on hover **Visual Consistency:** - Consistent timing (200ms for interactions) - Unified hover patterns across components - Standardized shadow depths - Better focus indicators - Smooth scroll throughout **Performance:** - No janky transitions - Optimized animations (transform + opacity) - Hardware-accelerated properties - Minimal repaints The UI now feels polished, professional, and delightful to use! Build successful - all visual enhancements working. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 12:04:46 +01:00
'relative rounded-lg ring-2 ring-border transition-all duration-200',
'hover:scale-110 hover:ring-primary hover:shadow-lg',
feat: implement palette generation features Add complete palette generation system with multiple methods: **New Components:** - ColorSwatch component - Individual color display - Click to copy to clipboard - Hover effects with copy icon - Configurable sizes (sm, md, lg) - Optional color label display - Check icon on successful copy - PaletteGrid component - Grid display for color palettes - Responsive grid layout (3-6 columns) - Click handler for color selection - Empty state message - Flexible and reusable - Select component - Dropdown selector - Consistent styling with other inputs - Optional label support - Keyboard accessible - Focus ring styling **Palette Pages:** 1. Gradient Creator (/palettes/gradient) - Multiple color stop editor (add/remove) - Configurable step count (2-1000) - Color space selection (RGB, HSL, Lab, LCH, OkLab, OkLCH) - Live gradient preview bar - Full palette grid display - Interactive color pickers for each stop - Real-time generation 2. Distinct Colors (/palettes/distinct) - Count selector (2-100 colors) - Distance metric selection (CIE76, CIEDE2000) - Simulated annealing algorithm - Statistics display: - Minimum distance - Average distance - Generation time - Loading state with progress message - Quality metrics for generated palette 3. Palettes Dashboard (/palettes) - Overview of all palette generators - Feature cards with icons - "Coming Soon" badge for harmony palettes - Quick navigation to each generator - Feature highlights for each method **Features:** - All palette generators integrated with Pastel API - Toast notifications for success/error - Loading states during generation - Copy colors to clipboard - Responsive layouts - Empty states - Error handling **API Integration:** - useGenerateGradient mutation - useGenerateDistinct mutation - Proper error handling and loading states - Result caching with React Query Build successful! 3 new palette pages rendering. Next: Harmony palettes, accessibility tools, and named colors. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 11:38:20 +01:00
'focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2',
feat: add comprehensive visual improvements and polished UI Major visual enhancements for professional look and feel: **New Components:** - Skeleton component for loading states - Pulse animation - Reusable for any content type - Consistent styling **Enhanced Animations:** - Added 8 new custom animations: - fade-in (smoother 0.3s) - slide-up/down (enhanced 0.4s) - slide-in-right/left (directional) - scale-in (zoom effect) - bounce-gentle (subtle bounce) - shimmer (loading effect) **Global Visual Improvements:** - Smooth theme transitions (200ms cubic-bezier) - Custom scrollbar styling with hover states - Smooth scroll behavior enabled - Theme transitioning class to prevent flash - Better transition timing functions **Component Enhancements:** 1. Home Page: - Staggered fade-in animations (0s, 0.1s, 0.2s-0.4s delays) - Scale animations on feature cards - Hover effects with shadow and border color change - Responsive padding adjustments - Enhanced button hover (scale + shadow) 2. ColorSwatch: - Improved hover scale (105% → 110%) - Added shadow on hover - Backdrop blur on overlay - Active state scale down (95%) - Smoother transitions (200ms) - Scale-in animation for copy icon 3. Button Component: - Active state scale down effect - Shadow on hover for primary/destructive - Border color change on outline hover - Smoother transitions (200ms) - Focus ring offset for better visibility **Micro-interactions:** - All buttons have active:scale-95 - Cards lift on hover with shadows - Smooth color transitions on theme switch - Icons animate on appearance - Links scale up on hover **Visual Consistency:** - Consistent timing (200ms for interactions) - Unified hover patterns across components - Standardized shadow depths - Better focus indicators - Smooth scroll throughout **Performance:** - No janky transitions - Optimized animations (transform + opacity) - Hardware-accelerated properties - Minimal repaints The UI now feels polished, professional, and delightful to use! Build successful - all visual enhancements working. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 12:04:46 +01:00
'group active:scale-95',
feat: implement palette generation features Add complete palette generation system with multiple methods: **New Components:** - ColorSwatch component - Individual color display - Click to copy to clipboard - Hover effects with copy icon - Configurable sizes (sm, md, lg) - Optional color label display - Check icon on successful copy - PaletteGrid component - Grid display for color palettes - Responsive grid layout (3-6 columns) - Click handler for color selection - Empty state message - Flexible and reusable - Select component - Dropdown selector - Consistent styling with other inputs - Optional label support - Keyboard accessible - Focus ring styling **Palette Pages:** 1. Gradient Creator (/palettes/gradient) - Multiple color stop editor (add/remove) - Configurable step count (2-1000) - Color space selection (RGB, HSL, Lab, LCH, OkLab, OkLCH) - Live gradient preview bar - Full palette grid display - Interactive color pickers for each stop - Real-time generation 2. Distinct Colors (/palettes/distinct) - Count selector (2-100 colors) - Distance metric selection (CIE76, CIEDE2000) - Simulated annealing algorithm - Statistics display: - Minimum distance - Average distance - Generation time - Loading state with progress message - Quality metrics for generated palette 3. Palettes Dashboard (/palettes) - Overview of all palette generators - Feature cards with icons - "Coming Soon" badge for harmony palettes - Quick navigation to each generator - Feature highlights for each method **Features:** - All palette generators integrated with Pastel API - Toast notifications for success/error - Loading states during generation - Copy colors to clipboard - Responsive layouts - Empty states - Error handling **API Integration:** - useGenerateGradient mutation - useGenerateDistinct mutation - Proper error handling and loading states - Result caching with React Query Build successful! 3 new palette pages rendering. Next: Harmony palettes, accessibility tools, and named colors. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 11:38:20 +01:00
sizeClasses[size]
)}
style={{ backgroundColor: color }}
onClick={onClick || handleCopy}
aria-label={`Color ${color}`}
>
feat: add comprehensive visual improvements and polished UI Major visual enhancements for professional look and feel: **New Components:** - Skeleton component for loading states - Pulse animation - Reusable for any content type - Consistent styling **Enhanced Animations:** - Added 8 new custom animations: - fade-in (smoother 0.3s) - slide-up/down (enhanced 0.4s) - slide-in-right/left (directional) - scale-in (zoom effect) - bounce-gentle (subtle bounce) - shimmer (loading effect) **Global Visual Improvements:** - Smooth theme transitions (200ms cubic-bezier) - Custom scrollbar styling with hover states - Smooth scroll behavior enabled - Theme transitioning class to prevent flash - Better transition timing functions **Component Enhancements:** 1. Home Page: - Staggered fade-in animations (0s, 0.1s, 0.2s-0.4s delays) - Scale animations on feature cards - Hover effects with shadow and border color change - Responsive padding adjustments - Enhanced button hover (scale + shadow) 2. ColorSwatch: - Improved hover scale (105% → 110%) - Added shadow on hover - Backdrop blur on overlay - Active state scale down (95%) - Smoother transitions (200ms) - Scale-in animation for copy icon 3. Button Component: - Active state scale down effect - Shadow on hover for primary/destructive - Border color change on outline hover - Smoother transitions (200ms) - Focus ring offset for better visibility **Micro-interactions:** - All buttons have active:scale-95 - Cards lift on hover with shadows - Smooth color transitions on theme switch - Icons animate on appearance - Links scale up on hover **Visual Consistency:** - Consistent timing (200ms for interactions) - Unified hover patterns across components - Standardized shadow depths - Better focus indicators - Smooth scroll throughout **Performance:** - No janky transitions - Optimized animations (transform + opacity) - Hardware-accelerated properties - Minimal repaints The UI now feels polished, professional, and delightful to use! Build successful - all visual enhancements working. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 12:04:46 +01:00
<div className="absolute inset-0 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-all duration-200 bg-black/30 rounded-lg backdrop-blur-sm">
feat: implement palette generation features Add complete palette generation system with multiple methods: **New Components:** - ColorSwatch component - Individual color display - Click to copy to clipboard - Hover effects with copy icon - Configurable sizes (sm, md, lg) - Optional color label display - Check icon on successful copy - PaletteGrid component - Grid display for color palettes - Responsive grid layout (3-6 columns) - Click handler for color selection - Empty state message - Flexible and reusable - Select component - Dropdown selector - Consistent styling with other inputs - Optional label support - Keyboard accessible - Focus ring styling **Palette Pages:** 1. Gradient Creator (/palettes/gradient) - Multiple color stop editor (add/remove) - Configurable step count (2-1000) - Color space selection (RGB, HSL, Lab, LCH, OkLab, OkLCH) - Live gradient preview bar - Full palette grid display - Interactive color pickers for each stop - Real-time generation 2. Distinct Colors (/palettes/distinct) - Count selector (2-100 colors) - Distance metric selection (CIE76, CIEDE2000) - Simulated annealing algorithm - Statistics display: - Minimum distance - Average distance - Generation time - Loading state with progress message - Quality metrics for generated palette 3. Palettes Dashboard (/palettes) - Overview of all palette generators - Feature cards with icons - "Coming Soon" badge for harmony palettes - Quick navigation to each generator - Feature highlights for each method **Features:** - All palette generators integrated with Pastel API - Toast notifications for success/error - Loading states during generation - Copy colors to clipboard - Responsive layouts - Empty states - Error handling **API Integration:** - useGenerateGradient mutation - useGenerateDistinct mutation - Proper error handling and loading states - Result caching with React Query Build successful! 3 new palette pages rendering. Next: Harmony palettes, accessibility tools, and named colors. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 11:38:20 +01:00
{copied ? (
feat: add comprehensive visual improvements and polished UI Major visual enhancements for professional look and feel: **New Components:** - Skeleton component for loading states - Pulse animation - Reusable for any content type - Consistent styling **Enhanced Animations:** - Added 8 new custom animations: - fade-in (smoother 0.3s) - slide-up/down (enhanced 0.4s) - slide-in-right/left (directional) - scale-in (zoom effect) - bounce-gentle (subtle bounce) - shimmer (loading effect) **Global Visual Improvements:** - Smooth theme transitions (200ms cubic-bezier) - Custom scrollbar styling with hover states - Smooth scroll behavior enabled - Theme transitioning class to prevent flash - Better transition timing functions **Component Enhancements:** 1. Home Page: - Staggered fade-in animations (0s, 0.1s, 0.2s-0.4s delays) - Scale animations on feature cards - Hover effects with shadow and border color change - Responsive padding adjustments - Enhanced button hover (scale + shadow) 2. ColorSwatch: - Improved hover scale (105% → 110%) - Added shadow on hover - Backdrop blur on overlay - Active state scale down (95%) - Smoother transitions (200ms) - Scale-in animation for copy icon 3. Button Component: - Active state scale down effect - Shadow on hover for primary/destructive - Border color change on outline hover - Smoother transitions (200ms) - Focus ring offset for better visibility **Micro-interactions:** - All buttons have active:scale-95 - Cards lift on hover with shadows - Smooth color transitions on theme switch - Icons animate on appearance - Links scale up on hover **Visual Consistency:** - Consistent timing (200ms for interactions) - Unified hover patterns across components - Standardized shadow depths - Better focus indicators - Smooth scroll throughout **Performance:** - No janky transitions - Optimized animations (transform + opacity) - Hardware-accelerated properties - Minimal repaints The UI now feels polished, professional, and delightful to use! Build successful - all visual enhancements working. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 12:04:46 +01:00
<Check className="h-5 w-5 text-white animate-scale-in" />
feat: implement palette generation features Add complete palette generation system with multiple methods: **New Components:** - ColorSwatch component - Individual color display - Click to copy to clipboard - Hover effects with copy icon - Configurable sizes (sm, md, lg) - Optional color label display - Check icon on successful copy - PaletteGrid component - Grid display for color palettes - Responsive grid layout (3-6 columns) - Click handler for color selection - Empty state message - Flexible and reusable - Select component - Dropdown selector - Consistent styling with other inputs - Optional label support - Keyboard accessible - Focus ring styling **Palette Pages:** 1. Gradient Creator (/palettes/gradient) - Multiple color stop editor (add/remove) - Configurable step count (2-1000) - Color space selection (RGB, HSL, Lab, LCH, OkLab, OkLCH) - Live gradient preview bar - Full palette grid display - Interactive color pickers for each stop - Real-time generation 2. Distinct Colors (/palettes/distinct) - Count selector (2-100 colors) - Distance metric selection (CIE76, CIEDE2000) - Simulated annealing algorithm - Statistics display: - Minimum distance - Average distance - Generation time - Loading state with progress message - Quality metrics for generated palette 3. Palettes Dashboard (/palettes) - Overview of all palette generators - Feature cards with icons - "Coming Soon" badge for harmony palettes - Quick navigation to each generator - Feature highlights for each method **Features:** - All palette generators integrated with Pastel API - Toast notifications for success/error - Loading states during generation - Copy colors to clipboard - Responsive layouts - Empty states - Error handling **API Integration:** - useGenerateGradient mutation - useGenerateDistinct mutation - Proper error handling and loading states - Result caching with React Query Build successful! 3 new palette pages rendering. Next: Harmony palettes, accessibility tools, and named colors. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 11:38:20 +01:00
) : (
<Copy className="h-5 w-5 text-white" />
)}
</div>
</button>
{showLabel && (
<span className="text-xs font-mono text-muted-foreground">{color}</span>
)}
</div>
);
}