cbdcccb8b2
Moved back to chromatism. Well worth it for the accuracy.
22 lines
588 B
JavaScript
22 lines
588 B
JavaScript
import { Map as ImmutableMap } from 'immutable';
|
|
import { convert } from 'chromatism';
|
|
|
|
export const generateThemeCss = brandColor => {
|
|
if (!brandColor) return null;
|
|
return themeDataToCss(brandColorToThemeData(brandColor));
|
|
};
|
|
|
|
export const brandColorToThemeData = brandColor => {
|
|
const { h, s, l } = convert(brandColor).hsl;
|
|
return ImmutableMap({
|
|
'brand-color_h': h,
|
|
'brand-color_s': `${s}%`,
|
|
'brand-color_l': `${l}%`,
|
|
});
|
|
};
|
|
|
|
export const themeDataToCss = themeData => (
|
|
themeData
|
|
.entrySeq()
|
|
.reduce((acc, cur) => acc + `--${cur[0]}:${cur[1]};`, '')
|
|
);
|