mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-25 09:03:12 +03:00
4e0473a93e
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
18 lines
559 B
JavaScript
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;
|
|
});
|