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

96 lines
3.2 KiB
TypeScript
Raw Normal View History

import React, { useEffect } from "react";
2022-11-23 19:24:30 +01:00
2022-12-16 17:20:46 +01:00
const ImageOptions = ({
zoomAmount,
setZoomAmount,
2022-12-21 16:43:54 +01:00
resetImagePaths,
2022-12-24 08:40:45 +01:00
hideZoomOptions,
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 16:43:54 +01:00
resetImagePaths: () => void;
2022-12-24 08:40:45 +01:00
hideZoomOptions?: boolean;
2022-12-16 17:20:46 +01:00
}) => {
useEffect(() => {
if (!localStorage.getItem("zoomAmount")) {
localStorage.setItem("zoomAmount", zoomAmount);
} else {
setZoomAmount(localStorage.getItem("zoomAmount"));
2022-12-16 17:20:46 +01:00
}
}, []);
2022-12-16 17:20:46 +01:00
2022-11-23 19:24:30 +01:00
return (
2022-12-27 12:08:49 +01:00
<div className="animate rounded-btn collapse absolute top-1 z-50 m-2">
2022-11-23 19:24:30 +01:00
<input type="checkbox" className="peer" />
2022-12-27 12:08:49 +01:00
<div className="outline-title peer-checked:outline-title-none collapse-title bg-opacity-25 text-center text-sm font-semibold uppercase text-slate-900 backdrop-blur-2xl peer-checked:bg-base-300 peer-checked:text-base-content">
2022-11-23 19:24:30 +01:00
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">
2022-12-21 16:43:54 +01:00
<button className="btn-primary btn" onClick={resetImagePaths}>
Reset Image
</button>
2022-12-24 08:40:45 +01:00
{!hideZoomOptions && (
<div className="flex flex-row items-center gap-2">
<p className="w-20">Zoom:</p>
<button
className={`btn-primary btn ${
zoomAmount === "100%" ? "btn-secondary" : "btn-primary"
}`}
onClick={() => {
setZoomAmount("100%");
localStorage.setItem("zoomAmount", "100%");
}}>
100%
</button>
<button
className={`btn-primary btn ${
zoomAmount === "125%" ? "btn-secondary" : "btn-primary"
}`}
onClick={() => {
setZoomAmount("125%");
localStorage.setItem("zoomAmount", "125%");
}}>
125%
</button>
<button
className={`btn-primary btn ${
zoomAmount === "150%" ? "btn-secondary" : "btn-primary"
}`}
onClick={() => {
setZoomAmount("150%");
localStorage.setItem("zoomAmount", "150%");
}}>
150%
</button>
<button
className={`btn-primary btn ${
zoomAmount === "175%" ? "btn-secondary" : "btn-primary"
}`}
onClick={() => {
setZoomAmount("175%");
localStorage.setItem("zoomAmount", "175%");
}}>
175%
</button>
<button
className={`btn-primary btn ${
zoomAmount === "200%" ? "btn-secondary" : "btn-primary"
}`}
onClick={() => {
setZoomAmount("200%");
localStorage.setItem("zoomAmount", "200%");
}}>
200%
</button>
</div>
)}
2022-11-23 19:24:30 +01:00
</div>
</div>
</div>
);
};
export default ImageOptions;