diff options
author | fragosti <francesco.agosti93@gmail.com> | 2018-10-19 07:35:59 +0800 |
---|---|---|
committer | fragosti <francesco.agosti93@gmail.com> | 2018-10-19 07:35:59 +0800 |
commit | 7a8adf9db5a83c3f44d6fe9e84e00ff1ec1e88e0 (patch) | |
tree | 161ef0e66e906e6561a8dbbd901b3fd97ab413fa /packages/instant/src/containers/selected_asset_theme_provider.ts | |
parent | ad6dc8e891059f00f2ddda1884bbc78c1e47ea24 (diff) | |
download | dexon-0x-contracts-7a8adf9db5a83c3f44d6fe9e84e00ff1ec1e88e0.tar.gz dexon-0x-contracts-7a8adf9db5a83c3f44d6fe9e84e00ff1ec1e88e0.tar.zst dexon-0x-contracts-7a8adf9db5a83c3f44d6fe9e84e00ff1ec1e88e0.zip |
feat: use color from metaData instead of default primaryColor
Diffstat (limited to 'packages/instant/src/containers/selected_asset_theme_provider.ts')
-rw-r--r-- | packages/instant/src/containers/selected_asset_theme_provider.ts | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/packages/instant/src/containers/selected_asset_theme_provider.ts b/packages/instant/src/containers/selected_asset_theme_provider.ts new file mode 100644 index 000000000..6e6b83d73 --- /dev/null +++ b/packages/instant/src/containers/selected_asset_theme_provider.ts @@ -0,0 +1,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); |