UNPKG

6.12 kBTypeScriptView Raw
1import { IChangedArgs } from '@jupyterlab/coreutils';
2import { ISettingRegistry } from '@jupyterlab/settingregistry';
3import { ITranslator } from '@jupyterlab/translation';
4import { IDisposable } from '@lumino/disposable';
5import { ISignal } from '@lumino/signaling';
6import { Widget } from '@lumino/widgets';
7import { ISplashScreen, IThemeManager } from './tokens';
8/**
9 * A class that provides theme management.
10 */
11export declare class ThemeManager implements IThemeManager {
12 /**
13 * Construct a new theme manager.
14 */
15 constructor(options: ThemeManager.IOptions);
16 /**
17 * Get the name of the current theme.
18 */
19 get theme(): string | null;
20 /**
21 * Get the name of the preferred light theme.
22 */
23 get preferredLightTheme(): string;
24 /**
25 * Get the name of the preferred dark theme.
26 */
27 get preferredDarkTheme(): string;
28 /**
29 * Get the name of the preferred theme
30 * When `adaptive-theme` is disabled, get current theme;
31 * Else, depending on the system settings, get preferred light or dark theme.
32 */
33 get preferredTheme(): string | null;
34 /**
35 * The names of the registered themes.
36 */
37 get themes(): ReadonlyArray<string>;
38 /**
39 * Get the names of the light themes.
40 */
41 get lightThemes(): ReadonlyArray<string>;
42 /**
43 * Get the names of the dark themes.
44 */
45 get darkThemes(): ReadonlyArray<string>;
46 /**
47 * A signal fired when the application theme changes.
48 */
49 get themeChanged(): ISignal<this, IChangedArgs<string, string | null>>;
50 /**
51 * Test if the system's preferred color scheme is dark
52 */
53 isSystemColorSchemeDark(): boolean;
54 /**
55 * Get the value of a CSS variable from its key.
56 *
57 * @param key - A Jupyterlab CSS variable, without the leading '--jp-'.
58 *
59 * @returns value - The current value of the Jupyterlab CSS variable
60 */
61 getCSS(key: string): string;
62 /**
63 * Load a theme CSS file by path.
64 *
65 * @param path - The path of the file to load.
66 */
67 loadCSS(path: string): Promise<void>;
68 /**
69 * Loads all current CSS overrides from settings. If an override has been
70 * removed or is invalid, this function unloads it instead.
71 */
72 loadCSSOverrides(): void;
73 /**
74 * Validate a CSS value w.r.t. a key
75 *
76 * @param key - A Jupyterlab CSS variable, without the leading '--jp-'.
77 *
78 * @param val - A candidate CSS value
79 */
80 validateCSS(key: string, val: string): boolean;
81 /**
82 * Register a theme with the theme manager.
83 *
84 * @param theme - The theme to register.
85 *
86 * @returns A disposable that can be used to unregister the theme.
87 */
88 register(theme: IThemeManager.ITheme): IDisposable;
89 /**
90 * Add a CSS override to the settings.
91 */
92 setCSSOverride(key: string, value: string): Promise<void>;
93 /**
94 * Set the current theme.
95 */
96 setTheme(name: string): Promise<void>;
97 /**
98 * Set the preferred light theme.
99 */
100 setPreferredLightTheme(name: string): Promise<void>;
101 /**
102 * Set the preferred dark theme.
103 */
104 setPreferredDarkTheme(name: string): Promise<void>;
105 /**
106 * Test whether a given theme is light.
107 */
108 isLight(name: string): boolean;
109 /**
110 * Increase a font size w.r.t. its current setting or its value in the
111 * current theme.
112 *
113 * @param key - A Jupyterlab font size CSS variable, without the leading '--jp-'.
114 */
115 incrFontSize(key: string): Promise<void>;
116 /**
117 * Decrease a font size w.r.t. its current setting or its value in the
118 * current theme.
119 *
120 * @param key - A Jupyterlab font size CSS variable, without the leading '--jp-'.
121 */
122 decrFontSize(key: string): Promise<void>;
123 /**
124 * Test whether a given theme styles scrollbars,
125 * and if the user has scrollbar styling enabled.
126 */
127 themeScrollbars(name: string): boolean;
128 /**
129 * Test if the user has scrollbar styling enabled.
130 */
131 isToggledThemeScrollbars(): boolean;
132 /**
133 * Toggle the `theme-scrollbars` setting.
134 */
135 toggleThemeScrollbars(): Promise<void>;
136 /**
137 * Test if the user enables adaptive theme.
138 */
139 isToggledAdaptiveTheme(): boolean;
140 /**
141 * Toggle the `adaptive-theme` setting.
142 */
143 toggleAdaptiveTheme(): Promise<void>;
144 /**
145 * Get the display name of the theme.
146 */
147 getDisplayName(name: string): string;
148 /**
149 * Change a font size by a positive or negative increment.
150 */
151 private _incrFontSize;
152 /**
153 * Initialize the key -> property dict for the overrides
154 */
155 private _initOverrideProps;
156 /**
157 * Handle the current settings.
158 */
159 private _loadSettings;
160 /**
161 * Load the theme.
162 *
163 * #### Notes
164 * This method assumes that the `theme` exists.
165 */
166 private _loadTheme;
167 /**
168 * Handle a theme error.
169 */
170 private _onError;
171 protected translator: ITranslator;
172 private _trans;
173 private _base;
174 private _current;
175 private _host;
176 private _links;
177 private _overrides;
178 private _overrideProps;
179 private _outstanding;
180 private _pending;
181 private _requests;
182 private _settings;
183 private _splash;
184 private _themes;
185 private _themeChanged;
186}
187export declare namespace ThemeManager {
188 /**
189 * The options used to create a theme manager.
190 */
191 interface IOptions {
192 /**
193 * The host widget for the theme manager.
194 */
195 host: Widget;
196 /**
197 * The setting registry key that holds theme setting data.
198 */
199 key: string;
200 /**
201 * The settings registry.
202 */
203 settings: ISettingRegistry;
204 /**
205 * The splash screen to show when loading themes.
206 */
207 splash?: ISplashScreen;
208 /**
209 * The url for local theme loading.
210 */
211 url: string;
212 /**
213 * The application language translator.
214 */
215 translator?: ITranslator;
216 }
217}