Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function createEsm(css) {
const { splitStyles } = require('@microsoft/load-themed-styles');
// Create a source file.
const source = [
`/* tslint:disable */`,
`import { loadStyles } from \'@microsoft/load-themed-styles\';`,
`loadStyles(${JSON.stringify(splitStyles(css))});`
];
return source.join('\n');
}
function createTypeScriptModule(fileName, css) {
const { splitStyles } = require("@microsoft/load-themed-styles");
// Create a source file.
const source = [
`/* tslint:disable */`,
`import { loadStyles } from \'@microsoft/load-themed-styles\';`,
`loadStyles(${JSON.stringify(splitStyles(css))});`
];
const map = _fileNameToClassMap[fileName];
for (let prop in map) {
source.push(`export const ${prop} = "${map[prop]}";`);
}
return source.join('\n');
}
function createTypeScriptModule(fileName, css) {
const { splitStyles } = require('@microsoft/load-themed-styles');
// Create a source file.
const source = [
`/* tslint:disable */`,
`import { loadStyles } from \'@microsoft/load-themed-styles\';`,
`loadStyles(${JSON.stringify(splitStyles(css))});`
];
const map = _fileNameToClassMap[fileName];
for (let prop in map) {
source.push(`export const ${prop} = "${map[prop]}";`);
}
return source.join('\n');
}
function createTypeScriptModule(fileName, css) {
const { splitStyles } = require('@microsoft/load-themed-styles');
// Create a source file.
const source = [
`/* tslint:disable */`,
`import { loadStyles } from \'@microsoft/load-themed-styles\';`,
`loadStyles(${JSON.stringify(splitStyles(css))});`
];
const map = _fileNameToClassMap[fileName];
for (let prop in map) {
source.push(`export const ${prop} = "${map[prop]}";`);
}
return source.join('\n');
}
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;
}
private async render(): Promise {
// Make sure all messages are shown on one line
loadStyles(`#${this.properties.messageId} > DIV {float:left;margin-right:15px;}`);
let targetNode = document.getElementById(this.properties.messageId);
if (!targetNode) {
// Make sure message element is present - if not create it
targetNode = document.createElement("DIV");
targetNode.id = this.properties.messageId;
document.body.appendChild(targetNode);
}
if (!_topPlaceholder) {
_topPlaceholder = this.context.placeholderProvider.tryCreateContent(PlaceholderName.Top, { onDispose: this._onDispose });
// Hide placeholder if there is no text in it
_topPlaceholder.domElement.style.cssText = targetNode.innerText.length > 0 ? "" : "display:none"
_topPlaceholder.domElement.innerHTML = `