blob: 6e6b83d73ef1cbb8802a573792724001f2e3dd4b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
import * as _ from 'lodash';
import * as React from 'react';
import { connect } from 'react-redux';
import { State } from '../redux/reducer';
import { Theme, theme as defaultTheme, ThemeProvider } from '../style/theme';
import { Asset } from '../types';
export interface SelectedAssetThemeProviderProps {}
interface ConnectedState {
theme: Theme;
}
const getTheme = (asset?: Asset): Theme => {
if (!_.isUndefined(asset) && !_.isUndefined(asset.metaData.primaryColor)) {
return {
...defaultTheme,
primaryColor: asset.metaData.primaryColor,
};
}
return defaultTheme;
};
const mapStateToProps = (state: State, _ownProps: SelectedAssetThemeProviderProps): ConnectedState => {
const theme = getTheme(state.selectedAsset);
return { theme };
};
export const SelectedAssetThemeProvider: React.ComponentClass<SelectedAssetThemeProviderProps> = connect(
mapStateToProps,
)(ThemeProvider);
|