refactor(react/settings): use separate components inside same file

This commit is contained in:
Elian Doran 2025-08-14 18:29:08 +03:00
parent 83e1512b59
commit d42a949602
No known key found for this signature in database

View File

@ -25,23 +25,18 @@ const BUILTIN_THEMES: Theme[] = [
]
export default function AppearanceSettings() {
const [ layoutOrientation, setLayoutOrientation ] = useTriliumOption("layoutOrientation", true);
const [ theme, setTheme ] = useTriliumOption("theme", true);
const [ overrideThemeFonts, setOverrideThemeFonts ] = useTriliumOptionBool("overrideThemeFonts");
const [ themes, setThemes ] = useState<Theme[]>([]);
useEffect(() => {
server.get<Theme[]>("options/user-themes").then((userThemes) => {
setThemes([
...BUILTIN_THEMES,
...userThemes
])
});
}, []);
return (
<>
<LayoutOrientation />
<ApplicationTheme />
</>
)
}
function LayoutOrientation() {
const [ layoutOrientation, setLayoutOrientation ] = useTriliumOption("layoutOrientation", true);
return (
<OptionsSection title={t("theme.layout")}>
{!isMobile() && <FormRadioGroup
name="layout-orientation"
@ -58,7 +53,25 @@ export default function AppearanceSettings() {
currentValue={layoutOrientation} onChange={setLayoutOrientation}
/>}
</OptionsSection>
);
}
function ApplicationTheme() {
const [ theme, setTheme ] = useTriliumOption("theme", true);
const [ overrideThemeFonts, setOverrideThemeFonts ] = useTriliumOptionBool("overrideThemeFonts");
const [ themes, setThemes ] = useState<Theme[]>([]);
useEffect(() => {
server.get<Theme[]>("options/user-themes").then((userThemes) => {
setThemes([
...BUILTIN_THEMES,
...userThemes
])
});
}, []);
return (
<OptionsSection title={t("theme.title")}>
<Column>
<label>{t("theme.theme_label")}</label>
@ -72,6 +85,5 @@ export default function AppearanceSettings() {
currentValue={overrideThemeFonts} onChange={setOverrideThemeFonts} />
</Column>
</OptionsSection>
</>
)
}