feat: remove colorspace option from pastel gradients (not supported by API)
This commit is contained in:
@@ -6,7 +6,6 @@ import { PaletteGrid } from '@/components/pastel/color/PaletteGrid';
|
|||||||
import { ExportMenu } from '@/components/pastel/tools/ExportMenu';
|
import { ExportMenu } from '@/components/pastel/tools/ExportMenu';
|
||||||
import { Button } from '@/components/ui/Button';
|
import { Button } from '@/components/ui/Button';
|
||||||
import { Input } from '@/components/ui/Input';
|
import { Input } from '@/components/ui/Input';
|
||||||
import { Select } from '@/components/ui/Select';
|
|
||||||
import { useGenerateGradient } from '@/lib/pastel/api/queries';
|
import { useGenerateGradient } from '@/lib/pastel/api/queries';
|
||||||
import { Loader2, Plus, X } from 'lucide-react';
|
import { Loader2, Plus, X } from 'lucide-react';
|
||||||
import { toast } from 'sonner';
|
import { toast } from 'sonner';
|
||||||
@@ -14,9 +13,6 @@ import { toast } from 'sonner';
|
|||||||
export default function GradientPage() {
|
export default function GradientPage() {
|
||||||
const [stops, setStops] = useState<string[]>(['#ff0099', '#0099ff']);
|
const [stops, setStops] = useState<string[]>(['#ff0099', '#0099ff']);
|
||||||
const [count, setCount] = useState(10);
|
const [count, setCount] = useState(10);
|
||||||
const [colorspace, setColorspace] = useState<
|
|
||||||
'rgb' | 'hsl' | 'hsv' | 'lab' | 'oklab' | 'lch' | 'oklch'
|
|
||||||
>('lch');
|
|
||||||
const [gradient, setGradient] = useState<string[]>([]);
|
const [gradient, setGradient] = useState<string[]>([]);
|
||||||
|
|
||||||
const generateMutation = useGenerateGradient();
|
const generateMutation = useGenerateGradient();
|
||||||
@@ -26,7 +22,6 @@ export default function GradientPage() {
|
|||||||
const result = await generateMutation.mutateAsync({
|
const result = await generateMutation.mutateAsync({
|
||||||
stops,
|
stops,
|
||||||
count,
|
count,
|
||||||
colorspace,
|
|
||||||
});
|
});
|
||||||
setGradient(result.gradient);
|
setGradient(result.gradient);
|
||||||
toast.success(`Generated ${result.gradient.length} colors`);
|
toast.success(`Generated ${result.gradient.length} colors`);
|
||||||
@@ -111,31 +106,6 @@ export default function GradientPage() {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Select
|
|
||||||
label="Color Space"
|
|
||||||
value={colorspace}
|
|
||||||
onChange={(e) =>
|
|
||||||
setColorspace(
|
|
||||||
e.target.value as
|
|
||||||
| 'rgb'
|
|
||||||
| 'hsl'
|
|
||||||
| 'hsv'
|
|
||||||
| 'lab'
|
|
||||||
| 'oklab'
|
|
||||||
| 'lch'
|
|
||||||
| 'oklch'
|
|
||||||
)
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<option value="rgb">RGB</option>
|
|
||||||
<option value="hsl">HSL</option>
|
|
||||||
<option value="hsv">HSV</option>
|
|
||||||
<option value="lab">Lab</option>
|
|
||||||
<option value="oklab">OkLab</option>
|
|
||||||
<option value="lch">LCH</option>
|
|
||||||
<option value="oklch">OkLCH (Recommended)</option>
|
|
||||||
</Select>
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
onClick={handleGenerate}
|
onClick={handleGenerate}
|
||||||
disabled={generateMutation.isPending || stops.length < 2}
|
disabled={generateMutation.isPending || stops.length < 2}
|
||||||
|
|||||||
@@ -125,7 +125,6 @@ export interface ColorManipulationData {
|
|||||||
export interface ColorMixRequest {
|
export interface ColorMixRequest {
|
||||||
colors: string[];
|
colors: string[];
|
||||||
fraction: number;
|
fraction: number;
|
||||||
colorspace?: 'rgb' | 'hsl' | 'hsv' | 'lab' | 'oklab' | 'lch' | 'oklch';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ColorMixData {
|
export interface ColorMixData {
|
||||||
@@ -163,13 +162,11 @@ export interface DistinctColorsData {
|
|||||||
export interface GradientRequest {
|
export interface GradientRequest {
|
||||||
stops: string[];
|
stops: string[];
|
||||||
count: number;
|
count: number;
|
||||||
colorspace?: 'rgb' | 'hsl' | 'hsv' | 'lab' | 'oklab' | 'lch' | 'oklch';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GradientData {
|
export interface GradientData {
|
||||||
stops: string[];
|
stops: string[];
|
||||||
count: number;
|
count: number;
|
||||||
colorspace: string;
|
|
||||||
gradient: string[];
|
gradient: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -313,7 +313,6 @@ export class PastelWASMClient {
|
|||||||
return {
|
return {
|
||||||
stops: request.stops,
|
stops: request.stops,
|
||||||
count: request.count,
|
count: request.count,
|
||||||
colorspace: request.colorspace || 'rgb',
|
|
||||||
gradient,
|
gradient,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -336,7 +335,6 @@ export class PastelWASMClient {
|
|||||||
return {
|
return {
|
||||||
stops: request.stops,
|
stops: request.stops,
|
||||||
count: request.count,
|
count: request.count,
|
||||||
colorspace: request.colorspace || 'rgb',
|
|
||||||
gradient,
|
gradient,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@@ -458,7 +456,6 @@ export class PastelWASMClient {
|
|||||||
'colors/names',
|
'colors/names',
|
||||||
],
|
],
|
||||||
formats: ['hex', 'rgb', 'hsl', 'hsv', 'lab', 'lch'],
|
formats: ['hex', 'rgb', 'hsl', 'hsv', 'lab', 'lch'],
|
||||||
color_spaces: ['rgb', 'hsl', 'hsv', 'lab', 'lch'],
|
|
||||||
distance_metrics: ['cie76', 'ciede2000'],
|
distance_metrics: ['cie76', 'ciede2000'],
|
||||||
colorblindness_types: ['protanopia', 'deuteranopia', 'tritanopia'],
|
colorblindness_types: ['protanopia', 'deuteranopia', 'tritanopia'],
|
||||||
}));
|
}));
|
||||||
|
|||||||
Reference in New Issue
Block a user