mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
- use monaco editor theme vs-dark for lens-dark.json theme (agreed with Alex)
- clean up theme.store.ts Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
parent
98244ec95c
commit
3ee2738f14
@ -20,41 +20,45 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { computed, makeObservable, observable, reaction } from "mobx";
|
import { computed, makeObservable, observable, reaction } from "mobx";
|
||||||
import { autoBind, iter, Singleton } from "./utils";
|
import { autoBind, Singleton } from "./utils";
|
||||||
import { UserStore } from "../common/user-store";
|
import { UserStore } from "../common/user-store";
|
||||||
import logger from "../main/logger";
|
import logger from "../main/logger";
|
||||||
import darkTheme from "./themes/lens-dark.json";
|
import lensDarkTheme from "./themes/lens-dark.json";
|
||||||
import lightTheme from "./themes/lens-light.json";
|
import lensLightTheme from "./themes/lens-light.json";
|
||||||
import type { SelectOption } from "./components/select";
|
import type { SelectOption } from "./components/select";
|
||||||
import type { MonacoEditorProps } from "./components/monaco-editor";
|
import type { MonacoEditorProps } from "./components/monaco-editor";
|
||||||
|
|
||||||
export type ThemeId = string;
|
export type ThemeId = string;
|
||||||
|
|
||||||
export interface Theme {
|
export interface Theme {
|
||||||
type: "dark" | "light" | string;
|
id?: ThemeId;
|
||||||
name: string;
|
name: string;
|
||||||
|
type: "dark" | "light";
|
||||||
colors: Record<string, string>;
|
colors: Record<string, string>;
|
||||||
description: string;
|
description: string;
|
||||||
author: string;
|
author: string;
|
||||||
monacoTheme: MonacoEditorProps["theme"];
|
monacoTheme: MonacoEditorProps["theme"];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ThemeItems extends Theme {
|
|
||||||
id: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class ThemeStore extends Singleton {
|
export class ThemeStore extends Singleton {
|
||||||
static readonly defaultTheme = "lens-dark";
|
static readonly defaultTheme = "lens-dark";
|
||||||
protected styles: HTMLStyleElement;
|
protected styles: HTMLStyleElement;
|
||||||
|
|
||||||
// bundled themes from `themes/${themeId}.json`
|
// bundled themes from `themes/${themeId}.json`
|
||||||
private allThemes = observable.map<string, Theme>({
|
private allThemes = observable.map<string, Theme>({
|
||||||
"lens-dark": darkTheme,
|
"lens-dark": lensDarkTheme as Theme,
|
||||||
"lens-light": lightTheme,
|
"lens-light": lensLightTheme as Theme,
|
||||||
});
|
});
|
||||||
|
|
||||||
@computed get themes(): ThemeItems[] {
|
@computed get themes() {
|
||||||
return Array.from(iter.map(this.allThemes, ([id, theme]) => ({ id, ...theme })));
|
return Array.from(this.allThemes.entries()).map(([themeId, themeOriginal]) => {
|
||||||
|
const theme: Required<Theme> = {
|
||||||
|
id: themeId, // take id from map's key
|
||||||
|
...themeOriginal,
|
||||||
|
};
|
||||||
|
|
||||||
|
return theme;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@computed get activeThemeId(): string {
|
@computed get activeThemeId(): string {
|
||||||
@ -62,7 +66,7 @@ export class ThemeStore extends Singleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@computed get activeTheme(): Theme {
|
@computed get activeTheme(): Theme {
|
||||||
return this.allThemes.get(this.activeThemeId) ?? this.allThemes.get("lens-dark");
|
return this.allThemes.get(this.activeThemeId) ?? this.allThemes.get(ThemeStore.defaultTheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
@computed get themeOptions(): SelectOption<string>[] {
|
@computed get themeOptions(): SelectOption<string>[] {
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
"type": "dark",
|
"type": "dark",
|
||||||
"description": "Original Lens dark theme",
|
"description": "Original Lens dark theme",
|
||||||
"author": "Mirantis",
|
"author": "Mirantis",
|
||||||
"monacoTheme": "clouds-midnight",
|
"monacoTheme": "vs-dark",
|
||||||
"colors": {
|
"colors": {
|
||||||
"blue": "#3d90ce",
|
"blue": "#3d90ce",
|
||||||
"magenta": "#c93dce",
|
"magenta": "#c93dce",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user