mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 15:19:01 +02:00
refactor(options/i18n): use select for language selection
This commit is contained in:
parent
1cc0e686ea
commit
0c2b186e50
@ -10,10 +10,16 @@
|
|||||||
margin-bottom: 0 !important;
|
margin-bottom: 0 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.option-row > select {
|
.option-row > select,
|
||||||
|
.option-row > .dropdown {
|
||||||
width: 60%;
|
width: 60%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.option-row > .dropdown button {
|
||||||
|
width: 100%;
|
||||||
|
text-align: start;
|
||||||
|
}
|
||||||
|
|
||||||
.option-row:last-of-type {
|
.option-row:last-of-type {
|
||||||
border-bottom: unset;
|
border-bottom: unset;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { useMemo } from "preact/hooks";
|
import { useMemo, useState } from "preact/hooks";
|
||||||
import { getAvailableLocales, t } from "../../../services/i18n";
|
import { getAvailableLocales, t } from "../../../services/i18n";
|
||||||
import FormSelect from "../../react/FormSelect";
|
import FormSelect from "../../react/FormSelect";
|
||||||
import OptionsRow from "./components/OptionsRow";
|
import OptionsRow from "./components/OptionsRow";
|
||||||
@ -12,6 +12,9 @@ import RawHtml from "../../react/RawHtml";
|
|||||||
import Admonition from "../../react/Admonition";
|
import Admonition from "../../react/Admonition";
|
||||||
import Button from "../../react/Button";
|
import Button from "../../react/Button";
|
||||||
import CheckboxList from "./components/CheckboxList";
|
import CheckboxList from "./components/CheckboxList";
|
||||||
|
import FormDropdownList from "../../react/FormDropdownList";
|
||||||
|
import Dropdown from "../../react/Dropdown";
|
||||||
|
import { FormListItem } from "../../react/FormList";
|
||||||
|
|
||||||
export default function InternationalizationOptions() {
|
export default function InternationalizationOptions() {
|
||||||
return (
|
return (
|
||||||
@ -57,12 +60,20 @@ function LocalizationOptions() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function LocaleSelector({ id, locales, currentValue, onChange }: { id?: string; locales: Locale[], currentValue: string, onChange: (newLocale: string) => void }) {
|
function LocaleSelector({ id, locales, currentValue, onChange }: { id?: string; locales: Locale[], currentValue: string, onChange: (newLocale: string) => void }) {
|
||||||
return <FormSelect
|
const [ activeLocale, setActiveLocale ] = useState(locales.find(l => l.id === currentValue));
|
||||||
id={id}
|
return (
|
||||||
values={locales}
|
<Dropdown text={activeLocale?.name}>
|
||||||
keyProperty="id" titleProperty="name"
|
{locales.map(locale => (
|
||||||
currentValue={currentValue} onChange={onChange}
|
<FormListItem
|
||||||
/>;
|
checked={locale === activeLocale }
|
||||||
|
onClick={() => {
|
||||||
|
setActiveLocale(locale);
|
||||||
|
onChange(locale.id);
|
||||||
|
}}
|
||||||
|
>{locale.name}</FormListItem>
|
||||||
|
))}
|
||||||
|
</Dropdown>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function DateSettings() {
|
function DateSettings() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user