feat: Add "Appearance" pane to preferences (#816)

Co-authored-by: Mo <mo@standardnotes.com>
This commit is contained in:
Aman Harwara
2022-01-19 19:41:04 +05:30
committed by GitHub
parent c232a5e3c6
commit da1d4f75c8
11 changed files with 307 additions and 44 deletions

View File

@@ -49,6 +49,19 @@ const toggleFocusMode = (enabled: boolean) => {
}
};
export const sortThemes = (a: SNTheme, b: SNTheme) => {
const aIsLayerable = a.isLayerable();
const bIsLayerable = b.isLayerable();
if (aIsLayerable && !bIsLayerable) {
return 1;
} else if (!aIsLayerable && bIsLayerable) {
return -1;
} else {
return a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1;
}
};
const QuickSettingsMenu: FunctionComponent<MenuProps> = observer(
({ application, appState }) => {
const {
@@ -79,23 +92,7 @@ const QuickSettingsMenu: FunctionComponent<MenuProps> = observer(
const themes = application.getDisplayableItems(
ContentType.Theme
) as SNTheme[];
setThemes(
themes.sort((a, b) => {
const aIsLayerable = a.isLayerable();
const bIsLayerable = b.isLayerable();
if (aIsLayerable && !bIsLayerable) {
return 1;
} else if (!aIsLayerable && bIsLayerable) {
return -1;
} else {
return a.name.toLowerCase() <
b.name.toLowerCase()
? -1
: 1;
}
})
);
setThemes(themes.sort(sortThemes));
setDefaultThemeOn(
!themes.find((theme) => theme.active && !theme.isLayerable())
);