2024-04-20 17:44:42 +02:00
|
|
|
import { customWidthAtom, useCustomWidthAtom } from "@/atoms/userSettingsAtom";
|
2024-09-01 14:01:45 +02:00
|
|
|
import { useAtom, useAtomValue } from "jotai";
|
|
|
|
import React from "react";
|
|
|
|
import { translationAtom } from "@/atoms/translations-atom";
|
2024-04-20 17:44:42 +02:00
|
|
|
|
|
|
|
export function CustomResolutionInput() {
|
|
|
|
const [useCustomWidth, setUseCustomWidth] = useAtom(useCustomWidthAtom);
|
|
|
|
const [customWidth, setCustomWidth] = useAtom(customWidthAtom);
|
2024-09-01 14:01:45 +02:00
|
|
|
const t = useAtomValue(translationAtom);
|
2024-04-20 17:44:42 +02:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<div className="flex flex-col gap-1">
|
2024-09-01 14:01:45 +02:00
|
|
|
<p className="text-sm font-medium">
|
|
|
|
{t("APP.INFOS.CUSTOM_INPUT_RESOLUTION.WIDTH")}
|
|
|
|
</p>
|
2024-04-20 17:44:42 +02:00
|
|
|
<p className="text-xs text-base-content/80">
|
2024-09-01 14:01:45 +02:00
|
|
|
<b>{t("APP.INFOS.CUSTOM_INPUT_RESOLUTION.RESTART")}</b>
|
2024-04-20 17:44:42 +02:00
|
|
|
<br />
|
2024-09-01 14:01:45 +02:00
|
|
|
{t("APP.INFOS.CUSTOM_INPUT_RESOLUTION.CUSTOM_WIDTH_TIP")}
|
2024-04-20 17:44:42 +02:00
|
|
|
</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>
|
|
|
|
);
|
|
|
|
}
|