2024-09-01 14:01:45 +02:00
|
|
|
import { translationAtom } from "@/atoms/translations-atom";
|
2024-04-20 17:44:42 +02:00
|
|
|
import { useCustomWidthAtom } from "@/atoms/userSettingsAtom";
|
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-04-21 19:27:16 +02:00
|
|
|
export function ImageScaleSelect({
|
|
|
|
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-01 14:01:45 +02:00
|
|
|
{t("APP.INFOS.IMAGE_SCALE.TITLE")}{" "}
|
|
|
|
<span className="text-xs">
|
|
|
|
{t("APP.INFOS.IMAGE_SCALE.SCALES_TIMES", {
|
|
|
|
scale,
|
|
|
|
})}
|
|
|
|
</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-01 14:01:45 +02:00
|
|
|
data-tooltip-content={t(
|
|
|
|
"APP.ERRORS.IMAGE_SCALE_WARN.PERF_ISSUE",
|
|
|
|
)}
|
2024-04-21 19:27:16 +02:00
|
|
|
>
|
|
|
|
!
|
|
|
|
</p>
|
|
|
|
)}
|
|
|
|
</>
|
|
|
|
) : (
|
|
|
|
<p className="text-sm font-medium">
|
2024-09-01 14:01:45 +02:00
|
|
|
{t("APP.INFOS.IMAGE_SCALE.TITLE_CAPS")}{" "}
|
|
|
|
{t("APP.INFOS.IMAGE_SCALE.SCALES_TIMES", {
|
|
|
|
scale,
|
|
|
|
})}{" "}
|
|
|
|
{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-01 14:01:45 +02:00
|
|
|
{t("APP.INFOS.IMAGE_SCALE.AI_UPSCALE_RESIZE_INFO")}
|
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-01 14:01:45 +02:00
|
|
|
{t("APP.ERRORS.IMAGE_SCALE_WARN.PERF_ISSUE_DEVICE")}
|
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>
|
|
|
|
);
|
|
|
|
}
|