mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-29 15:12:58 +03:00
0d092c2e32
refs https://github.com/TryGhost/Team/issues/928 - we want to make use of the same color adjustments and contrast selection for accent colors we use in Admin on the server-side for emails so utility functions have been extracted to an external package
19 lines
488 B
JavaScript
19 lines
488 B
JavaScript
import {Color} from '@tryghost/color-utils';
|
|
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();
|
|
});
|