mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 22:43:30 +03:00
eed299d1f6
refs https://github.com/TryGhost/Team/issues/928 - switched to using `color` for color conversion and adjustments rather than maintaining our own limited utils (preparation to extract our own utils to separate library) - changed contrast threshold for yiq-based contrast adjustment from `128` to `186` to match Portal's current behaviour
19 lines
470 B
JavaScript
19 lines
470 B
JavaScript
import Color from 'color';
|
|
import {helper} from '@ember/component/helper';
|
|
|
|
export default helper(function hexAdjuster([hex], {s: sDiff = 0, l: lDiff = 0} = {}) {
|
|
const originalColor = Color(hex);
|
|
|
|
let newColor = originalColor;
|
|
|
|
if (sDiff !== 0) {
|
|
newColor = newColor.saturationl(newColor.saturationl() + sDiff);
|
|
}
|
|
|
|
if (lDiff !== 0) {
|
|
newColor = newColor.lightness(newColor.lightness() + lDiff);
|
|
}
|
|
|
|
return newColor.hex();
|
|
});
|