1
0
mirror of https://github.com/upscayl/upscayl.git synced 2024-12-01 02:27:16 +01:00
upscayl/renderer/components/LeftPaneSteps.jsx

132 lines
5.0 KiB
React
Raw Normal View History

2022-08-31 17:25:26 +02:00
import React from "react";
2022-09-08 08:52:00 +02:00
import ReactTooltip from "react-tooltip";
2022-08-31 17:25:26 +02:00
function LeftPaneSteps(props) {
2022-09-08 08:52:00 +02:00
const handleBatchMode = () => {
props.setBatchMode((oldValue) => !oldValue);
};
2022-08-31 17:25:26 +02:00
return (
2022-09-08 08:52:00 +02:00
<div className="animate-step-in animate flex h-screen flex-col gap-7 overflow-auto p-5">
{/* BATCH OPTION */}
<div className="flex flex-row items-end">
<p
2022-09-19 13:14:40 +02:00
className="mr-1 inline-block cursor-help text-sm text-white/70"
2022-09-08 08:52:00 +02:00
data-tip="This will let you upscale all files in a folder at once"
2022-08-31 17:25:26 +02:00
>
2022-09-08 08:52:00 +02:00
Batch Upscale:
</p>
2022-09-19 20:05:29 +02:00
<button
className={`animate relative inline-block h-5 w-8 cursor-pointer rounded-full outline-none focus-visible:shadow-lg focus-visible:shadow-purple-500 ${
props.batchMode ? "bg-gradient-purple" : "bg-neutral-500"
2022-09-08 08:52:00 +02:00
}`}
onClick={handleBatchMode}
2022-08-31 17:25:26 +02:00
>
2022-09-08 08:52:00 +02:00
<div
className={`${
2022-09-19 20:05:29 +02:00
props.batchMode ? "translate-x-4" : "translate-x-1"
2022-09-08 08:52:00 +02:00
} animate absolute top-1/2 h-3 w-3 -translate-y-1/2 rounded-full bg-neutral-100`}
></div>
2022-09-19 20:05:29 +02:00
</button>
2022-08-31 17:25:26 +02:00
</div>
2022-09-19 01:54:45 +02:00
{/* STEP 1 */}
<div data-tip={props.imagePath}>
2022-09-19 13:14:40 +02:00
<p className="step-heading">Step 1</p>
2022-09-19 01:54:45 +02:00
<button
2022-09-19 20:05:29 +02:00
className="animate bg-gradient-red rounded-lg p-3 font-medium text-white/90 outline-none transition-colors focus-visible:shadow-lg focus-visible:shadow-red-500"
2022-09-19 01:54:45 +02:00
onClick={
!props.batchMode
? props.selectImageHandler
: props.selectFolderHandler
}
>
Select {props.batchMode ? "Folder" : "Image"}
</button>
</div>
2022-08-31 17:25:26 +02:00
2022-09-19 01:54:45 +02:00
{/* STEP 2 */}
<div className="animate-step-in">
2022-09-19 13:14:40 +02:00
<p className="step-heading">Step 2</p>
<p className="mb-2 text-sm text-white/60">Select Upscaling Type</p>
<select
name="select-model"
onDrop={(e) => props.handleDrop(e)}
2022-09-25 13:15:43 +02:00
className="animate bg-gradient-white block cursor-pointer rounded-lg p-3 font-medium text-black/90 outline-none hover:bg-slate-200 focus-visible:ring-2 focus-visible:ring-slate-400"
2022-09-19 13:14:40 +02:00
onChange={props.handleModelChange}
>
<option value="realesrgan-x4plus">General Photo</option>
<option value="realesrgan-x4plus-anime">Digital Art</option>
<option value="models-DF2K">Sharpen Image</option>
</select>
2022-09-19 01:54:45 +02:00
{props.model !== "models-DF2K" && !props.batchMode && (
2022-09-19 13:14:40 +02:00
<div className="mt-2 flex items-center gap-1">
2022-09-19 01:54:45 +02:00
<input
type="checkbox"
2022-09-19 20:05:29 +02:00
className="checked:bg-gradient-white h-4 w-4 cursor-pointer appearance-none rounded-full bg-white/30 transition duration-200 focus:outline-none focus-visible:border focus-visible:shadow-lg focus-visible:shadow-white/40"
2022-09-19 01:54:45 +02:00
checked={props.doubleUpscayl}
onChange={(e) => {
if (e.target.checked) {
props.setDoubleUpscayl(true);
} else {
props.setDoubleUpscayl(false);
}
}}
/>
<p
2022-09-19 13:14:40 +02:00
className={`inline-block cursor-pointer select-none rounded-full text-sm font-medium ${
2022-09-19 01:54:45 +02:00
props.doubleUpscayl
? "bg-gradient-white px-2 text-black/90"
2022-09-19 13:14:40 +02:00
: "text-white/50"
2022-09-19 01:54:45 +02:00
}`}
onClick={(e) => {
props.setDoubleUpscayl(!props.doubleUpscayl);
}}
2022-09-08 08:52:00 +02:00
>
2022-09-19 01:54:45 +02:00
Double Upscayl
2022-09-08 08:52:00 +02:00
</p>
2022-09-19 13:14:40 +02:00
<span
className="cursor-help rounded-full bg-white/20 px-3 text-center font-bold text-white/40"
data-tip="Enable this option to get an 8x upscayl. Note that this may not always work properly with all images, for example, images with really large resolutions."
>
i
</span>
2022-09-08 08:52:00 +02:00
</div>
2022-09-19 01:54:45 +02:00
)}
</div>
2022-09-08 08:52:00 +02:00
2022-09-19 01:54:45 +02:00
{/* STEP 3 */}
<div className="animate-step-in" data-tip={props.outputPath}>
2022-09-19 13:14:40 +02:00
<p className="step-heading">Step 3</p>
<p className="mb-2 text-sm text-white/60">Defaults to Image's path</p>
2022-09-19 01:54:45 +02:00
<button
2022-09-19 20:05:29 +02:00
className="animate bg-gradient mt-1 rounded-lg p-3 font-medium text-black/90 outline-none transition-colors focus-visible:shadow-lg focus-visible:shadow-green-500"
2022-09-19 01:54:45 +02:00
onClick={props.outputHandler}
>
Set Output Folder
</button>
</div>
2022-09-08 08:52:00 +02:00
2022-09-19 01:54:45 +02:00
{/* STEP 4 */}
<div className="animate-step-in">
2022-09-19 13:14:40 +02:00
<p className="step-heading">Step 4</p>
2022-09-19 01:54:45 +02:00
<button
2022-09-19 20:05:29 +02:00
className="animate bg-gradient-upscayl rounded-lg p-3 font-medium text-white/90 outline-none transition-colors focus-visible:shadow-lg focus-visible:shadow-violet-500"
2022-09-19 01:54:45 +02:00
onClick={props.upscaylHandler}
disabled={props.progress.length > 0}
>
{props.progress.length > 0 ? "Upscayling⏳" : "Upscayl"}
</button>
</div>
2022-09-08 08:52:00 +02:00
<ReactTooltip
2022-09-19 13:14:40 +02:00
className="max-w-md break-words bg-neutral-900 text-neutral-50"
2022-09-08 08:52:00 +02:00
place="top"
/>
2022-08-31 17:25:26 +02:00
</div>
);
}
export default LeftPaneSteps;