2021-07-29 13:35:03 +03:00
|
|
|
import {Color} from '@tryghost/color-utils';
|
2021-07-26 19:00:11 +03:00
|
|
|
import {helper} from '@ember/component/helper';
|
|
|
|
|
2021-07-28 19:14:24 +03:00
|
|
|
export default helper(function hexAdjuster([hex], {s: sDiff = 0, l: lDiff = 0} = {}) {
|
|
|
|
const originalColor = Color(hex);
|
2021-07-26 19:00:11 +03:00
|
|
|
|
2021-07-28 19:14:24 +03:00
|
|
|
let newColor = originalColor;
|
2021-07-26 19:00:11 +03:00
|
|
|
|
2021-07-28 19:14:24 +03:00
|
|
|
if (sDiff !== 0) {
|
|
|
|
newColor = newColor.saturationl(newColor.saturationl() + sDiff);
|
|
|
|
}
|
2021-07-26 19:00:11 +03:00
|
|
|
|
2021-07-28 19:14:24 +03:00
|
|
|
if (lDiff !== 0) {
|
|
|
|
newColor = newColor.lightness(newColor.lightness() + lDiff);
|
|
|
|
}
|
|
|
|
|
|
|
|
return newColor.hex();
|
2021-07-26 19:00:11 +03:00
|
|
|
});
|