Skip to content

Commit

Permalink
feat(variant-theme): keep custom colors (#261)
Browse files Browse the repository at this point in the history
  • Loading branch information
RongqiZ authored Nov 21, 2024
1 parent 70b19d2 commit 369d425
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "keep custom colors",
"packageName": "@fluentui-contrib/variant-theme",
"email": "[email protected]",
"dependentChangeType": "patch"
}
14 changes: 8 additions & 6 deletions packages/variant-theme/src/ThemeGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,17 @@ function getStrongVariant(
brand: BrandVariants,
isInverted?: boolean
) {
const newBrandColor = theme.colorNeutralBackground1;

// Todo: dark mode support
setNeutralWithBrand(theme, brand);
const colorOnBrand: string = determineColorOnBrand(
theme.colorNeutralBackground1
);
const alphas: Record<AlphaColors, string> =
colorOnBrand === black ? blackAlpha : whiteAlpha;

setColorsOnBrand(theme, brand, colorOnBrand, alphas, isInverted);
const alphas: Record<AlphaColors, string> =
contrast(hex_to_sRGB(newBrandColor), hex_to_sRGB(black)) >
contrast(hex_to_sRGB(newBrandColor), hex_to_sRGB(white))
? whiteAlpha
: blackAlpha;
setColorsOnBrand(theme, brand, newBrandColor, alphas, isInverted);
}

function setNeutralWithBrand(theme: Theme, brand: BrandVariants) {
Expand Down

0 comments on commit 369d425

Please sign in to comment.