Skip to content

Commit

Permalink
fix(Tag): use primary colors
Browse files Browse the repository at this point in the history
  • Loading branch information
zouxuoz committed Dec 24, 2018
1 parent 0408aa4 commit 67d7961
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion src/components/Tag/Tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ const theme = createComponentTheme(name, ({ COLORS }: *): * => ({
color: fp.mapValues(
(color) => ({
backgroundColor: color,
color: getContrastColor(color),
color: getContrastColor(color, {
lightColor: COLORS.LIGHT_PRIMARY_TEXT_COLOR,
darkColor: COLORS.PRIMARY_TEXT_COLOR,
}),
}),
COLORS,
),
Expand Down
6 changes: 3 additions & 3 deletions src/components/Tag/Tag.utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ const getLuma = (color) => {
return (0.2126 * rgb[0]) + (0.7152 * rgb[1]) + (0.0722 * rgb[2]);
};

export const getContrastColor = (color) => {
export const getContrastColor = (color, { lightColor = '#ffffff', darkColor = '#000000' } = {}) => {
if (isValidRGB(color)) {
return (getLuma(color) >= 165) ? '#000000' : '#ffffff';
return (getLuma(color) >= 165) ? darkColor : lightColor;
}

return '#000000';
return darkColor;
};

0 comments on commit 67d7961

Please sign in to comment.