Commit Graph

9 Commits

Author SHA1 Message Date
5a20e12ea4 feat(phase-13): implement auto-save system with localStorage
Add comprehensive auto-save functionality to prevent data loss.

Features:
- Auto-save every 30 seconds
- Saves all layers with canvas data
- Preserves layer masks
- Saves layer properties (visibility, opacity, blend mode, etc.)
- Toast notification on restore
- Utility functions for managing auto-save:
  * hasAutoSave() - Check if auto-save exists
  * loadAutoSave() - Restore from auto-save
  * clearAutoSave() - Clear saved data
  * getAutoSaveTime() - Get save timestamp
- Converts canvas to data URLs for storage
- Restores canvas from data URLs
- Handles errors gracefully

Changes:
- Created hooks/use-auto-save.ts
- useAutoSave() hook for periodic saving
- Saves project structure to localStorage
- Auto-save key: 'paint-ui-autosave'
- 30-second save interval
- Includes timestamp for restore info

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 20:15:49 +01:00
54aac626a2 feat: add Import Image functionality to add images as new layers
Implements image import feature that adds images as new layers without clearing existing work:

**New Import Image Function** (`hooks/use-file-operations.ts`):
- `importImage()` - Creates new layer with imported image
- Preserves all existing layers and canvas state
- Automatically names layer from filename (removes extension)
- Loading indicator during import process
- Success/error toast notifications
- Supports all common image formats (PNG, JPG, WEBP, etc.)

**File Menu Integration** (`components/editor/file-menu.tsx`):
- Added "Import Image..." menu item with ImagePlus icon
- Positioned after "Open..." for logical flow
- Separate file input for import (only accepts images)
- Import handler with file input reset
- Keyboard accessible with proper ARIA roles

**Key Differences from Open:**
- **Open** - Replaces entire canvas (clears all layers, resets dimensions)
- **Import** - Adds image as new layer (preserves existing work)

