Files
pastel-ui/app/playground/page.tsx

219 lines
7.9 KiB
TypeScript
Raw Normal View History

feat: implement color playground with interactive picker and info display Add complete color manipulation interface: **Color Components:** - ColorPicker - Interactive hex color picker with text input - Uses react-colorful for visual selection - Manual input support for any color format - Real-time updates - ColorDisplay - Large color preview swatch - Configurable sizes (sm, md, lg, xl) - Optional border styling - Accessible with ARIA labels - ColorInfo - Comprehensive color information display - Shows all formats: Hex, RGB, HSL, Lab, OkLab - Copy to clipboard functionality for each format - Displays brightness, luminance, light/dark type - Shows named color matches **API Integration:** - React Query hooks for all Pastel API endpoints - useColorInfo - Get color information - useConvertFormat - Format conversion - useLighten, useDarken, useSaturate, etc. - Manipulations - useGenerateRandom, useGenerateDistinct, useGenerateGradient - useNamedColors - Cached named colors list - Automatic error handling and loading states **Playground Page (/playground):** - Two-column layout: picker + info - Live color preview with large swatch - Real-time API integration with loading states - Error handling with user-friendly messages - Quick action buttons (ready for implementation) - Responsive grid layout **Features:** - Toast notifications for clipboard copy - Loading spinners during API calls - Error display with helpful messages - Accessible keyboard navigation - Smooth transitions and animations Build successful with playground page rendering! Ready for color manipulation actions. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 11:05:23 +01:00
'use client';
feat: implement UX enhancements for playground Add comprehensive UX improvements to color playground: **URL State Sharing:** - Implement URL parameter sync for colors - Add share button to copy playground URLs - Wrap in Suspense boundary for Next.js 16 compatibility - Colors persist in URL for easy sharing **Keyboard Shortcuts:** - Create reusable useKeyboard hook with modifier support - Add Cmd/Ctrl+C to copy current color - Add Cmd/Ctrl+S to share color URL - Add Cmd/Ctrl+R for random color generation - Display keyboard hints in playground header - Cross-platform support (Mac/Windows/Linux) **Color History:** - Implement Zustand store with localStorage persistence - Track up to 50 most recent colors with timestamps - Auto-deduplicate and keep most recent entry - Add visual history grid in playground - Click to restore previous colors - Individual color removal with hover UI - Clear all history option **Playground UI Enhancements:** - Add visual keyboard shortcut indicators (⌘C, ⌘S, ⌘R) - Implement Recent Colors section with 5-column grid - Add hover effects for history color swatches - Individual remove buttons on hover - Toast notifications for all actions - Improved button layout and spacing **Files Added:** - lib/hooks/useKeyboard.ts - Keyboard shortcut management - lib/stores/historyStore.ts - Color history with persistence **Files Modified:** - app/playground/page.tsx - Integrated all UX features Successfully builds with all features working. Ready for user testing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 12:30:33 +01:00
import { useState, useEffect, Suspense } from 'react';
import { useSearchParams, useRouter } from 'next/navigation';
feat: implement color playground with interactive picker and info display Add complete color manipulation interface: **Color Components:** - ColorPicker - Interactive hex color picker with text input - Uses react-colorful for visual selection - Manual input support for any color format - Real-time updates - ColorDisplay - Large color preview swatch - Configurable sizes (sm, md, lg, xl) - Optional border styling - Accessible with ARIA labels - ColorInfo - Comprehensive color information display - Shows all formats: Hex, RGB, HSL, Lab, OkLab - Copy to clipboard functionality for each format - Displays brightness, luminance, light/dark type - Shows named color matches **API Integration:** - React Query hooks for all Pastel API endpoints - useColorInfo - Get color information - useConvertFormat - Format conversion - useLighten, useDarken, useSaturate, etc. - Manipulations - useGenerateRandom, useGenerateDistinct, useGenerateGradient - useNamedColors - Cached named colors list - Automatic error handling and loading states **Playground Page (/playground):** - Two-column layout: picker + info - Live color preview with large swatch - Real-time API integration with loading states - Error handling with user-friendly messages - Quick action buttons (ready for implementation) - Responsive grid layout **Features:** - Toast notifications for clipboard copy - Loading spinners during API calls - Error display with helpful messages - Accessible keyboard navigation - Smooth transitions and animations Build successful with playground page rendering! Ready for color manipulation actions. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 11:05:23 +01:00
import { ColorPicker } from '@/components/color/ColorPicker';
import { ColorDisplay } from '@/components/color/ColorDisplay';
import { ColorInfo } from '@/components/color/ColorInfo';
feat: implement color manipulation tools with interactive sliders Add complete color manipulation interface to playground: **New Components:** - Slider component - Customizable range input with label and value display - Smooth animations on thumb hover - Keyboard accessible - Shows current value with optional suffix - Tailwind-styled for consistency - ManipulationPanel component - Full color manipulation controls - Lighten/Darken sliders (0-100% range) - Saturate/Desaturate sliders (0-100% range) - Hue rotation slider (-180° to +180°) - Complementary color quick action - All operations integrated with Pastel API - Toast notifications for success/error - Loading states during API calls **Playground Enhancements:** - Replaced placeholder quick action buttons with ManipulationPanel - Full integration with color manipulation mutations - Real-time color updates after each operation - User-friendly feedback with toast messages - Amount controls for precise adjustments **Features:** - Live preview of manipulation results - Configurable amounts before applying - Success/error handling with helpful messages - Disabled state during API operations - Smooth user experience with immediate feedback **API Integration:** - useLighten, useDarken mutations - useSaturate, useDesaturate mutations - useRotate for hue rotation - useComplement for complementary colors - All mutations with proper error handling Build successful! Color manipulation tools fully functional. Next: Navigation, theme system, and additional UI components. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 11:28:35 +01:00
import { ManipulationPanel } from '@/components/tools/ManipulationPanel';
feat: implement color playground with interactive picker and info display Add complete color manipulation interface: **Color Components:** - ColorPicker - Interactive hex color picker with text input - Uses react-colorful for visual selection - Manual input support for any color format - Real-time updates - ColorDisplay - Large color preview swatch - Configurable sizes (sm, md, lg, xl) - Optional border styling - Accessible with ARIA labels - ColorInfo - Comprehensive color information display - Shows all formats: Hex, RGB, HSL, Lab, OkLab - Copy to clipboard functionality for each format - Displays brightness, luminance, light/dark type - Shows named color matches **API Integration:** - React Query hooks for all Pastel API endpoints - useColorInfo - Get color information - useConvertFormat - Format conversion - useLighten, useDarken, useSaturate, etc. - Manipulations - useGenerateRandom, useGenerateDistinct, useGenerateGradient - useNamedColors - Cached named colors list - Automatic error handling and loading states **Playground Page (/playground):** - Two-column layout: picker + info - Live color preview with large swatch - Real-time API integration with loading states - Error handling with user-friendly messages - Quick action buttons (ready for implementation) - Responsive grid layout **Features:** - Toast notifications for clipboard copy - Loading spinners during API calls - Error display with helpful messages - Accessible keyboard navigation - Smooth transitions and animations Build successful with playground page rendering! Ready for color manipulation actions. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 11:05:23 +01:00
import { useColorInfo } from '@/lib/api/queries';
feat: implement UX enhancements for playground Add comprehensive UX improvements to color playground: **URL State Sharing:** - Implement URL parameter sync for colors - Add share button to copy playground URLs - Wrap in Suspense boundary for Next.js 16 compatibility - Colors persist in URL for easy sharing **Keyboard Shortcuts:** - Create reusable useKeyboard hook with modifier support - Add Cmd/Ctrl+C to copy current color - Add Cmd/Ctrl+S to share color URL - Add Cmd/Ctrl+R for random color generation - Display keyboard hints in playground header - Cross-platform support (Mac/Windows/Linux) **Color History:** - Implement Zustand store with localStorage persistence - Track up to 50 most recent colors with timestamps - Auto-deduplicate and keep most recent entry - Add visual history grid in playground - Click to restore previous colors - Individual color removal with hover UI - Clear all history option **Playground UI Enhancements:** - Add visual keyboard shortcut indicators (⌘C, ⌘S, ⌘R) - Implement Recent Colors section with 5-column grid - Add hover effects for history color swatches - Individual remove buttons on hover - Toast notifications for all actions - Improved button layout and spacing **Files Added:** - lib/hooks/useKeyboard.ts - Keyboard shortcut management - lib/stores/historyStore.ts - Color history with persistence **Files Modified:** - app/playground/page.tsx - Integrated all UX features Successfully builds with all features working. Ready for user testing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 12:30:33 +01:00
import { useKeyboard } from '@/lib/hooks/useKeyboard';
import { useColorHistory } from '@/lib/stores/historyStore';
import { Loader2, Share2, History, X } from 'lucide-react';
import { Button } from '@/components/ui/button';
import { toast } from 'sonner';
feat: implement color playground with interactive picker and info display Add complete color manipulation interface: **Color Components:** - ColorPicker - Interactive hex color picker with text input - Uses react-colorful for visual selection - Manual input support for any color format - Real-time updates - ColorDisplay - Large color preview swatch - Configurable sizes (sm, md, lg, xl) - Optional border styling - Accessible with ARIA labels - ColorInfo - Comprehensive color information display - Shows all formats: Hex, RGB, HSL, Lab, OkLab - Copy to clipboard functionality for each format - Displays brightness, luminance, light/dark type - Shows named color matches **API Integration:** - React Query hooks for all Pastel API endpoints - useColorInfo - Get color information - useConvertFormat - Format conversion - useLighten, useDarken, useSaturate, etc. - Manipulations - useGenerateRandom, useGenerateDistinct, useGenerateGradient - useNamedColors - Cached named colors list - Automatic error handling and loading states **Playground Page (/playground):** - Two-column layout: picker + info - Live color preview with large swatch - Real-time API integration with loading states - Error handling with user-friendly messages - Quick action buttons (ready for implementation) - Responsive grid layout **Features:** - Toast notifications for clipboard copy - Loading spinners during API calls - Error display with helpful messages - Accessible keyboard navigation - Smooth transitions and animations Build successful with playground page rendering! Ready for color manipulation actions. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 11:05:23 +01:00
feat: implement UX enhancements for playground Add comprehensive UX improvements to color playground: **URL State Sharing:** - Implement URL parameter sync for colors - Add share button to copy playground URLs - Wrap in Suspense boundary for Next.js 16 compatibility - Colors persist in URL for easy sharing **Keyboard Shortcuts:** - Create reusable useKeyboard hook with modifier support - Add Cmd/Ctrl+C to copy current color - Add Cmd/Ctrl+S to share color URL - Add Cmd/Ctrl+R for random color generation - Display keyboard hints in playground header - Cross-platform support (Mac/Windows/Linux) **Color History:** - Implement Zustand store with localStorage persistence - Track up to 50 most recent colors with timestamps - Auto-deduplicate and keep most recent entry - Add visual history grid in playground - Click to restore previous colors - Individual color removal with hover UI - Clear all history option **Playground UI Enhancements:** - Add visual keyboard shortcut indicators (⌘C, ⌘S, ⌘R) - Implement Recent Colors section with 5-column grid - Add hover effects for history color swatches - Individual remove buttons on hover - Toast notifications for all actions - Improved button layout and spacing **Files Added:** - lib/hooks/useKeyboard.ts - Keyboard shortcut management - lib/stores/historyStore.ts - Color history with persistence **Files Modified:** - app/playground/page.tsx - Integrated all UX features Successfully builds with all features working. Ready for user testing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 12:30:33 +01:00
function PlaygroundContent() {
const searchParams = useSearchParams();
const router = useRouter();
const [color, setColor] = useState(() => {
// Initialize from URL if available
const urlColor = searchParams.get('color');
return urlColor ? `#${urlColor.replace('#', '')}` : '#ff0099';
});
feat: implement color playground with interactive picker and info display Add complete color manipulation interface: **Color Components:** - ColorPicker - Interactive hex color picker with text input - Uses react-colorful for visual selection - Manual input support for any color format - Real-time updates - ColorDisplay - Large color preview swatch - Configurable sizes (sm, md, lg, xl) - Optional border styling - Accessible with ARIA labels - ColorInfo - Comprehensive color information display - Shows all formats: Hex, RGB, HSL, Lab, OkLab - Copy to clipboard functionality for each format - Displays brightness, luminance, light/dark type - Shows named color matches **API Integration:** - React Query hooks for all Pastel API endpoints - useColorInfo - Get color information - useConvertFormat - Format conversion - useLighten, useDarken, useSaturate, etc. - Manipulations - useGenerateRandom, useGenerateDistinct, useGenerateGradient - useNamedColors - Cached named colors list - Automatic error handling and loading states **Playground Page (/playground):** - Two-column layout: picker + info - Live color preview with large swatch - Real-time API integration with loading states - Error handling with user-friendly messages - Quick action buttons (ready for implementation) - Responsive grid layout **Features:** - Toast notifications for clipboard copy - Loading spinners during API calls - Error display with helpful messages - Accessible keyboard navigation - Smooth transitions and animations Build successful with playground page rendering! Ready for color manipulation actions. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 11:05:23 +01:00
const { data, isLoading, isError, error } = useColorInfo({
colors: [color],
});
const colorInfo = data?.colors[0];
feat: implement UX enhancements for playground Add comprehensive UX improvements to color playground: **URL State Sharing:** - Implement URL parameter sync for colors - Add share button to copy playground URLs - Wrap in Suspense boundary for Next.js 16 compatibility - Colors persist in URL for easy sharing **Keyboard Shortcuts:** - Create reusable useKeyboard hook with modifier support - Add Cmd/Ctrl+C to copy current color - Add Cmd/Ctrl+S to share color URL - Add Cmd/Ctrl+R for random color generation - Display keyboard hints in playground header - Cross-platform support (Mac/Windows/Linux) **Color History:** - Implement Zustand store with localStorage persistence - Track up to 50 most recent colors with timestamps - Auto-deduplicate and keep most recent entry - Add visual history grid in playground - Click to restore previous colors - Individual color removal with hover UI - Clear all history option **Playground UI Enhancements:** - Add visual keyboard shortcut indicators (⌘C, ⌘S, ⌘R) - Implement Recent Colors section with 5-column grid - Add hover effects for history color swatches - Individual remove buttons on hover - Toast notifications for all actions - Improved button layout and spacing **Files Added:** - lib/hooks/useKeyboard.ts - Keyboard shortcut management - lib/stores/historyStore.ts - Color history with persistence **Files Modified:** - app/playground/page.tsx - Integrated all UX features Successfully builds with all features working. Ready for user testing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 12:30:33 +01:00
// Color history
const { history, addColor, removeColor, clearHistory, getRecent } = useColorHistory();
const recentColors = getRecent(10);
// Update URL and history when color changes
useEffect(() => {
const hex = color.replace('#', '');
router.push(`/playground?color=${hex}`, { scroll: false });
addColor(color);
}, [color, router, addColor]);
// Share color via URL
const handleShare = () => {
const url = `${window.location.origin}/playground?color=${color.replace('#', '')}`;
navigator.clipboard.writeText(url);
toast.success('Link copied to clipboard!');
};
// Copy color to clipboard
const handleCopyColor = () => {
navigator.clipboard.writeText(color);
toast.success('Color copied to clipboard!');
};
// Random color generation
const handleRandomColor = () => {
const randomHex = '#' + Math.floor(Math.random() * 16777215).toString(16).padStart(6, '0');
setColor(randomHex);
};
// Keyboard shortcuts
useKeyboard([
{
key: 'c',
meta: true,
handler: handleCopyColor,
description: 'Copy color',
},
{
key: 's',
meta: true,
handler: handleShare,
description: 'Share color',
},
{
key: 'r',
meta: true,
handler: handleRandomColor,
description: 'Random color',
},
]);
feat: implement color playground with interactive picker and info display Add complete color manipulation interface: **Color Components:** - ColorPicker - Interactive hex color picker with text input - Uses react-colorful for visual selection - Manual input support for any color format - Real-time updates - ColorDisplay - Large color preview swatch - Configurable sizes (sm, md, lg, xl) - Optional border styling - Accessible with ARIA labels - ColorInfo - Comprehensive color information display - Shows all formats: Hex, RGB, HSL, Lab, OkLab - Copy to clipboard functionality for each format - Displays brightness, luminance, light/dark type - Shows named color matches **API Integration:** - React Query hooks for all Pastel API endpoints - useColorInfo - Get color information - useConvertFormat - Format conversion - useLighten, useDarken, useSaturate, etc. - Manipulations - useGenerateRandom, useGenerateDistinct, useGenerateGradient - useNamedColors - Cached named colors list - Automatic error handling and loading states **Playground Page (/playground):** - Two-column layout: picker + info - Live color preview with large swatch - Real-time API integration with loading states - Error handling with user-friendly messages - Quick action buttons (ready for implementation) - Responsive grid layout **Features:** - Toast notifications for clipboard copy - Loading spinners during API calls - Error display with helpful messages - Accessible keyboard navigation - Smooth transitions and animations Build successful with playground page rendering! Ready for color manipulation actions. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 11:05:23 +01:00
return (
<div className="min-h-screen px-8 py-12">
feat: implement color playground with interactive picker and info display Add complete color manipulation interface: **Color Components:** - ColorPicker - Interactive hex color picker with text input - Uses react-colorful for visual selection - Manual input support for any color format - Real-time updates - ColorDisplay - Large color preview swatch - Configurable sizes (sm, md, lg, xl) - Optional border styling - Accessible with ARIA labels - ColorInfo - Comprehensive color information display - Shows all formats: Hex, RGB, HSL, Lab, OkLab - Copy to clipboard functionality for each format - Displays brightness, luminance, light/dark type - Shows named color matches **API Integration:** - React Query hooks for all Pastel API endpoints - useColorInfo - Get color information - useConvertFormat - Format conversion - useLighten, useDarken, useSaturate, etc. - Manipulations - useGenerateRandom, useGenerateDistinct, useGenerateGradient - useNamedColors - Cached named colors list - Automatic error handling and loading states **Playground Page (/playground):** - Two-column layout: picker + info - Live color preview with large swatch - Real-time API integration with loading states - Error handling with user-friendly messages - Quick action buttons (ready for implementation) - Responsive grid layout **Features:** - Toast notifications for clipboard copy - Loading spinners during API calls - Error display with helpful messages - Accessible keyboard navigation - Smooth transitions and animations Build successful with playground page rendering! Ready for color manipulation actions. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 11:05:23 +01:00
<div className="max-w-7xl mx-auto space-y-8">
<div>
<h1 className="text-4xl font-bold mb-2">Color Playground</h1>
<p className="text-muted-foreground">
Interactive color manipulation and analysis tool
</p>
feat: implement UX enhancements for playground Add comprehensive UX improvements to color playground: **URL State Sharing:** - Implement URL parameter sync for colors - Add share button to copy playground URLs - Wrap in Suspense boundary for Next.js 16 compatibility - Colors persist in URL for easy sharing **Keyboard Shortcuts:** - Create reusable useKeyboard hook with modifier support - Add Cmd/Ctrl+C to copy current color - Add Cmd/Ctrl+S to share color URL - Add Cmd/Ctrl+R for random color generation - Display keyboard hints in playground header - Cross-platform support (Mac/Windows/Linux) **Color History:** - Implement Zustand store with localStorage persistence - Track up to 50 most recent colors with timestamps - Auto-deduplicate and keep most recent entry - Add visual history grid in playground - Click to restore previous colors - Individual color removal with hover UI - Clear all history option **Playground UI Enhancements:** - Add visual keyboard shortcut indicators (⌘C, ⌘S, ⌘R) - Implement Recent Colors section with 5-column grid - Add hover effects for history color swatches - Individual remove buttons on hover - Toast notifications for all actions - Improved button layout and spacing **Files Added:** - lib/hooks/useKeyboard.ts - Keyboard shortcut management - lib/stores/historyStore.ts - Color history with persistence **Files Modified:** - app/playground/page.tsx - Integrated all UX features Successfully builds with all features working. Ready for user testing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 12:30:33 +01:00
<div className="mt-3 flex flex-wrap gap-2 text-xs text-muted-foreground">
<kbd className="px-2 py-1 bg-muted rounded border">C</kbd>
<span>Copy</span>
<kbd className="px-2 py-1 bg-muted rounded border ml-3">S</kbd>
<span>Share</span>
<kbd className="px-2 py-1 bg-muted rounded border ml-3">R</kbd>
<span>Random</span>
</div>
feat: implement color playground with interactive picker and info display Add complete color manipulation interface: **Color Components:** - ColorPicker - Interactive hex color picker with text input - Uses react-colorful for visual selection - Manual input support for any color format - Real-time updates - ColorDisplay - Large color preview swatch - Configurable sizes (sm, md, lg, xl) - Optional border styling - Accessible with ARIA labels - ColorInfo - Comprehensive color information display - Shows all formats: Hex, RGB, HSL, Lab, OkLab - Copy to clipboard functionality for each format - Displays brightness, luminance, light/dark type - Shows named color matches **API Integration:** - React Query hooks for all Pastel API endpoints - useColorInfo - Get color information - useConvertFormat - Format conversion - useLighten, useDarken, useSaturate, etc. - Manipulations - useGenerateRandom, useGenerateDistinct, useGenerateGradient - useNamedColors - Cached named colors list - Automatic error handling and loading states **Playground Page (/playground):** - Two-column layout: picker + info - Live color preview with large swatch - Real-time API integration with loading states - Error handling with user-friendly messages - Quick action buttons (ready for implementation) - Responsive grid layout **Features:** - Toast notifications for clipboard copy - Loading spinners during API calls - Error display with helpful messages - Accessible keyboard navigation - Smooth transitions and animations Build successful with playground page rendering! Ready for color manipulation actions. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 11:05:23 +01:00
</div>
<div className="grid grid-cols-1 lg:grid-cols-2 gap-8">
{/* Left Column: Color Picker and Display */}
<div className="space-y-6">
<div className="p-6 border rounded-lg bg-card">
<h2 className="text-xl font-semibold mb-4">Color Picker</h2>
<ColorPicker color={color} onChange={setColor} />
</div>
<div className="p-6 border rounded-lg bg-card">
feat: implement UX enhancements for playground Add comprehensive UX improvements to color playground: **URL State Sharing:** - Implement URL parameter sync for colors - Add share button to copy playground URLs - Wrap in Suspense boundary for Next.js 16 compatibility - Colors persist in URL for easy sharing **Keyboard Shortcuts:** - Create reusable useKeyboard hook with modifier support - Add Cmd/Ctrl+C to copy current color - Add Cmd/Ctrl+S to share color URL - Add Cmd/Ctrl+R for random color generation - Display keyboard hints in playground header - Cross-platform support (Mac/Windows/Linux) **Color History:** - Implement Zustand store with localStorage persistence - Track up to 50 most recent colors with timestamps - Auto-deduplicate and keep most recent entry - Add visual history grid in playground - Click to restore previous colors - Individual color removal with hover UI - Clear all history option **Playground UI Enhancements:** - Add visual keyboard shortcut indicators (⌘C, ⌘S, ⌘R) - Implement Recent Colors section with 5-column grid - Add hover effects for history color swatches - Individual remove buttons on hover - Toast notifications for all actions - Improved button layout and spacing **Files Added:** - lib/hooks/useKeyboard.ts - Keyboard shortcut management - lib/stores/historyStore.ts - Color history with persistence **Files Modified:** - app/playground/page.tsx - Integrated all UX features Successfully builds with all features working. Ready for user testing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 12:30:33 +01:00
<div className="flex items-center justify-between mb-4">
<h2 className="text-xl font-semibold">Preview</h2>
<Button onClick={handleShare} variant="outline" size="sm">
<Share2 className="h-4 w-4 mr-2" />
Share
</Button>
</div>
feat: implement color playground with interactive picker and info display Add complete color manipulation interface: **Color Components:** - ColorPicker - Interactive hex color picker with text input - Uses react-colorful for visual selection - Manual input support for any color format - Real-time updates - ColorDisplay - Large color preview swatch - Configurable sizes (sm, md, lg, xl) - Optional border styling - Accessible with ARIA labels - ColorInfo - Comprehensive color information display - Shows all formats: Hex, RGB, HSL, Lab, OkLab - Copy to clipboard functionality for each format - Displays brightness, luminance, light/dark type - Shows named color matches **API Integration:** - React Query hooks for all Pastel API endpoints - useColorInfo - Get color information - useConvertFormat - Format conversion - useLighten, useDarken, useSaturate, etc. - Manipulations - useGenerateRandom, useGenerateDistinct, useGenerateGradient - useNamedColors - Cached named colors list - Automatic error handling and loading states **Playground Page (/playground):** - Two-column layout: picker + info - Live color preview with large swatch - Real-time API integration with loading states - Error handling with user-friendly messages - Quick action buttons (ready for implementation) - Responsive grid layout **Features:** - Toast notifications for clipboard copy - Loading spinners during API calls - Error display with helpful messages - Accessible keyboard navigation - Smooth transitions and animations Build successful with playground page rendering! Ready for color manipulation actions. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 11:05:23 +01:00
<div className="flex justify-center">
<ColorDisplay color={color} size="xl" />
</div>
</div>
feat: implement UX enhancements for playground Add comprehensive UX improvements to color playground: **URL State Sharing:** - Implement URL parameter sync for colors - Add share button to copy playground URLs - Wrap in Suspense boundary for Next.js 16 compatibility - Colors persist in URL for easy sharing **Keyboard Shortcuts:** - Create reusable useKeyboard hook with modifier support - Add Cmd/Ctrl+C to copy current color - Add Cmd/Ctrl+S to share color URL - Add Cmd/Ctrl+R for random color generation - Display keyboard hints in playground header - Cross-platform support (Mac/Windows/Linux) **Color History:** - Implement Zustand store with localStorage persistence - Track up to 50 most recent colors with timestamps - Auto-deduplicate and keep most recent entry - Add visual history grid in playground - Click to restore previous colors - Individual color removal with hover UI - Clear all history option **Playground UI Enhancements:** - Add visual keyboard shortcut indicators (⌘C, ⌘S, ⌘R) - Implement Recent Colors section with 5-column grid - Add hover effects for history color swatches - Individual remove buttons on hover - Toast notifications for all actions - Improved button layout and spacing **Files Added:** - lib/hooks/useKeyboard.ts - Keyboard shortcut management - lib/stores/historyStore.ts - Color history with persistence **Files Modified:** - app/playground/page.tsx - Integrated all UX features Successfully builds with all features working. Ready for user testing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 12:30:33 +01:00
{recentColors.length > 0 && (
<div className="p-6 border rounded-lg bg-card">
<div className="flex items-center justify-between mb-4">
<div className="flex items-center gap-2">
<History className="h-5 w-5" />
<h2 className="text-xl font-semibold">Recent Colors</h2>
</div>
<Button
onClick={clearHistory}
variant="ghost"
size="sm"
className="text-muted-foreground hover:text-foreground"
>
Clear
</Button>
</div>
<div className="grid grid-cols-5 gap-2">
{recentColors.map((entry) => (
<div
feat: implement UX enhancements for playground Add comprehensive UX improvements to color playground: **URL State Sharing:** - Implement URL parameter sync for colors - Add share button to copy playground URLs - Wrap in Suspense boundary for Next.js 16 compatibility - Colors persist in URL for easy sharing **Keyboard Shortcuts:** - Create reusable useKeyboard hook with modifier support - Add Cmd/Ctrl+C to copy current color - Add Cmd/Ctrl+S to share color URL - Add Cmd/Ctrl+R for random color generation - Display keyboard hints in playground header - Cross-platform support (Mac/Windows/Linux) **Color History:** - Implement Zustand store with localStorage persistence - Track up to 50 most recent colors with timestamps - Auto-deduplicate and keep most recent entry - Add visual history grid in playground - Click to restore previous colors - Individual color removal with hover UI - Clear all history option **Playground UI Enhancements:** - Add visual keyboard shortcut indicators (⌘C, ⌘S, ⌘R) - Implement Recent Colors section with 5-column grid - Add hover effects for history color swatches - Individual remove buttons on hover - Toast notifications for all actions - Improved button layout and spacing **Files Added:** - lib/hooks/useKeyboard.ts - Keyboard shortcut management - lib/stores/historyStore.ts - Color history with persistence **Files Modified:** - app/playground/page.tsx - Integrated all UX features Successfully builds with all features working. Ready for user testing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 12:30:33 +01:00
key={entry.timestamp}
className="group relative aspect-square rounded-lg border-2 border-border hover:border-primary transition-all hover:scale-110 cursor-pointer"
feat: implement UX enhancements for playground Add comprehensive UX improvements to color playground: **URL State Sharing:** - Implement URL parameter sync for colors - Add share button to copy playground URLs - Wrap in Suspense boundary for Next.js 16 compatibility - Colors persist in URL for easy sharing **Keyboard Shortcuts:** - Create reusable useKeyboard hook with modifier support - Add Cmd/Ctrl+C to copy current color - Add Cmd/Ctrl+S to share color URL - Add Cmd/Ctrl+R for random color generation - Display keyboard hints in playground header - Cross-platform support (Mac/Windows/Linux) **Color History:** - Implement Zustand store with localStorage persistence - Track up to 50 most recent colors with timestamps - Auto-deduplicate and keep most recent entry - Add visual history grid in playground - Click to restore previous colors - Individual color removal with hover UI - Clear all history option **Playground UI Enhancements:** - Add visual keyboard shortcut indicators (⌘C, ⌘S, ⌘R) - Implement Recent Colors section with 5-column grid - Add hover effects for history color swatches - Individual remove buttons on hover - Toast notifications for all actions - Improved button layout and spacing **Files Added:** - lib/hooks/useKeyboard.ts - Keyboard shortcut management - lib/stores/historyStore.ts - Color history with persistence **Files Modified:** - app/playground/page.tsx - Integrated all UX features Successfully builds with all features working. Ready for user testing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 12:30:33 +01:00
style={{ backgroundColor: entry.color }}
onClick={() => setColor(entry.color)}
title={entry.color}
role="button"
tabIndex={0}
onKeyDown={(e) => {
if (e.key === 'Enter' || e.key === ' ') {
setColor(entry.color);
}
}}
feat: implement UX enhancements for playground Add comprehensive UX improvements to color playground: **URL State Sharing:** - Implement URL parameter sync for colors - Add share button to copy playground URLs - Wrap in Suspense boundary for Next.js 16 compatibility - Colors persist in URL for easy sharing **Keyboard Shortcuts:** - Create reusable useKeyboard hook with modifier support - Add Cmd/Ctrl+C to copy current color - Add Cmd/Ctrl+S to share color URL - Add Cmd/Ctrl+R for random color generation - Display keyboard hints in playground header - Cross-platform support (Mac/Windows/Linux) **Color History:** - Implement Zustand store with localStorage persistence - Track up to 50 most recent colors with timestamps - Auto-deduplicate and keep most recent entry - Add visual history grid in playground - Click to restore previous colors - Individual color removal with hover UI - Clear all history option **Playground UI Enhancements:** - Add visual keyboard shortcut indicators (⌘C, ⌘S, ⌘R) - Implement Recent Colors section with 5-column grid - Add hover effects for history color swatches - Individual remove buttons on hover - Toast notifications for all actions - Improved button layout and spacing **Files Added:** - lib/hooks/useKeyboard.ts - Keyboard shortcut management - lib/stores/historyStore.ts - Color history with persistence **Files Modified:** - app/playground/page.tsx - Integrated all UX features Successfully builds with all features working. Ready for user testing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 12:30:33 +01:00
>
<div className="absolute inset-0 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity bg-black/30 rounded-lg">
<button
onClick={(e) => {
e.stopPropagation();
removeColor(entry.color);
toast.success('Color removed from history');
}}
className="p-1 bg-destructive rounded-full hover:bg-destructive/80"
aria-label="Remove color"
feat: implement UX enhancements for playground Add comprehensive UX improvements to color playground: **URL State Sharing:** - Implement URL parameter sync for colors - Add share button to copy playground URLs - Wrap in Suspense boundary for Next.js 16 compatibility - Colors persist in URL for easy sharing **Keyboard Shortcuts:** - Create reusable useKeyboard hook with modifier support - Add Cmd/Ctrl+C to copy current color - Add Cmd/Ctrl+S to share color URL - Add Cmd/Ctrl+R for random color generation - Display keyboard hints in playground header - Cross-platform support (Mac/Windows/Linux) **Color History:** - Implement Zustand store with localStorage persistence - Track up to 50 most recent colors with timestamps - Auto-deduplicate and keep most recent entry - Add visual history grid in playground - Click to restore previous colors - Individual color removal with hover UI - Clear all history option **Playground UI Enhancements:** - Add visual keyboard shortcut indicators (⌘C, ⌘S, ⌘R) - Implement Recent Colors section with 5-column grid - Add hover effects for history color swatches - Individual remove buttons on hover - Toast notifications for all actions - Improved button layout and spacing **Files Added:** - lib/hooks/useKeyboard.ts - Keyboard shortcut management - lib/stores/historyStore.ts - Color history with persistence **Files Modified:** - app/playground/page.tsx - Integrated all UX features Successfully builds with all features working. Ready for user testing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 12:30:33 +01:00
>
<X className="h-3 w-3 text-destructive-foreground" />
</button>
</div>
</div>
feat: implement UX enhancements for playground Add comprehensive UX improvements to color playground: **URL State Sharing:** - Implement URL parameter sync for colors - Add share button to copy playground URLs - Wrap in Suspense boundary for Next.js 16 compatibility - Colors persist in URL for easy sharing **Keyboard Shortcuts:** - Create reusable useKeyboard hook with modifier support - Add Cmd/Ctrl+C to copy current color - Add Cmd/Ctrl+S to share color URL - Add Cmd/Ctrl+R for random color generation - Display keyboard hints in playground header - Cross-platform support (Mac/Windows/Linux) **Color History:** - Implement Zustand store with localStorage persistence - Track up to 50 most recent colors with timestamps - Auto-deduplicate and keep most recent entry - Add visual history grid in playground - Click to restore previous colors - Individual color removal with hover UI - Clear all history option **Playground UI Enhancements:** - Add visual keyboard shortcut indicators (⌘C, ⌘S, ⌘R) - Implement Recent Colors section with 5-column grid - Add hover effects for history color swatches - Individual remove buttons on hover - Toast notifications for all actions - Improved button layout and spacing **Files Added:** - lib/hooks/useKeyboard.ts - Keyboard shortcut management - lib/stores/historyStore.ts - Color history with persistence **Files Modified:** - app/playground/page.tsx - Integrated all UX features Successfully builds with all features working. Ready for user testing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 12:30:33 +01:00
))}
</div>
</div>
)}
feat: implement color playground with interactive picker and info display Add complete color manipulation interface: **Color Components:** - ColorPicker - Interactive hex color picker with text input - Uses react-colorful for visual selection - Manual input support for any color format - Real-time updates - ColorDisplay - Large color preview swatch - Configurable sizes (sm, md, lg, xl) - Optional border styling - Accessible with ARIA labels - ColorInfo - Comprehensive color information display - Shows all formats: Hex, RGB, HSL, Lab, OkLab - Copy to clipboard functionality for each format - Displays brightness, luminance, light/dark type - Shows named color matches **API Integration:** - React Query hooks for all Pastel API endpoints - useColorInfo - Get color information - useConvertFormat - Format conversion - useLighten, useDarken, useSaturate, etc. - Manipulations - useGenerateRandom, useGenerateDistinct, useGenerateGradient - useNamedColors - Cached named colors list - Automatic error handling and loading states **Playground Page (/playground):** - Two-column layout: picker + info - Live color preview with large swatch - Real-time API integration with loading states - Error handling with user-friendly messages - Quick action buttons (ready for implementation) - Responsive grid layout **Features:** - Toast notifications for clipboard copy - Loading spinners during API calls - Error display with helpful messages - Accessible keyboard navigation - Smooth transitions and animations Build successful with playground page rendering! Ready for color manipulation actions. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 11:05:23 +01:00
</div>
{/* Right Column: Color Information */}
<div className="space-y-6">
<div className="p-6 border rounded-lg bg-card">
<h2 className="text-xl font-semibold mb-4">Color Information</h2>
{isLoading && (
<div className="flex items-center justify-center py-12">
<Loader2 className="h-8 w-8 animate-spin text-muted-foreground" />
</div>
)}
{isError && (
<div className="p-4 bg-destructive/10 text-destructive rounded-lg">
<p className="font-medium">Error loading color information</p>
<p className="text-sm mt-1">{error?.message || 'Unknown error'}</p>
</div>
)}
{colorInfo && <ColorInfo info={colorInfo} />}
</div>
<div className="p-6 border rounded-lg bg-card">
feat: implement color manipulation tools with interactive sliders Add complete color manipulation interface to playground: **New Components:** - Slider component - Customizable range input with label and value display - Smooth animations on thumb hover - Keyboard accessible - Shows current value with optional suffix - Tailwind-styled for consistency - ManipulationPanel component - Full color manipulation controls - Lighten/Darken sliders (0-100% range) - Saturate/Desaturate sliders (0-100% range) - Hue rotation slider (-180° to +180°) - Complementary color quick action - All operations integrated with Pastel API - Toast notifications for success/error - Loading states during API calls **Playground Enhancements:** - Replaced placeholder quick action buttons with ManipulationPanel - Full integration with color manipulation mutations - Real-time color updates after each operation - User-friendly feedback with toast messages - Amount controls for precise adjustments **Features:** - Live preview of manipulation results - Configurable amounts before applying - Success/error handling with helpful messages - Disabled state during API operations - Smooth user experience with immediate feedback **API Integration:** - useLighten, useDarken mutations - useSaturate, useDesaturate mutations - useRotate for hue rotation - useComplement for complementary colors - All mutations with proper error handling Build successful! Color manipulation tools fully functional. Next: Navigation, theme system, and additional UI components. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 11:28:35 +01:00
<h2 className="text-xl font-semibold mb-4">Color Manipulation</h2>
<ManipulationPanel color={color} onColorChange={setColor} />
feat: implement color playground with interactive picker and info display Add complete color manipulation interface: **Color Components:** - ColorPicker - Interactive hex color picker with text input - Uses react-colorful for visual selection - Manual input support for any color format - Real-time updates - ColorDisplay - Large color preview swatch - Configurable sizes (sm, md, lg, xl) - Optional border styling - Accessible with ARIA labels - ColorInfo - Comprehensive color information display - Shows all formats: Hex, RGB, HSL, Lab, OkLab - Copy to clipboard functionality for each format - Displays brightness, luminance, light/dark type - Shows named color matches **API Integration:** - React Query hooks for all Pastel API endpoints - useColorInfo - Get color information - useConvertFormat - Format conversion - useLighten, useDarken, useSaturate, etc. - Manipulations - useGenerateRandom, useGenerateDistinct, useGenerateGradient - useNamedColors - Cached named colors list - Automatic error handling and loading states **Playground Page (/playground):** - Two-column layout: picker + info - Live color preview with large swatch - Real-time API integration with loading states - Error handling with user-friendly messages - Quick action buttons (ready for implementation) - Responsive grid layout **Features:** - Toast notifications for clipboard copy - Loading spinners during API calls - Error display with helpful messages - Accessible keyboard navigation - Smooth transitions and animations Build successful with playground page rendering! Ready for color manipulation actions. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 11:05:23 +01:00
</div>
</div>
</div>
</div>
</div>
);
}
feat: implement UX enhancements for playground Add comprehensive UX improvements to color playground: **URL State Sharing:** - Implement URL parameter sync for colors - Add share button to copy playground URLs - Wrap in Suspense boundary for Next.js 16 compatibility - Colors persist in URL for easy sharing **Keyboard Shortcuts:** - Create reusable useKeyboard hook with modifier support - Add Cmd/Ctrl+C to copy current color - Add Cmd/Ctrl+S to share color URL - Add Cmd/Ctrl+R for random color generation - Display keyboard hints in playground header - Cross-platform support (Mac/Windows/Linux) **Color History:** - Implement Zustand store with localStorage persistence - Track up to 50 most recent colors with timestamps - Auto-deduplicate and keep most recent entry - Add visual history grid in playground - Click to restore previous colors - Individual color removal with hover UI - Clear all history option **Playground UI Enhancements:** - Add visual keyboard shortcut indicators (⌘C, ⌘S, ⌘R) - Implement Recent Colors section with 5-column grid - Add hover effects for history color swatches - Individual remove buttons on hover - Toast notifications for all actions - Improved button layout and spacing **Files Added:** - lib/hooks/useKeyboard.ts - Keyboard shortcut management - lib/stores/historyStore.ts - Color history with persistence **Files Modified:** - app/playground/page.tsx - Integrated all UX features Successfully builds with all features working. Ready for user testing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 12:30:33 +01:00
export default function PlaygroundPage() {
return (
<Suspense fallback={
<div className="min-h-screen px-8 py-12">
feat: implement UX enhancements for playground Add comprehensive UX improvements to color playground: **URL State Sharing:** - Implement URL parameter sync for colors - Add share button to copy playground URLs - Wrap in Suspense boundary for Next.js 16 compatibility - Colors persist in URL for easy sharing **Keyboard Shortcuts:** - Create reusable useKeyboard hook with modifier support - Add Cmd/Ctrl+C to copy current color - Add Cmd/Ctrl+S to share color URL - Add Cmd/Ctrl+R for random color generation - Display keyboard hints in playground header - Cross-platform support (Mac/Windows/Linux) **Color History:** - Implement Zustand store with localStorage persistence - Track up to 50 most recent colors with timestamps - Auto-deduplicate and keep most recent entry - Add visual history grid in playground - Click to restore previous colors - Individual color removal with hover UI - Clear all history option **Playground UI Enhancements:** - Add visual keyboard shortcut indicators (⌘C, ⌘S, ⌘R) - Implement Recent Colors section with 5-column grid - Add hover effects for history color swatches - Individual remove buttons on hover - Toast notifications for all actions - Improved button layout and spacing **Files Added:** - lib/hooks/useKeyboard.ts - Keyboard shortcut management - lib/stores/historyStore.ts - Color history with persistence **Files Modified:** - app/playground/page.tsx - Integrated all UX features Successfully builds with all features working. Ready for user testing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 12:30:33 +01:00
<div className="max-w-7xl mx-auto flex items-center justify-center">
<Loader2 className="h-8 w-8 animate-spin text-muted-foreground" />
</div>
</div>
}>
<PlaygroundContent />
</Suspense>
);
}