From 2312d5e82e96475d39bdf720972f715dc6d3516b Mon Sep 17 00:00:00 2001 From: Mrugesh Mohapatra Date: Fri, 29 Jun 2018 19:00:05 +0530 Subject: [PATCH] fix(theme): add night mode to learn --- packages/learn/src/layouts/index.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/learn/src/layouts/index.js b/packages/learn/src/layouts/index.js index 865149aae2..0ce387b6b1 100644 --- a/packages/learn/src/layouts/index.js +++ b/packages/learn/src/layouts/index.js @@ -8,12 +8,13 @@ import ga from '../analytics'; import Header from '../components/Header'; import DonationModal from '../components/Donation'; -import { fetchUser } from '../redux/app'; +import { fetchUser, userSelector } from '../redux/app'; import 'prismjs/themes/prism.css'; import 'react-reflex/styles.css'; import './global.css'; import './layout.css'; +import { createSelector } from 'reselect'; const metaKeywords = [ 'javascript', @@ -39,13 +40,17 @@ const metaKeywords = [ 'programming' ]; -const mapStateToProps = () => ({}); +const mapStateToProps = createSelector( + userSelector, + ({ theme = 'default' }) => ({ theme }) +); const mapDispatchToProps = dispatch => bindActionCreators({ fetchUser }, dispatch); const propTypes = { children: PropTypes.func, - fetchUser: PropTypes.func.isRequired + fetchUser: PropTypes.func.isRequired, + theme: PropTypes.string }; class Layout extends PureComponent { @@ -76,7 +81,7 @@ class Layout extends PureComponent { } } render() { - const { children } = this.props; + const { children, theme } = this.props; return (
-
+
{children()}