bigbuffet-rw/app/soapbox/utils/theme.js

23 lines
588 B
JavaScript
Raw Normal View History

2020-06-02 13:48:27 -07:00
import { Map as ImmutableMap } from 'immutable';
import { convert } from 'chromatism';
2020-06-02 13:48:27 -07:00
export const generateThemeCss = brandColor => {
if (!brandColor) return null;
return themeDataToCss(brandColorToThemeData(brandColor));
};
export const brandColorToThemeData = brandColor => {
const { h, s, l } = convert(brandColor).hsl;
2020-06-02 13:48:27 -07:00
return ImmutableMap({
2020-06-06 20:55:00 -07:00
'brand-color_h': h,
'brand-color_s': `${s}%`,
'brand-color_l': `${l}%`,
2020-06-02 13:48:27 -07:00
});
};
2020-05-30 17:05:01 -07:00
export const themeDataToCss = themeData => (
themeData
.entrySeq()
.reduce((acc, cur) => acc + `--${cur[0]}:${cur[1]};`, '')
);