Spaces quick settings (#7196)

This commit is contained in:
Michael Telatynski 2021-11-26 15:41:04 +00:00 committed by GitHub
parent 138f6685d4
commit 9fefeefc8c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 366 additions and 32 deletions

View file

@ -19,6 +19,7 @@ import { _t } from "./languageHandler";
import SettingsStore from "./settings/SettingsStore";
import ThemeWatcher from "./settings/watchers/ThemeWatcher";
import { compare } from "./utils/strings";
export const DEFAULT_THEME = "light";
const HIGH_CONTRAST_THEMES = {
@ -86,6 +87,21 @@ export function enumerateThemes(): {[key: string]: string} {
return Object.assign({}, customThemeNames, BUILTIN_THEMES);
}
interface ITheme {
id: string;
name: string;
}
export function getOrderedThemes(): ITheme[] {
const themes = Object.entries(enumerateThemes())
.map(p => ({ id: p[0], name: p[1] })) // convert pairs to objects for code readability
.filter(p => !isHighContrastTheme(p.id));
const builtInThemes = themes.filter(p => !p.id.startsWith("custom-"));
const customThemes = themes.filter(p => !builtInThemes.includes(p))
.sort((a, b) => compare(a.name, b.name));
return [...builtInThemes, ...customThemes];
}
function clearCustomTheme(): void {
// remove all css variables, we assume these are there because of the custom theme
const inlineStyleProps = Object.values(document.body.style);