本文整理汇总了TypeScript中@uifabric/styling/lib/index.createTheme函数的典型用法代码示例。如果您正苦于以下问题:TypeScript createTheme函数的具体用法?TypeScript createTheme怎么用?TypeScript createTheme使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了createTheme函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: makeThemeFromPartials
function makeThemeFromPartials(
originalTheme: IPartialTheme,
partialPalette: Partial<IPalette>,
partialSemantic: Partial<ISemanticColors>): ITheme {
return createTheme({
...originalTheme,
...{
palette: { ...originalTheme.palette, ...partialPalette },
semanticColors: { ...originalTheme.semanticColors, ...partialSemantic },
}
});
}
示例2: getSoftVariant
export function getSoftVariant(theme: IPartialTheme): ITheme {
const fullTheme = createTheme(theme);
const p = fullTheme.palette;
// commented lines are unchanged, but left in for tracking purposes
// in a tint variant, most colors remain unchanged
const partialPalette: Partial<IPalette> = {
// theme
// themeDarker: '#004578',
// themeDark: '#005a9e',
// themeDarkAlt: '#106ebe',
// themePrimary: '#0078d4',
// themeSecondary: '#2b88d8',
// themeTertiary: '#71afe5',
// themeLight: '#c7e0f4',
// themeLighter: '#deecf9',
// themeLighterAlt: '#eff6fc',
// foregrounds
// black: '#000000',
// neutralDark: '#212121',
// neutralPrimary: '#333333',
// neutralPrimaryAlt: '#3c3c3c',
// neutralSecondary: '#666666',
// neutralTertiary: '#a6a6a6',
// backgrounds
// neutralTertiaryAlt: '#c8c8c8', // themeLighter?
// neutralQuaternary: '#d0d0d0',
// neutralQuaternaryAlt: '#dadada',
// neutralLight: '#eaeaea',
// neutralLighter: '#f4f4f4',
// neutralLighterAlt: '#f8f8f8',
white: p.themeLighterAlt
};
const partialSemantic: Partial<ISemanticColors> = {
bodyBackground: p.themeLighterAlt,
inputBorder: p.themeLighter,
// inputBorderHovered: p.neutralPrimary,
inputBackground: p.themeLighter,
// inputBackgroundChecked: p.themePrimary,
// inputBackgroundCheckedHovered: p.themeDarkAlt,
inputForegroundChecked: p.themeLighterAlt,
// inputFocusBorderAlt: p.themePrimary,
};
return makeThemeFromPartials(theme, partialPalette, partialSemantic);
}
示例3: getStrongVariant
export function getStrongVariant(theme: IPartialTheme): ITheme {
const fullTheme = createTheme(theme);
const p = fullTheme.palette;
// dirty algorithm:
// in a tricolor theme, foreground doesn't get used?
// theme colors -> background shades
// foregrounds -> background shades
// backgrounds -> theme colors
const partialPalette: Partial<IPalette> = {
// theme
themeDarker: p.white,
themeDark: p.neutralLighterAlt,
themeDarkAlt: p.neutralLighterAlt,
themePrimary: p.white,
themeSecondary: p.neutralLighter,
themeTertiary: p.neutralLight,
themeLight: p.neutralQuaternaryAlt,
themeLighter: p.neutralQuaternary,
themeLighterAlt: p.neutralTertiaryAlt,
// foregrounds
black: p.neutralLighterAlt,
neutralDark: p.neutralLighter,
neutralPrimary: p.white,
neutralPrimaryAlt: p.neutralLight,
neutralSecondary: p.neutralQuaternaryAlt,
neutralTertiary: p.neutralQuaternary,
// backgrounds
neutralTertiaryAlt: p.themeLighterAlt,
neutralQuaternary: p.themeLighter,
neutralQuaternaryAlt: p.themeLight,
neutralLight: p.themeTertiary,
neutralLighter: p.themeSecondary,
neutralLighterAlt: p.themePrimary,
white: p.themeDarkAlt
};
const partialSemantic: Partial<ISemanticColors> = {
bodyBackground: p.themeDarkAlt,
bodyText: p.white,
bodySubtext: p.white,
inputBorder: p.themeDark,
// inputBorderHovered: p.neutralPrimary,
inputBackground: p.themeDark,
inputBackgroundChecked: p.white,
// inputBackgroundCheckedHovered: p.themeDarkAlt,
inputForegroundChecked: p.themeDark,
// inputFocusBorderAlt: p.themePrimary,
};
// Strong variant is unique here, we've redefined the entire palette and are
// effectively inverting the theme. Thus, do not mix in the original theme's value
// for the palette and semanticColors, since they will not work well "inverted",
// instead, use the new palette and then generate semanticColors from scratch.
return createTheme({
...theme,
...{
palette: partialPalette,
semanticColors: partialSemantic,
isInverted: !theme.isInverted
}
});
}