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/input-custom-resolution.tsx
NayamAmarshe 95843ded88
Refactor Renderer Code (#987)
* Initial refactor

* Remove unused imports

* Update code

* Refactor and Update Code

- Change file names to kebab-caase
- Add new useTranslation Hook
- Change useLog hook name to useLogger
- Update translation hook to provide autocomplete

* Update import and component name

* Rename files and components

* Update locales

* Update electron commands

* Update var

* Change Lowercase

* Replace filter with map

* Add props

* Update flag check

* Add validate paths

* Update formats

* Update import

* Update function

* Update function and translation

* Update handlePaste
2024-10-04 14:45:54 +05:30

59 lines
1.8 KiB
TypeScript

import {
customWidthAtom,
useCustomWidthAtom,
} from "@/atoms/user-settings-atom";
import { useAtom, useAtomValue } from "jotai";
import React from "react";
import { translationAtom } from "@/atoms/translations-atom";
export function InputCustomResolution() {
const [useCustomWidth, setUseCustomWidth] = useAtom(useCustomWidthAtom);
const [customWidth, setCustomWidth] = useAtom(customWidthAtom);
const t = useAtomValue(translationAtom);
return (
<div>
<div className="flex flex-col gap-1">
<p className="text-sm font-medium">
{t("SETTINGS.CUSTOM_INPUT_RESOLUTION.TITLE")}
</p>
<p className="text-xs text-base-content/80">
<b>{t("SETTINGS.CUSTOM_INPUT_RESOLUTION.RESTART")}</b>
<br />
{t("SETTINGS.CUSTOM_INPUT_RESOLUTION.DESCRIPTION")}
</p>
</div>
<div className="mt-2 flex items-center gap-2">
<input
type="checkbox"
className="toggle"
checked={useCustomWidth}
onClick={(e) => {
if (!e.currentTarget.checked) {
localStorage.removeItem("customWidth");
}
setUseCustomWidth(!useCustomWidth);
}}
/>
<input
type="number"
value={customWidth}
disabled={!useCustomWidth}
onChange={(e) => {
if (e.currentTarget.value === "") {
setUseCustomWidth(false);
setCustomWidth(null);
localStorage.removeItem("customWidth");
return;
}
setCustomWidth(parseInt(e.currentTarget.value));
}}
step="1"
min="1"
className="input input-primary h-7 w-32 [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none"
/>
</div>
</div>
);
}