Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function loadTheme(theme: IPartialTheme, depComments: boolean = false): ITheme {
_theme = createTheme(theme, depComments);
// Invoke the legacy method of theming the page as well.
legacyLoadTheme({ ..._theme.palette, ..._theme.semanticColors, ..._theme.effects, ..._loadFonts(_theme) });
Customizations.applySettings({ [ThemeSettingName]: _theme });
_onThemeChangeCallbacks.forEach((callback: (theme: ITheme) => void) => {
try {
callback(_theme);
} catch (e) {
// don't let a bad callback break everything else
}
});
return _theme;
}
private _onColorChanged(index: number, newColor: string) {
let { colors } = this.state;
let color = colors[index];
let theme: ITheme = {};
color.value = newColor;
for (let i = 0; i < colors.length; i++) {
let themeColor = colors[i];
theme[themeColor.key] = themeColor.value;
}
loadTheme(theme);
// The theme has changed values, but color state is the same. Force an update on the list.
this.refs.list.forceUpdate();
}
export function loadTheme(theme: IPartialTheme): ITheme {
_theme = createTheme(theme);
// Invoke the legacy method of theming the page as well.
legacyLoadTheme({ ..._theme.palette, ..._theme.semanticColors });
GlobalSettings.setValue(ThemeSettingName, _theme);
return _theme;
}
private _onColorChanged(index: number, newColor: string) {
let { colors } = this.state;
let color = colors[index];
let theme: ITheme = {};
color.value = newColor;
for (let i = 0; i < colors.length; i++) {
let themeColor = colors[i];
theme[themeColor.key] = themeColor.value;
}
loadTheme(theme);
// The theme has changed values, but color state is the same. Force an update on the list.
this.refs.list.forceUpdate();
}
export function loadTheme(theme: IPartialTheme, depComments: boolean = false): ITheme {
_theme = createTheme(theme, depComments);
// Invoke the legacy method of theming the page as well.
legacyLoadTheme({..._theme.palette, ..._theme.semanticColors});
Customizations.applySettings({[ThemeSettingName]: _theme});
_onThemeChangeCallbacks.forEach((callback: (theme: ITheme) => void) => {
try {
callback(_theme);
} catch (e) {
// don't let a bad callback break everything else
}
});
return _theme;
}