Localize bare switcher and add button

This commit is contained in:
Riftriot 2024-01-04 14:31:52 -06:00
parent 5c632642d4
commit 6c6c6626cf
6 changed files with 38 additions and 16 deletions

1
.env Normal file
View file

@ -0,0 +1 @@
test=TESTTTT

View file

@ -52,11 +52,13 @@
}, },
"bare": { "bare": {
"title": "Bare Server", "title": "Bare Server",
"subtitle": "Enter the URL of your bare server" "subtitle": "Enter the URL of your bare server",
"select": "Select"
}, },
"theme": { "theme": {
"title": "Theme", "title": "Theme",
"subtitle": "Choose a theme so your eyes don't hate us" "subtitle": "Choose a theme so your eyes don't hate us",
"select": "Select"
} }
}, },
"titles": { "titles": {

View file

@ -50,6 +50,11 @@
"title": "Buscador", "title": "Buscador",
"subtitle": "Elige tu motor de búsqueda." "subtitle": "Elige tu motor de búsqueda."
}, },
"bare": {
"title": "Bare Server",
"subtitle": "Pon tu url de tu bare server",
"select": "Seleccionar"
},
"theme": { "theme": {
"title": "Mirar", "title": "Mirar",
"subtitle": "Elige una mirada para que tus ojos no nos odienn" "subtitle": "Elige una mirada para que tus ojos no nos odienn"

View file

@ -50,6 +50,11 @@
"title": "検索エンジン", "title": "検索エンジン",
"subtitle": "ネビュラの検索エンジンを選択してください" "subtitle": "ネビュラの検索エンジンを選択してください"
}, },
"bare": {
"title": "Bare サーバー",
"subtitle": "Bare サーバー URL を入力してください",
"select": "選択する"
},
"theme": { "theme": {
"title": "テーマ", "title": "テーマ",
"subtitle": "目が嫌いにならないようにテーマを選んでください" "subtitle": "目が嫌いにならないようにテーマを選んでください"

View file

@ -1,6 +1,7 @@
import { useState, useEffect } from "preact/hooks"; import { useState, useEffect } from "preact/hooks";
import { set } from "../../util/IDB"; import { set } from "../../util/IDB";
import { uninstallServiceWorkers } from "../../util/SWHelper"; import { uninstallServiceWorkers } from "../../util/SWHelper";
import { useTranslation } from "react-i18next";
interface BareInputProps { interface BareInputProps {
placeholder: string; placeholder: string;
@ -8,6 +9,7 @@ interface BareInputProps {
} }
function BareInput(props: BareInputProps) { function BareInput(props: BareInputProps) {
const { t } = useTranslation();
const value = localStorage.getItem(props.storageKey) || "/bare/"; const value = localStorage.getItem(props.storageKey) || "/bare/";
const [inputValue, setInputValue] = useState(value); const [inputValue, setInputValue] = useState(value);
function validateUrl(url: string) { function validateUrl(url: string) {
@ -28,22 +30,29 @@ function BareInput(props: BareInputProps) {
} }
return finalUrl; return finalUrl;
} }
function handleChange(event: any) { function handleChange() {
const url = validateUrl(event.target.value); const url = validateUrl((document.getElementById("input") as HTMLInputElement).value);
setInputValue(event.target.value); setInputValue((document.getElementById("input") as HTMLInputElement).value);
set(props.storageKey, url); set(props.storageKey, url);
localStorage.setItem(props.storageKey, url); localStorage.setItem(props.storageKey, url);
uninstallServiceWorkers(); uninstallServiceWorkers();
window.location.reload(); window.location.reload();
} }
return ( return (
<input <div className="flex flex-col items-center">
type="text" <input
placeholder={props.placeholder} type="text"
value={inputValue} placeholder={props.placeholder}
onBlur={handleChange} value={inputValue}
className="font-roboto flex h-14 w-56 flex-row rounded-2xl border border-input-border-color bg-input p-4 text-center text-xl" id="input"
/> className="font-roboto flex h-14 w-56 flex-row rounded-2xl border border-input-border-color bg-input p-4 text-center text-xl"
/>
<div className="font-roboto items-center justify-center flex h-4 w-24 flex-row rounded-2xl border border-input-border-color bg-input p-4 text-center text-xl"
onClick={handleChange}
>
{t("settings.bare.select")}
</div>
</div>
); );
} }

View file

@ -39,7 +39,7 @@ const Proxy = ({ id, active }) => {
variants={settingsPageVariant} variants={settingsPageVariant}
className="content-card flex w-full flex-row flex-wrap justify-center gap-4" className="content-card flex w-full flex-row flex-wrap justify-center gap-4"
> >
<div className="flex h-64 w-80 flex-col flex-wrap content-center items-center rounded-lg border border-input-border-color bg-lighter p-7 text-center"> <div className="flex h-64 w-80 flex-col flex-wrap content-center items-center rounded-lg border border-input-border-color bg-lighter p-4 text-center">
<div className="p-2 text-3xl font-bold text-input-text"> <div className="p-2 text-3xl font-bold text-input-text">
{t("settings.proxy.title")} {t("settings.proxy.title")}
</div> </div>
@ -48,7 +48,7 @@ const Proxy = ({ id, active }) => {
</div> </div>
<Dropdown storageKey="proxy" options={engines} refresh={false} /> <Dropdown storageKey="proxy" options={engines} refresh={false} />
</div> </div>
<div className="flex h-64 w-80 flex-col flex-wrap content-center items-center rounded-lg border border-input-border-color bg-lighter p-7 text-center"> <div className="flex h-64 w-80 flex-col flex-wrap content-center items-center rounded-lg border border-input-border-color bg-lighter p-4 text-center">
<div className="p-2 text-3xl font-bold text-input-text"> <div className="p-2 text-3xl font-bold text-input-text">
{t("settings.proxymodes.title")} {t("settings.proxymodes.title")}
</div> </div>
@ -61,7 +61,7 @@ const Proxy = ({ id, active }) => {
refresh={false} refresh={false}
/> />
</div> </div>
<div className="flex h-64 w-80 flex-col flex-wrap content-center items-center rounded-lg border border-input-border-color bg-lighter p-7 text-center"> <div className="flex h-64 w-80 flex-col flex-wrap content-center items-center rounded-lg border border-input-border-color bg-lighter p-4 text-center">
<div className="p-2 text-3xl font-bold text-input-text"> <div className="p-2 text-3xl font-bold text-input-text">
{t("settings.search.title")} {t("settings.search.title")}
</div> </div>
@ -74,7 +74,7 @@ const Proxy = ({ id, active }) => {
refresh={false} refresh={false}
/> />
</div> </div>
<div className="flex h-64 w-80 flex-col flex-wrap content-center items-center rounded-lg border border-input-border-color bg-lighter p-7 text-center"> <div className="flex h-64 w-80 flex-col flex-wrap content-center items-center rounded-lg border border-input-border-color bg-lighter p-4 text-center">
<div className="p-2 text-3xl font-bold text-input-text"> <div className="p-2 text-3xl font-bold text-input-text">
{t("settings.bare.title")} {t("settings.bare.title")}
</div> </div>