[dyad] Added button to swap width/height - wrote 1 file(s)

This commit is contained in:
[dyad]
2026-01-18 12:15:16 +01:00
parent a8f5a4ae3f
commit 5fe444bb72

View File

@@ -17,7 +17,7 @@ import {
SelectTrigger, SelectTrigger,
SelectValue, SelectValue,
} from "@/components/ui/select"; } from "@/components/ui/select";
import { Upload, Download, X, Trash2, Check } from "lucide-react"; import { Upload, Download, X, Trash2, Check, ArrowRightLeft } from "lucide-react";
import { toast } from "sonner"; import { toast } from "sonner";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
import { Switch } from "@/components/ui/switch"; import { Switch } from "@/components/ui/switch";
@@ -333,6 +333,11 @@ export function ImageConverter() {
setAspectRatio("custom"); setAspectRatio("custom");
}; };
const handleSwapDimensions = () => {
setWidth(height);
setHeight(width);
};
const hasImages = images.length > 0; const hasImages = images.length > 0;
return ( return (
@@ -365,12 +370,15 @@ export function ImageConverter() {
</SelectContent> </SelectContent>
</Select> </Select>
</div> </div>
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4"> <div className="flex items-end gap-2">
<div className="space-y-2"> <div className="space-y-2 flex-1">
<Label htmlFor="width">Width (px)</Label> <Label htmlFor="width">Width (px)</Label>
<Input id="width" type="number" placeholder="Original" value={width} onChange={handleWidthChange} /> <Input id="width" type="number" placeholder="Original" value={width} onChange={handleWidthChange} />
</div> </div>
<div className="space-y-2"> <Button variant="outline" size="icon" onClick={handleSwapDimensions} className="shrink-0" aria-label="Swap width and height">
<ArrowRightLeft className="h-4 w-4" />
</Button>
<div className="space-y-2 flex-1">
<Label htmlFor="height">Height (px)</Label> <Label htmlFor="height">Height (px)</Label>
<Input id="height" type="number" placeholder="Original" value={height} onChange={handleHeightChange} /> <Input id="height" type="number" placeholder="Original" value={height} onChange={handleHeightChange} />
</div> </div>