Ghost/ghost/admin/app/helpers/hex-adjust.js
Kevin Ansfield 0d092c2e32 Switched to extracted @tryghost/color-utils package
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
2021-07-29 11:35:15 +01:00

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();
});