Ghost/ghost/admin/app/helpers/hex-adjust.js
Kevin Ansfield 4e0473a93e Added CTA button and URL input to email-cta card
refs https://github.com/TryGhost/Team/issues/927

- added CTA `button and url inputs to email-cta card
- added `textColorForBackgroundColor` color util and used it to add a white/black text color variable that can be used when the accent color is used as a background color
- added `{{hex-adjust}}` helper for modifying lightness and saturation of a hex color
- adjusted inline power-select dropdown styling
2021-07-26 17:03:17 +01:00

18 lines
559 B
JavaScript

import {helper} from '@ember/component/helper';
import {hexToRgb, hslToRgb, rgbToHex, rgbToHsl} from '../utils/color';
export default helper(function hexAdjuster([hex], {s: sDiff, l: lDiff} = {}) {
const rgb = hexToRgb(hex);
const {h,s,l} = rgbToHsl(rgb);
const adjS = sDiff ? Math.min(Math.max(s + (sDiff / 100), 0), 1) : s;
const adjL = lDiff ? Math.min(Math.max(l + (lDiff / 100), 0), 1) : l;
const adjRgb = hslToRgb({h, s: adjS, l: adjL});
const adjHex = rgbToHex(adjRgb);
console.log(hex, adjHex);
return adjHex;
});