**User Experience:**
- File > Import Image... opens native file picker
- Only image files accepted (image/*)
- Import creates layer with image dimensions
- Layer positioned at origin (0, 0)
- Can import multiple images as separate layers
- Works alongside existing drag & drop functionality

**Use Cases:**
- Adding reference images to canvas
- Building collages from multiple images
- Importing assets without losing current work
- Layer-based compositing workflows

All functionality tested and working with no build errors.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 18:31:28 +01:00
513b865b1f feat(mobile): add touch gesture support for mobile devices
Added comprehensive touch support for mobile/tablet usage:

Touch Gestures Hook:
- Created useTouchGestures hook for pinch-to-zoom and two-finger pan
- Handles multi-touch events with distance calculation
- Integrated with canvas store for zoom and pan state
- Prevents default touch behaviors (pull-to-refresh, page scroll)

Features:
- Pinch-to-zoom: Two-finger pinch gesture for zoom in/out
- Two-finger pan: Pan canvas with two fingers
- Touch drawing: Single touch works for all drawing tools (pointer events already supported)
- Min/max zoom limits (0.1x - 32x)
- Smooth gesture handling with distance thresholds

UI Improvements:
- Added touch-action: none CSS to prevent default touch behaviors
- Added touch-none Tailwind class for better touch handling
- Canvas container properly handles touch events

Mobile Experience:
- Drawing tools work with single touch
- Zoom/pan gestures feel natural
- No interference with browser touch behaviors
- Optimized for tablets and touch-enabled devices

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 16:48:19 +01:00
7f4d574c64 feat(tools): implement advanced brush tools - Clone Stamp, Smudge, and Dodge/Burn
Added three professional-grade image manipulation tools to complete Feature 4:

Clone Stamp Tool (Shortcut: 8)
- Sample from source location with Alt+Click
- Paint sampled content to destination
- Maintains relative offset for natural cloning
- Supports soft/hard brush with hardness setting

Smudge Tool (Shortcut: 9)
- Creates realistic paint-smearing effects
- Progressively blends colors for natural smudging
- Uses flow setting to control smudge strength
- Soft brush falloff for smooth blending

Dodge/Burn Tool (Shortcut: 0)
- Dodge mode: Lightens image areas (default)
- Burn mode: Darkens image areas (Alt key)
- Professional photography exposure adjustment
- Respects hardness setting for precise control

All tools:
- Fully integrated with tool palette and keyboard shortcuts
- Support smooth interpolation for fluid strokes
- Use existing tool settings (size, opacity, hardness, flow, spacing)
- Lazy-loaded via code splitting system
- Icons from Lucide React (Stamp, Droplet, Sun)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 16:27:02 +01:00
2e18f43453 feat(ui/perf): implement loading states, keyboard navigation, and lazy-loaded tools
Add comprehensive UX and performance improvements:

**Loading States & Feedback:**
- Add loading overlay with spinner and custom messages
- Integrate loading states into all file operations (open, save, export)
- Create loading-store.ts for centralized loading state management

**Keyboard Navigation:**
- Expand keyboard shortcuts to include tool selection (1-7)
- Add layer navigation with Arrow Up/Down
- Add layer operations (Ctrl+D duplicate, Delete/Backspace remove)
- Display keyboard shortcuts in tool tooltips
- Enhanced keyboard shortcut system with proper key conflict handling

**Performance - Code Splitting:**
- Implement dynamic tool loader with lazy loading
- Tools load on-demand when first selected
- Preload common tools (pencil, brush, eraser) for instant access
- Add tool caching to prevent redundant loads
- Reduces initial bundle size and improves startup time

**Integration:**
- Add LoadingOverlay to app layout
- Update canvas-with-tools to use lazy-loaded tool instances
- Add keyboard shortcut hints to tool palette UI

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 16:08:24 +01:00
3ad7dbf314 feat(ui): implement comprehensive toast notification system
Added a complete toast notification system with:
- Toast store using Zustand for state management
- Toast component with 4 types: success, error, warning, info
- Animated slide-in/slide-out transitions
- Auto-dismiss after configurable duration
- Close button on each toast
- Utility functions for easy access (toast.success(), toast.error(), etc.)

Integrated toast notifications into file operations:
- Success notifications for: open image, open project, export image, save project
- Error notifications for: failed operations
- Warning notifications for: unsupported file types

UI Features:
- Stacks toasts in top-right corner
- Color-coded by type with icons (CheckCircle, AlertCircle, AlertTriangle, Info)
- Accessible with ARIA attributes
- Smooth animations using custom CSS keyframes

This provides immediate user feedback for all major operations throughout
the application.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 15:42:50 +01:00
924c10a3e4 feat(phase-7): implement comprehensive effects & filters system
This commit completes Phase 7 of the paint-ui implementation, adding a
complete filters and effects system with live preview capabilities.

**New Files:**
- types/filter.ts: Filter types, parameters, and state interfaces
- lib/filter-utils.ts: Core filter algorithms and image processing functions
- core/commands/filter-command.ts: Undo/redo support for filters
- store/filter-store.ts: Filter state management with Zustand
- hooks/use-filter-preview.ts: Real-time filter preview system
- components/filters/filter-panel.tsx: Complete filter UI with parameters
- components/filters/index.ts: Filters barrel export

**Updated Files:**
- components/editor/editor-layout.tsx: Integrated FilterPanel into layout
- store/index.ts: Added filter-store export
- types/index.ts: Added filter types export

**Implemented Filters:**

**Adjustment Filters (with parameters):**
-  Brightness (-100 to +100): Linear brightness adjustment
-  Contrast (-100 to +100): Contrast curve adjustment
-  Hue/Saturation/Lightness: Full HSL color manipulation
  - Hue: -180° to +180° rotation
  - Saturation: -100% to +100% adjustment
  - Lightness: -100% to +100% adjustment

**Effect Filters (with parameters):**
-  Gaussian Blur (1-50px): Separable kernel blur with proper edge handling
-  Sharpen (0-100%): Unsharp mask algorithm
-  Threshold (0-255): Binary threshold conversion
-  Posterize (2-256 levels): Color quantization

**One-Click Filters (no parameters):**
-  Invert: Color inversion
-  Grayscale: Luminosity-based desaturation
-  Sepia: Classic sepia tone effect

**Technical Features:**
- Real-time preview system with toggle control
- Non-destructive preview (restores original on cancel)
- Undo/redo integration via FilterCommand
- Efficient image processing with typed arrays
- HSL/RGB color space conversions
- Separable Gaussian blur for performance
- Proper clamping and edge case handling
- Layer-aware filtering (respects locked layers)

**UI/UX Features:**
- 264px wide filter panel with all filters listed
- Dynamic parameter controls based on selected filter
- Live preview toggle with visual feedback
- Apply/Cancel actions with proper state cleanup
- Disabled state when no unlocked layer selected
- Clear parameter labels and value display

**Algorithm Implementations:**
- Brightness: Linear RGB adjustment with clamping
- Contrast: Standard contrast curve (factor-based)
- Hue/Saturation: Full RGB↔HSL conversion with proper hue rotation
- Blur: Separable Gaussian kernel (horizontal + vertical passes)
- Sharpen: Convolution kernel with configurable amount
- Threshold: Luminosity-based binary conversion
- Posterize: Color quantization with configurable levels

Build verified: ✓ Compiled successfully in 1248ms

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 02:12:18 +01:00
b93ae377d0 feat(phase-6): implement comprehensive file operations system
This commit completes Phase 6 of the paint-ui implementation, adding full
file import/export capabilities with drag-drop and clipboard support.

**New Files:**
- lib/file-utils.ts: Core file operations (open, save, export, project format)
- hooks/use-file-operations.ts: React hook for file operations
- hooks/use-drag-drop.ts: Drag & drop state management
- hooks/use-clipboard.ts: Clipboard paste event handling
- components/editor/file-menu.tsx: File menu dropdown component
- components/modals/export-dialog.tsx: Export dialog with format/quality options
- components/modals/new-image-dialog.tsx: New image dialog with presets
- components/modals/index.ts: Modals barrel export

**Updated Files:**
- components/editor/editor-layout.tsx: Integrated FileMenu, drag-drop overlay, clipboard paste
- components/editor/index.ts: Added file-menu export

**Features:**
-  Create new images with dimension presets (Full HD, HD, 800x600, custom)
-  Open image files (PNG, JPG, WEBP) as new layers
-  Save/load .paint project files (JSON with base64 layer data)
-  Export as PNG/JPEG/WEBP with quality control
-  Drag & drop file upload with visual overlay
-  Clipboard paste support (Ctrl+V)
-  File type validation and error handling
-  DataTransfer API integration for unified file handling

**Project File Format (.paint):**
- JSON structure with version, dimensions, layer metadata
- Base64-encoded PNG data for each layer
- Preserves layer properties (opacity, blend mode, order, visibility)

Build verified: ✓ Compiled successfully in 1233ms

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 02:06:49 +01:00
4f5c78df30 feat: implement Phase 3 - History & Undo System with command pattern
Complete undo/redo functionality with robust command pattern architecture:

**Command Pattern Infrastructure (core/commands/)**
- BaseCommand: Abstract class for all undoable operations
- Command merging support for consecutive similar operations
- Timestamp tracking for intelligent merging

**Layer Commands**
- CreateLayerCommand: Create layer with full undo support
- DeleteLayerCommand: Delete with restoration of original position
- UpdateLayerCommand: Property updates with auto-merging (1s window)
- DuplicateLayerCommand: Duplicate with full canvas cloning
- ReorderLayerCommand: Z-order changes with bidirectional support
- MergeLayerDownCommand: Merge with canvas state preservation

**History Store (store/history-store.ts)**
- Dual stack architecture (undo/redo)
- Maximum 50 commands with automatic pruning
- Execution guard to prevent recursion
- Command merging for reduced history bloat
- Full state inspection (canUndo, canRedo, getHistorySummary)

**Layer Operations Wrapper (lib/layer-operations.ts)**
- History-enabled wrappers for all layer operations
- Drop-in replacements for direct store calls
- Automatic command creation and execution

**Keyboard Shortcuts (hooks/use-keyboard-shortcuts.ts)**
- Ctrl+Z / Cmd+Z: Undo
- Ctrl+Shift+Z / Cmd+Shift+Z: Redo
- Ctrl+Y / Cmd+Y: Redo (alternative)
- Input field detection (no interference with text editing)
- Platform-aware display strings (⌘ on Mac, Ctrl on Windows/Linux)

**UI Components**
- History Panel: Visual undo/redo stack
  - Shows all commands with timestamps
  - Current state indicator
  - Undone commands shown with reduced opacity
  - Command counter (undoable/redoable)

- Editor Toolbar: Undo/Redo buttons
  - Disabled state when stack is empty
  - Tooltip with keyboard shortcuts
  - Visual feedback on hover

- Layers Panel: History-integrated actions
  - Duplicate layer button (with history)
  - Delete layer (with confirmation and history)
  - Toggle visibility (with history)
  - Prevents deleting last layer

**Integration**
- All layer operations now support undo/redo
- Initial background layer creation bypasses history
- New layers created via UI add to history
- Keyboard shortcuts active globally (except in inputs)

**Performance**
- Command merging reduces memory usage
- Efficient canvas cloning for layer restoration
- No memory leaks with proper cleanup
- Dev server: 451ms startup (unchanged)

**Type Safety**
- Command interface with execute/undo/merge
- HistoryState interface for store
- Full TypeScript coverage

Ready for Phase 4: Drawing Tools implementation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 21:24:59 +01:00