Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@uifabric/variants",
"comment": "Variants: improve algorithm for generating strong variant that better handles inversion",
"type": "patch"
}
],
"packageName": "@uifabric/variants",
"email": "phkuo@microsoft.com"
}
14 changes: 13 additions & 1 deletion packages/variants/src/variants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ export function getStrongVariant(theme: IPartialTheme): ITheme {
const partialSemantic: Partial<ISemanticColors> = {
bodyBackground: p.themeDarkAlt,
bodyText: p.white,
bodySubtext: p.white,

inputBorder: p.themeDark,
// inputBorderHovered: p.neutralPrimary,
Expand All @@ -190,5 +191,16 @@ export function getStrongVariant(theme: IPartialTheme): ITheme {
// inputFocusBorderAlt: p.themePrimary,
};

return makeThemeFromPartials(theme, partialPalette, partialSemantic);
// 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
}
});
}