Skip to content

Commit a611888

Browse files
Merge pull request #186 from Chia-Network/develop
Release 1.1.14
2 parents 0a7ac85 + d90ebdb commit a611888

File tree

6 files changed

+46
-8
lines changed

6 files changed

+46
-8
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "climateexplorerui",
3-
"version": "1.1.13",
3+
"version": "1.1.14",
44
"private": true,
55
"author": "Chia Network Inc. <[email protected]>",
66
"description": "User interface for the Chia Climate Explorer application",

src/App.js

+20-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import { IntlProvider } from 'react-intl';
44
import { useDispatch, useSelector } from 'react-redux';
55

66
import {
7+
setCustomTheme,
78
setLocale,
89
setThemeFromLocalStorage,
910
} from './store/actions/appActions';
1011

1112
import { loadLocaleData } from './translations';
1213
import { AppNavigator } from './navigation';
13-
import theme from './theme';
1414

1515
import { IndeterminateProgressOverlay } from './components';
1616
import { LocaleChangeListener } from './components/blocks/LocaleChangeListener';
@@ -20,6 +20,24 @@ const App = () => {
2020
const appStore = useSelector(state => state);
2121
const [translationTokens, setTranslationTokens] = useState();
2222

23+
const notifyParentWhenAppLoaded = () => {
24+
window.parent.postMessage('appLoaded', window.location.origin);
25+
};
26+
27+
useEffect(() => {
28+
const handleMessage = event => {
29+
if (event.data.customThemeColors) {
30+
dispatch(setCustomTheme(event.data.customThemeColors));
31+
}
32+
};
33+
notifyParentWhenAppLoaded();
34+
window.addEventListener('message', handleMessage);
35+
36+
return () => {
37+
window.removeEventListener('message', handleMessage);
38+
};
39+
}, []);
40+
2341
useEffect(() => {
2442
dispatch(setThemeFromLocalStorage);
2543
}, [setThemeFromLocalStorage]);
@@ -41,7 +59,7 @@ const App = () => {
4159
}
4260

4361
return (
44-
<ThemeProvider theme={theme}>
62+
<ThemeProvider theme={appStore.customTheme}>
4563
<IntlProvider
4664
locale="en"
4765
defaultLocale="en"

src/components/layout/LeftNav.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const NavContainer = styled('div')`
2323
width: 16rem;
2424
min-width: 16rem;
2525
height: 100%;
26-
background-color: ${props => props.theme.colors.default.primaryDark};
26+
background-color: ${props => props.theme.colors.default.leftNav.bg};
2727
overflow-y: scroll;
2828
2929
-ms-overflow-style: none;
@@ -38,16 +38,19 @@ const StyledLastItem = styled('div')`
3838
`;
3939

4040
const MenuItem = styled(Link)`
41-
background: ${props => (props.selected ? 'white' : 'transparent')};
41+
background: ${props =>
42+
props.selected
43+
? props.theme.colors.default.leftNav.highlight
44+
: 'transparent'};
4245
:hover {
4346
background: ${props => props.theme.colors.default.primary};
4447
}
4548
padding: 0.5625rem 0rem 0.75rem 3.25rem;
4649
text-transform: uppercase;
47-
${props =>
50+
color: ${props =>
4851
props.selected
49-
? `color: ${props.theme.colors.default.primary};`
50-
: 'color: #6e7d7f;'}
52+
? props.theme.colors.default.primary
53+
: props.theme.colors.default.leftNav.text};
5154
font-family: ${props => props.theme.typography.primary.bold};
5255
cursor: pointer;
5356
display: block;

src/store/actions/appActions.js

+8
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export const actions = keyMirror(
1212
'DEACTIVATE_PROGRESS_INDICATOR',
1313
'TOGGLE_THEME',
1414
'SET_THEME',
15+
'SET_CUSTOM_THEME',
1516
'SET_GLOBAL_ERROR_MESSAGE',
1617
'CLEAR_GLOBAL_ERROR_MESSAGE',
1718
'SET_LOCALE',
@@ -84,6 +85,13 @@ export const setThemeFromLocalStorage = {
8485
payload: localStorage.getItem('theme'),
8586
};
8687

88+
export const setCustomTheme = customColors => {
89+
return {
90+
type: actions.SET_CUSTOM_THEME,
91+
payload: customColors,
92+
};
93+
};
94+
8795
export const toggleTheme = {
8896
type: actions.TOGGLE_THEME,
8997
};

src/store/reducers/appReducer.js

+4
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ import u from 'updeep';
22

33
import { actions as appActions } from '../actions/appActions';
44
import constants from '../../constants';
5+
import theme from '../../theme';
56

67
const initialState = {
78
showProgressOverlay: false,
89
theme: constants.THEME.DEFAULT,
910
errorMessage: null,
1011
locale: null,
12+
customTheme: theme,
1113
connectionCheck: true,
1214
notification: null,
1315
refresh: false,
@@ -62,6 +64,8 @@ const appReducer = (state = initialState, action) => {
6264
: constants.THEME.DARK;
6365
localStorage.setItem('theme', theme);
6466
return u({ theme }, state);
67+
case appActions.SET_CUSTOM_THEME:
68+
return u({ customTheme: action.payload }, state);
6569

6670
case appActions.CONNECTION_CHECK:
6771
return u({ connectionCheck: action.payload }, state);

src/theme.js

+5
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ const colors = {
3737
background: '#F0F2F5',
3838
onSurface: '#000000',
3939
onButton: '#FFFFFF',
40+
leftNav: {
41+
bg: 'rgb(240, 242, 245)',
42+
text: '#6e7d7f',
43+
highlight: '#fff',
44+
},
4045
status: {
4146
info: {
4247
primary: '#91D5FF',

0 commit comments

Comments
 (0)