fix: correct API integration and complete missing features

Fix API response format mismatches and implement all remaining features:

**API Integration Fixes:**
- Fix ManipulationPanel to use `colors` instead of `results` from API responses
- Fix gradient endpoint to use `gradient` array from API response
- Fix color blindness simulator to use correct field names (`input`/`output` vs `original`/`simulated`)
- Fix text color optimizer request field (`backgrounds` vs `background_colors`)
- Fix method name casing: `simulateColorBlindness` (capital B)
- Add palette generation endpoint integration

**Type Definition Updates:**
- Update GradientData to match API structure with `gradient` array
- Update ColorBlindnessData to use `colors` with `input`/`output`/`difference_percentage`
- Update TextColorData to use `colors` with `textcolor`/`wcag_aa`/`wcag_aaa` fields
- Add PaletteGenerateRequest and PaletteGenerateData types

**Completed Features:**
- Harmony Palettes: Now uses dedicated `/palettes/generate` API endpoint
  - Simplified from 80 lines of manual color theory to single API call
  - Supports 6 harmony types: monochromatic, analogous, complementary, split-complementary, triadic, tetradic
- Text Color Optimizer: Full implementation with WCAG compliance checking
  - Automatic black/white text color selection
  - Live preview with contrast ratios
  - AA/AAA compliance indicators
- Color Blindness Simulator: Fixed and working
  - Shows difference percentage for each simulation
  - Side-by-side comparison view
- Gradient Creator: Fixed to use correct API response structure
- Batch Operations: Fixed to extract output colors correctly

**UI Improvements:**
- Enable all accessibility tool cards (remove "Coming Soon" badges)
- Enable harmony palettes card
- Add safety check for gradient state to prevent undefined errors

All features now fully functional and properly integrated with Pastel API.

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
valknarness
2025-11-07 14:33:38 +01:00
parent cb3fcdd806
commit 93889ab9bd
11 changed files with 314 additions and 112 deletions

View File

@@ -38,8 +38,8 @@ export function ManipulationPanel({ color, onColorChange }: ManipulationPanelPro
colors: [color],
amount: lightenAmount,
});
if (result.results[0]) {
onColorChange(result.results[0].output);
if (result.colors[0]) {
onColorChange(result.colors[0].output);
toast.success(`Lightened by ${(lightenAmount * 100).toFixed(0)}%`);
}
} catch (error) {
@@ -53,8 +53,8 @@ export function ManipulationPanel({ color, onColorChange }: ManipulationPanelPro
colors: [color],
amount: darkenAmount,
});
if (result.results[0]) {
onColorChange(result.results[0].output);
if (result.colors[0]) {
onColorChange(result.colors[0].output);
toast.success(`Darkened by ${(darkenAmount * 100).toFixed(0)}%`);
}
} catch (error) {
@@ -68,8 +68,8 @@ export function ManipulationPanel({ color, onColorChange }: ManipulationPanelPro
colors: [color],
amount: saturateAmount,
});
if (result.results[0]) {
onColorChange(result.results[0].output);
if (result.colors[0]) {
onColorChange(result.colors[0].output);
toast.success(`Saturated by ${(saturateAmount * 100).toFixed(0)}%`);
}
} catch (error) {
@@ -83,8 +83,8 @@ export function ManipulationPanel({ color, onColorChange }: ManipulationPanelPro
colors: [color],
amount: desaturateAmount,
});
if (result.results[0]) {
onColorChange(result.results[0].output);
if (result.colors[0]) {
onColorChange(result.colors[0].output);
toast.success(`Desaturated by ${(desaturateAmount * 100).toFixed(0)}%`);
}
} catch (error) {
@@ -98,8 +98,8 @@ export function ManipulationPanel({ color, onColorChange }: ManipulationPanelPro
colors: [color],
amount: rotateAmount,
});
if (result.results[0]) {
onColorChange(result.results[0].output);
if (result.colors[0]) {
onColorChange(result.colors[0].output);
toast.success(`Rotated hue by ${rotateAmount}°`);
}
} catch (error) {
@@ -110,8 +110,8 @@ export function ManipulationPanel({ color, onColorChange }: ManipulationPanelPro
const handleComplement = async () => {
try {
const result = await complementMutation.mutateAsync([color]);
if (result.results[0]) {
onColorChange(result.results[0].output);
if (result.colors[0]) {
onColorChange(result.colors[0].output);
toast.success('Generated complementary color');
}
} catch (error) {