Skip to content

Commit

Permalink
Changed color utilites to output hex instead of .css() or rgb
Browse files Browse the repository at this point in the history
  • Loading branch information
cchaos committed Sep 29, 2021
1 parent 082a756 commit 2db22a4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/services/color/contrast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Background: ${background}`
}
}

return highContrastTextColor;
return chroma(highContrastTextColor).hex();
};

/**
Expand Down
8 changes: 4 additions & 4 deletions src/services/color/manipulation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,31 @@ export const transparentize = (color: string, alpha: number) =>
* @param ratio - Mix weight. From 0-1. Larger value indicates more white.
*/
export const tint = (color: string, ratio: number) =>
chroma.mix(color, '#fff', ratio, 'rgb').css();
chroma.mix(color, '#fff', ratio, 'rgb').hex();

/**
* Mixes a provided color with black.
* @param color - Color to mix with black
* @param ratio - Mix weight. From 0-1. Larger value indicates more black.
*/
export const shade = (color: string, ratio: number) =>
chroma.mix(color, '#000', ratio, 'rgb').css();
chroma.mix(color, '#000', ratio, 'rgb').hex();

/**
* Increases the saturation of a color by manipulating the hsl saturation.
* @param color - Color to manipulate
* @param amount - Amount to change in absolute terms. 0-1.
*/
export const saturate = (color: string, amount: number) =>
chroma(color).set('hsl.s', `+${amount}`).css();
chroma(color).set('hsl.s', `+${amount}`).hex();

/**
* Decreases the saturation of a color by manipulating the hsl saturation.
* @param color - Color to manipulate
* @param amount - Amount to change in absolute terms. 0-1.
*/
export const desaturate = (color: string, amount: number) =>
chroma(color).set('hsl.s', `-${amount}`).css();
chroma(color).set('hsl.s', `-${amount}`).hex();

/**
* Returns the lightness value of a color. 0-100
Expand Down

0 comments on commit 2db22a4

Please sign in to comment.