1
0
mirror of https://github.com/upscayl/upscayl.git synced 2025-02-03 13:13:32 +01:00

72 lines
2.0 KiB
TypeScript
Raw Normal View History

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