2024-09-01 14:01:45 +02:00
|
|
|
import { translationAtom } from "@/atoms/translations-atom";
|
2024-01-23 09:44:32 +01:00
|
|
|
import { lensSizeAtom, viewTypeAtom } from "@/atoms/userSettingsAtom";
|
2024-04-17 18:18:45 +02:00
|
|
|
import { cn } from "@/lib/utils";
|
2024-09-01 14:01:45 +02:00
|
|
|
import { useAtom, useAtomValue } from "jotai";
|
2024-04-24 22:00:08 +02:00
|
|
|
import { WrenchIcon } from "lucide-react";
|
2024-04-01 11:04:56 +02:00
|
|
|
import { 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);
|
2024-01-23 09:44:32 +01:00
|
|
|
const [viewType, setViewType] = useAtom(viewTypeAtom);
|
|
|
|
const [lensSize, setLensSize] = useAtom(lensSizeAtom);
|
2024-09-01 14:01:45 +02:00
|
|
|
const t = useAtomValue(translationAtom);
|
2024-01-21 07:48:22 +01:00
|
|
|
|
2022-12-21 17:24:13 +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-21 17:24:13 +01:00
|
|
|
}, []);
|
2022-12-16 17:20:46 +01:00
|
|
|
|
2022-11-23 19:24:30 +01:00
|
|
|
return (
|
2024-01-23 09:44:32 +01:00
|
|
|
<div
|
|
|
|
onDoubleClick={(e) => {
|
|
|
|
e.stopPropagation();
|
|
|
|
}}
|
2024-04-17 18:18:45 +02:00
|
|
|
className={`fixed right-0 top-0 z-50 h-screen w-[28rem] bg-base-100 text-base-content shadow-xl shadow-base-300 transition-all duration-500 ${
|
|
|
|
openSidebar ? "right-0" : "-right-full translate-x-full"
|
|
|
|
}`}
|
2024-04-01 11:04:56 +02:00
|
|
|
>
|
2024-01-21 07:48:22 +01:00
|
|
|
<div
|
2024-04-24 22:00:08 +02:00
|
|
|
className={`group absolute right-[100%] top-1/2 z-50 flex cursor-pointer items-center gap-2 rounded-btn rounded-r-none bg-base-100 p-4 transition-all duration-500`}
|
2024-04-17 18:18:45 +02:00
|
|
|
onClick={() => {
|
|
|
|
setOpenSidebar(!openSidebar);
|
|
|
|
}}
|
2024-04-01 11:04:56 +02:00
|
|
|
>
|
2024-04-17 18:18:45 +02:00
|
|
|
<WrenchIcon
|
|
|
|
className={cn(
|
|
|
|
"animate text-xl text-base-content",
|
|
|
|
openSidebar ? "rotate-180" : "rotate-0",
|
2024-01-21 07:48:22 +01:00
|
|
|
)}
|
2024-04-17 18:18:45 +02:00
|
|
|
/>
|
|
|
|
</div>
|
2024-01-23 09:44:32 +01:00
|
|
|
|
2024-04-17 18:18:45 +02:00
|
|
|
<div className="flex flex-col justify-center gap-5 overflow-auto p-5">
|
|
|
|
<button className="btn btn-primary" onClick={resetImagePaths}>
|
2024-09-03 09:34:58 +02:00
|
|
|
{t("APP.IMAGE_OPTIONS.RESET_BUTTON_TITLE")}
|
2024-04-17 18:18:45 +02:00
|
|
|
</button>
|
2024-01-23 09:54:08 +01:00
|
|
|
|
2024-04-17 18:18:45 +02:00
|
|
|
<div className="flex flex-row items-center gap-2">
|
2024-09-01 14:01:45 +02:00
|
|
|
<p className="text-sm font-medium">
|
2024-09-03 09:34:58 +02:00
|
|
|
{t("APP.IMAGE_OPTIONS.LENS_VIEW_TITLE")}
|
2024-09-01 14:01:45 +02:00
|
|
|
</p>
|
2024-04-17 18:18:45 +02:00
|
|
|
<input
|
|
|
|
type="checkbox"
|
|
|
|
className="toggle"
|
|
|
|
checked={viewType === "slider"}
|
|
|
|
onChange={(e) => {
|
|
|
|
setViewType(e.target.checked ? "slider" : "lens");
|
|
|
|
}}
|
|
|
|
/>
|
2024-09-01 14:01:45 +02:00
|
|
|
<p className="text-sm font-medium">
|
2024-09-03 09:34:58 +02:00
|
|
|
{t("APP.IMAGE_OPTIONS.SLIDER_VIEW_TITLE")}
|
2024-09-01 14:01:45 +02:00
|
|
|
</p>
|
2024-04-17 18:18:45 +02:00
|
|
|
</div>
|
2024-01-23 09:54:08 +01:00
|
|
|
|
2024-04-17 18:18:45 +02:00
|
|
|
<div className="flex flex-col gap-2">
|
2024-09-01 14:01:45 +02:00
|
|
|
<p className="text-sm font-medium">
|
2024-09-03 09:34:58 +02:00
|
|
|
{t("APP.IMAGE_OPTIONS.ZOOM_AMOUNT_TITLE")} ({zoomAmount}%)
|
2024-09-01 14:01:45 +02:00
|
|
|
</p>
|
2024-04-17 18:18:45 +02:00
|
|
|
<input
|
|
|
|
type="range"
|
|
|
|
min="100"
|
|
|
|
max="1000"
|
|
|
|
step={10}
|
|
|
|
className="range range-md"
|
|
|
|
value={parseInt(zoomAmount)}
|
|
|
|
onChange={(e) => {
|
|
|
|
setZoomAmount(e.target.value);
|
|
|
|
localStorage.setItem("zoomAmount", e.target.value);
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</div>
|
2024-01-23 09:44:32 +01:00
|
|
|
|
2024-04-17 18:18:45 +02:00
|
|
|
<div className="flex flex-col gap-2">
|
2024-09-01 14:01:45 +02:00
|
|
|
<p className="text-sm font-medium">
|
2024-09-03 09:34:58 +02:00
|
|
|
{t("APP.IMAGE_OPTIONS.LENS_SIZE_TITLE")} ({lensSize / 10})
|
2024-09-01 14:01:45 +02:00
|
|
|
</p>
|
2024-04-17 18:18:45 +02:00
|
|
|
<input
|
|
|
|
type="range"
|
|
|
|
min="20"
|
|
|
|
max="400"
|
|
|
|
step={10}
|
|
|
|
className="range range-md"
|
|
|
|
value={lensSize}
|
|
|
|
onChange={(e) => {
|
|
|
|
setLensSize(parseInt(e.target.value));
|
|
|
|
}}
|
|
|
|
/>
|
2022-11-23 19:24:30 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default ImageOptions;
|