UNPKG

4.92 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 * The names of the registered themes.
22 */
23 get themes(): ReadonlyArray<string>;
24 /**
25 * A signal fired when the application theme changes.
26 */
27 get themeChanged(): ISignal<this, IChangedArgs<string, string | null>>;
28 /**
29 * Get the value of a CSS variable from its key.
30 *
31 * @param key - A Jupyterlab CSS variable, without the leading '--jp-'.
32 *
33 * @returns value - The current value of the Jupyterlab CSS variable
34 */
35 getCSS(key: string): string;
36 /**
37 * Load a theme CSS file by path.
38 *
39 * @param path - The path of the file to load.
40 */
41 loadCSS(path: string): Promise<void>;
42 /**
43 * Loads all current CSS overrides from settings. If an override has been
44 * removed or is invalid, this function unloads it instead.
45 */
46 loadCSSOverrides(): void;
47 /**
48 * Validate a CSS value w.r.t. a key
49 *
50 * @param key - A Jupyterlab CSS variable, without the leading '--jp-'.
51 *
52 * @param val - A candidate CSS value
53 */
54 validateCSS(key: string, val: string): boolean;
55 /**
56 * Register a theme with the theme manager.
57 *
58 * @param theme - The theme to register.
59 *
60 * @returns A disposable that can be used to unregister the theme.
61 */
62 register(theme: IThemeManager.ITheme): IDisposable;
63 /**
64 * Add a CSS override to the settings.
65 */
66 setCSSOverride(key: string, value: string): Promise<void>;
67 /**
68 * Set the current theme.
69 */
70 setTheme(name: string): Promise<void>;
71 /**
72 * Test whether a given theme is light.
73 */
74 isLight(name: string): boolean;
75 /**
76 * Increase a font size w.r.t. its current setting or its value in the
77 * current theme.
78 *
79 * @param key - A Jupyterlab font size CSS variable, without the leading '--jp-'.
80 */
81 incrFontSize(key: string): Promise<void>;
82 /**
83 * Decrease a font size w.r.t. its current setting or its value in the
84 * current theme.
85 *
86 * @param key - A Jupyterlab font size CSS variable, without the leading '--jp-'.
87 */
88 decrFontSize(key: string): Promise<void>;
89 /**
90 * Test whether a given theme styles scrollbars,
91 * and if the user has scrollbar styling enabled.
92 */
93 themeScrollbars(name: string): boolean;
94 /**
95 * Test if the user has scrollbar styling enabled.
96 */
97 isToggledThemeScrollbars(): boolean;
98 /**
99 * Toggle the `theme-scrollbars` setting.
100 */
101 toggleThemeScrollbars(): Promise<void>;
102 /**
103 * Get the display name of the theme.
104 */
105 getDisplayName(name: string): string;
106 /**
107 * Change a font size by a positive or negative increment.
108 */
109 private _incrFontSize;
110 /**
111 * Initialize the key -> property dict for the overrides
112 */
113 private _initOverrideProps;
114 /**
115 * Handle the current settings.
116 */
117 private _loadSettings;
118 /**
119 * Load the theme.
120 *
121 * #### Notes
122 * This method assumes that the `theme` exists.
123 */
124 private _loadTheme;
125 /**
126 * Handle a theme error.
127 */
128 private _onError;
129 protected translator: ITranslator;
130 private _trans;
131 private _base;
132 private _current;
133 private _host;
134 private _links;
135 private _overrides;
136 private _overrideProps;
137 private _outstanding;
138 private _pending;
139 private _requests;
140 private _settings;
141 private _splash;
142 private _themes;
143 private _themeChanged;
144}
145export declare namespace ThemeManager {
146 /**
147 * The options used to create a theme manager.
148 */
149 interface IOptions {
150 /**
151 * The host widget for the theme manager.
152 */
153 host: Widget;
154 /**
155 * The setting registry key that holds theme setting data.
156 */
157 key: string;
158 /**
159 * The settings registry.
160 */
161 settings: ISettingRegistry;
162 /**
163 * The splash screen to show when loading themes.
164 */
165 splash?: ISplashScreen;
166 /**
167 * The url for local theme loading.
168 */
169 url: string;
170 /**
171 * The application language translator.
172 */
173 translator?: ITranslator;
174 }
175}