Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function _getCustomizations>(
displayName: string,
context: ICustomizerContext,
fields?: string[]
): ICustomizationProps {
// TODO: do we want field props? should fields be part of IComponent and used here?
// TODO: should we centrally define DefaultFields? (not exported from styling)
// TOOD: tie this array to ICustomizationProps, such that each array element is keyof ICustomizationProps
const DefaultFields = ['theme', 'styles', 'tokens'];
return Customizations.getSettings(fields || DefaultFields, displayName, context.customizations);
}
function _getCustomizations>(
displayName: string | undefined,
context: ICustomizerContext,
fields?: string[]
): ICustomizationProps {
// TODO: do we want field props? should fields be part of IComponent and used here?
// TODO: should we centrally define DefaultFields? (not exported from styling)
// TODO: tie this array to ICustomizationProps, such that each array element is keyof ICustomizationProps
const DefaultFields = ['theme', 'styles', 'tokens'];
return Customizations.getSettings(fields || DefaultFields, displayName, context.customizations);
}
function _getCustomizations>(
displayName: string,
context: ICustomizerContext,
fields?: string[]
): ICustomizationProps {
// TODO: do we want field props? should fields be part of IComponent and used here?
// TODO: should we centrally define DefaultFields? (not exported from styling)
// TOOD: tie this array to ICustomizationProps, such that each array element is keyof ICustomizationProps
const DefaultFields = ['theme', 'styles', 'tokens'];
return Customizations.getSettings(fields || DefaultFields, displayName, context.customizations);
}
export function getThemedContext(context: ICustomizerContext, scheme?: ISchemeNames, theme?: ITheme): ICustomizerContext {
let newContext: ICustomizerContext = context;
let newSettings;
// Only fall back to context and customizations when theme arg is not provided.
let schemeSource = theme || Customizations.getSettings(['theme'], undefined, context.customizations).theme;
if (theme) {
newSettings = { theme };
}
const schemeTheme: ITheme | undefined = scheme && schemeSource && schemeSource.schemes && schemeSource.schemes[scheme];
// These first two checks are logically redundant but TS doesn't infer schemeSource.schemes is defined when schemeTheme is defined.
if (schemeSource && schemeTheme && schemeSource !== schemeTheme) {
newSettings = { theme: schemeTheme };
newSettings.theme.schemes = schemeSource.schemes;
}
if (newSettings) {
newContext = {
customizations: {
import { DefaultSpacing } from './DefaultSpacing';
import { loadTheme as legacyLoadTheme } from '@microsoft/load-themed-styles';
import { DefaultEffects } from './DefaultEffects';
let _theme: ITheme = createTheme({
palette: DefaultPalette,
semanticColors: _makeSemanticColorsFromPalette(DefaultPalette, false, false),
fonts: DefaultFontStyles,
isInverted: false,
disableGlobalClassNames: false
});
let _onThemeChangeCallbacks: Array<(theme: ITheme) => void> = [];
export const ThemeSettingName = 'theme';
if (!Customizations.getSettings([ThemeSettingName]).theme) {
const win = getWindow();
// tslint:disable:no-string-literal no-any
if (win && (win as any)['FabricConfig'] && (win as any)['FabricConfig'].theme) {
_theme = createTheme((win as any)['FabricConfig'].theme);
}
// tslint:enable:no-string-literal no-any
// Set the default theme.
Customizations.applySettings({ [ThemeSettingName]: _theme });
}
/**
* Gets the theme object
* @param depComments - Whether to include deprecated tags as comments for deprecated slots.
*/