1
0
mirror of https://github.com/upscayl/upscayl.git synced 2024-12-23 21:05:06 +01:00
upscayl/renderer/components/settings-tab/ImageScaleSelect.tsx

69 lines
1.9 KiB
TypeScript
Raw Normal View History

2024-04-20 17:44:42 +02:00
import { useCustomWidthAtom } from "@/atoms/userSettingsAtom";
2024-04-21 19:27:16 +02:00
import { useAtom, 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-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">
Image Scale <span className="text-xs">({scale}X)</span>
</p>
{hideInfo && parseInt(scale) >= 6 && (
<p
className="badge badge-warning text-xs font-bold"
data-tooltip-id="tooltip"
data-tooltip-content="Anything above 5X may cause performance issues on some devices!"
>
!
</p>
)}
</>
) : (
<p className="text-sm font-medium">
IMAGE SCALE ({scale}X) {useCustomWidth && "DISABLED"}
</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">
Anything above 4X (except 16X Double Upscayl) only resizes the image
and does not use AI upscaling.
</p>
)}
{!hideInfo && parseInt(scale) >= 6 && (
<p className="text-xs text-base-content/80 text-red-500">
This may cause performance issues on some devices!
</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>
);
}