2024-09-01 14:01:45 +02:00
|
|
|
import { translationAtom } from "@/atoms/translations-atom";
|
2024-10-04 11:15:54 +02:00
|
|
|
import { useCustomWidthAtom } from "@/atoms/user-settings-atom";
|
2024-09-01 14:01:45 +02:00
|
|
|
import { useAtomValue } from "jotai";
|
2024-04-20 17:44:42 +02:00
|
|
|
|
2023-07-22 13:07:53 +02:00
|
|
|
type ImageScaleSelectProps = {
|
2024-04-21 19:27:16 +02:00
|
|
|
scale: string;
|
|
|
|
setScale: React.Dispatch<React.SetStateAction<string>>;
|
|
|
|
hideInfo?: boolean;
|
2023-07-22 13:07:53 +02:00
|
|
|
};
|
|
|
|
|
2024-10-04 11:15:54 +02:00
|
|
|
export function SelectImageScale({
|
2024-04-21 19:27:16 +02:00
|
|
|
scale,
|
|
|
|
setScale,
|
|
|
|
hideInfo,
|
|
|
|
}: ImageScaleSelectProps) {
|
|
|
|
const useCustomWidth = useAtomValue(useCustomWidthAtom);
|
2024-09-01 14:01:45 +02:00
|
|
|
const t = useAtomValue(translationAtom);
|
2024-04-20 17:44:42 +02:00
|
|
|
|
2023-07-22 13:07:53 +02:00
|
|
|
return (
|
2024-04-20 17:44:42 +02:00
|
|
|
<div className={`${useCustomWidth && "opacity-50"}`}>
|
2023-07-22 13:07:53 +02:00
|
|
|
<div className="flex flex-row gap-1">
|
2024-04-21 19:27:16 +02:00
|
|
|
{hideInfo ? (
|
|
|
|
<>
|
|
|
|
<p className="text-sm">
|
2024-09-03 09:34:58 +02:00
|
|
|
{t("SETTINGS.IMAGE_SCALE.TITLE")}{" "}
|
2024-09-05 06:51:30 +02:00
|
|
|
<span className="text-xs">({scale}X)</span>
|
2024-04-21 19:27:16 +02:00
|
|
|
</p>
|
|
|
|
{hideInfo && parseInt(scale) >= 6 && (
|
|
|
|
<p
|
|
|
|
className="badge badge-warning text-xs font-bold"
|
|
|
|
data-tooltip-id="tooltip"
|
2024-09-03 09:34:58 +02:00
|
|
|
data-tooltip-content={t("SETTINGS.IMAGE_SCALE.WARNING")}
|
2024-04-21 19:27:16 +02:00
|
|
|
>
|
|
|
|
!
|
|
|
|
</p>
|
|
|
|
)}
|
|
|
|
</>
|
|
|
|
) : (
|
|
|
|
<p className="text-sm font-medium">
|
2024-09-05 06:51:30 +02:00
|
|
|
{t("SETTINGS.IMAGE_SCALE.TITLE")} ({scale}X){" "}
|
2024-09-01 14:01:45 +02:00
|
|
|
{useCustomWidth && "DISABLED"}
|
2024-04-21 19:27:16 +02:00
|
|
|
</p>
|
|
|
|
)}
|
2023-07-22 13:07:53 +02:00
|
|
|
</div>
|
2024-04-21 19:27:16 +02:00
|
|
|
{!hideInfo && (
|
|
|
|
<p className="text-xs text-base-content/80">
|
2024-09-03 09:34:58 +02:00
|
|
|
{t("SETTINGS.IMAGE_SCALE.DESCRIPTION")}
|
2024-04-21 19:27:16 +02:00
|
|
|
</p>
|
|
|
|
)}
|
|
|
|
{!hideInfo && parseInt(scale) >= 6 && (
|
2024-04-21 19:14:39 +02:00
|
|
|
<p className="text-xs text-base-content/80 text-red-500">
|
2024-09-03 09:34:58 +02:00
|
|
|
{t("SETTINGS.IMAGE_SCALE.ADDITIONAL_WARNING")}
|
2024-04-21 19:14:39 +02:00
|
|
|
</p>
|
|
|
|
)}
|
2024-04-21 19:27:16 +02:00
|
|
|
|
2023-07-22 13:07:53 +02:00
|
|
|
<input
|
|
|
|
type="range"
|
2023-07-23 08:32:22 +02:00
|
|
|
min="1"
|
2024-04-09 20:21:54 +02:00
|
|
|
max="16"
|
2024-04-21 19:14:39 +02:00
|
|
|
placeholder="Example: 1320"
|
2023-07-22 13:07:53 +02:00
|
|
|
value={scale}
|
|
|
|
onChange={(e: any) => {
|
|
|
|
setScale(e.target.value.toString());
|
|
|
|
}}
|
|
|
|
step="1"
|
|
|
|
className="range range-primary mt-2"
|
2024-04-20 17:44:42 +02:00
|
|
|
disabled={useCustomWidth}
|
2023-07-22 13:07:53 +02:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|