1
0
mirror of https://github.com/upscayl/upscayl.git synced 2024-12-12 15:51:06 +01:00
upscayl/renderer/components/upscayl-tab/view/ImageOptions.tsx

115 lines
3.9 KiB
TypeScript
Raw Normal View History

2024-01-21 07:48:22 +01:00
import SidebarClosed from "@/components/icons/SidebarClosed";
import SidebarOpened from "@/components/icons/SidebarOpened";
import React, { useEffect, useState } 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
}) => {
2024-01-21 07:48:22 +01:00
const [openSidebar, setOpenSidebar] = useState(false);
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 (
2024-01-21 07:48:22 +01:00
<div className="">
{/* <div
className={`bg-base-100 p-4 rounded-btn rounded-r-none fixed top-1/2 right-0 z-50 shadow-xl shadow-black group flex items-center gap-2`}
onClick={() => setOpenSidebar(!openSidebar)}>
<Sidebar className="text-white text-xl" />
</div> */}
2022-11-23 19:24:30 +01:00
2024-01-21 07:48:22 +01:00
<div
className={`transition-all duration-500 bg-base-100 text-base-content h-screen w-[28rem] fixed right-0 top-0 z-50 shadow-xl shadow-black ${
openSidebar ? "right-0" : "-right-full translate-x-full"
}`}>
<div
className={`transition-all duration-500 bg-base-100 p-4 rounded-btn rounded-r-none absolute top-1/2 right-[100%] z-50 cursor-pointer flex items-center group gap-2`}
onClick={() => {
setOpenSidebar(!openSidebar);
}}>
{openSidebar ? (
<SidebarOpened className="text-white text-xl" />
) : (
<SidebarClosed className="text-white text-xl" />
)}
</div>
<div className="flex 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;