1
0
mirror of https://github.com/upscayl/upscayl.git synced 2024-12-18 18:35:58 +01:00
upscayl/renderer/components/sidebar/settings-tab/select-image-scale.tsx

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 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
};
export function SelectImageScale({
2024-04-21 19:27:16 +02:00
scale,
setScale,
hideInfo,
}: ImageScaleSelectProps) {
const useCustomWidth = useAtomValue(useCustomWidthAtom);
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">
{t("SETTINGS.IMAGE_SCALE.TITLE")}{" "}
<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"
data-tooltip-content={t("SETTINGS.IMAGE_SCALE.WARNING")}
2024-04-21 19:27:16 +02:00
>
!
</p>
)}
</>
) : (
<p className="text-sm font-medium">
{t("SETTINGS.IMAGE_SCALE.TITLE")} ({scale}X){" "}
{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">
{t("SETTINGS.IMAGE_SCALE.DESCRIPTION")}
2024-04-21 19:27:16 +02:00
</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 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"
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>
);
}