pleroma/app/soapbox/reducers/theme.js

24 lines
596 B
JavaScript
Raw Normal View History

2020-05-30 17:05:01 -07:00
import {
SET_THEME,
} from '../actions/theme';
import { Map as ImmutableMap } from 'immutable';
2020-05-30 18:11:08 -07:00
import { brightness, hue } from 'chromatism';
2020-05-30 17:05:01 -07:00
const initialState = ImmutableMap();
2020-05-30 18:11:08 -07:00
const populate = themeData => {
const { 'brand-color': brandColor } = themeData.toObject();
return ImmutableMap({
'nav-ui-highlight-color': brightness(10, hue(-3, brandColor).hex).hex,
}).merge(themeData);
};
2020-05-30 17:05:01 -07:00
export default function theme(state = initialState, action) {
switch(action.type) {
case SET_THEME:
2020-05-30 18:11:08 -07:00
return populate(ImmutableMap(action.themeData));
2020-05-30 17:05:01 -07:00
default:
return state;
}
};