1
0
mirror of https://github.com/upscayl/upscayl.git synced 2024-12-01 10:37:17 +01:00
upscayl/renderer/components/ImageOptions.tsx

91 lines
3.1 KiB
TypeScript
Raw Normal View History

2022-11-23 19:24:30 +01:00
import React from "react";
2022-12-16 17:20:46 +01:00
const ImageOptions = ({
zoomAmount,
setZoomAmount,
2022-12-21 11:32:45 +01:00
leftImageRef,
rightImageRef,
2022-12-16 17:20:46 +01:00
}: {
2022-12-21 11:32:45 +01:00
zoomAmount: string;
2022-12-16 17:20:46 +01:00
setZoomAmount: (arg: any) => void;
2022-12-21 11:32:45 +01:00
leftImageRef: React.RefObject<HTMLImageElement>;
rightImageRef: React.RefObject<HTMLImageElement>;
2022-12-16 17:20:46 +01:00
}) => {
2022-12-17 18:28:48 +01:00
const [zoomLevel, setZoomLevel] = React.useState("125");
2022-12-16 17:20:46 +01:00
const handleZoom = (direction: number) => {
if (direction === 0) {
setZoomAmount("");
2022-12-17 18:28:48 +01:00
setZoomLevel("100");
console.log("🚀 => file: ImageOptions.tsx:24 => zoomLevel", zoomLevel);
} else if (direction === 1 && zoomLevel < "200") {
setZoomLevel((parseInt(zoomLevel) + direction * 25).toString());
setZoomAmount("zoom-" + zoomLevel);
console.log("🚀 => file: ImageOptions.tsx:24 => zoomLevel", zoomLevel);
} else if (direction === -1 && zoomLevel > "100") {
setZoomLevel((parseInt(zoomLevel) + direction * 25).toString());
setZoomAmount("zoom-" + zoomLevel);
console.log("🚀 => file: ImageOptions.tsx:24 => zoomLevel", zoomLevel);
}
if (zoomLevel > "200" || zoomLevel < "100") {
setZoomAmount("100");
2022-12-16 17:20:46 +01:00
}
};
2022-11-23 19:24:30 +01:00
return (
2022-12-16 17:20:46 +01:00
<div className="animate rounded-btn collapse absolute top-0 z-50 m-2 opacity-25 hover:opacity-100">
2022-11-23 19:24:30 +01:00
<input type="checkbox" className="peer" />
<div className="collapse-title bg-base-100 text-center text-sm font-semibold uppercase text-primary-content peer-checked:bg-base-300 peer-checked:text-base-content">
Show/Hide Image Settings
</div>
<div className="collapse-content bg-base-100 text-base-content">
2022-12-16 17:20:46 +01:00
<div className="flex max-h-96 flex-col justify-center gap-5 overflow-auto p-5">
<button className="btn-primary btn">Reset Image</button>
<div className="flex flex-row items-center gap-2">
<p className="w-20">Zoom:</p>
2022-12-17 18:28:48 +01:00
<button
2022-12-21 11:32:45 +01:00
className={`btn-primary btn ${
zoomAmount === "100%" ? "btn-secondary" : "btn-primary"
}`}
onClick={() => setZoomAmount("100%")}>
2022-12-16 17:20:46 +01:00
100%
</button>
2022-12-17 18:28:48 +01:00
<button
2022-12-21 11:32:45 +01:00
className={`btn-primary btn ${
zoomAmount === "125%" ? "btn-secondary" : "btn-primary"
}`}
onClick={() => setZoomAmount("125%")}>
125%
</button>
<button
className={`btn-primary btn ${
zoomAmount === "150%" ? "btn-secondary" : "btn-primary"
}`}
onClick={() => setZoomAmount("150%")}>
150%
</button>
<button
className={`btn-primary btn ${
zoomAmount === "175%" ? "btn-secondary" : "btn-primary"
}`}
onClick={() => setZoomAmount("175%")}>
175%
</button>
<button
className={`btn-primary btn ${
zoomAmount === "200%" ? "btn-secondary" : "btn-primary"
}`}
onClick={() => setZoomAmount("200%")}>
200%
2022-12-16 17:20:46 +01:00
</button>
</div>
2022-11-23 19:24:30 +01:00
</div>
</div>
</div>
);
};
export default ImageOptions;