fix(theme): add night mode to learn

This commit is contained in:
Mrugesh Mohapatra
2018-06-29 19:00:05 +05:30
parent 776d567cea
commit 2312d5e82e

View File

@@ -8,12 +8,13 @@ import ga from '../analytics';
import Header from '../components/Header'; import Header from '../components/Header';
import DonationModal from '../components/Donation'; import DonationModal from '../components/Donation';
import { fetchUser } from '../redux/app'; import { fetchUser, userSelector } from '../redux/app';
import 'prismjs/themes/prism.css'; import 'prismjs/themes/prism.css';
import 'react-reflex/styles.css'; import 'react-reflex/styles.css';
import './global.css'; import './global.css';
import './layout.css'; import './layout.css';
import { createSelector } from 'reselect';
const metaKeywords = [ const metaKeywords = [
'javascript', 'javascript',
@@ -39,13 +40,17 @@ const metaKeywords = [
'programming' 'programming'
]; ];
const mapStateToProps = () => ({}); const mapStateToProps = createSelector(
userSelector,
({ theme = 'default' }) => ({ theme })
);
const mapDispatchToProps = dispatch => const mapDispatchToProps = dispatch =>
bindActionCreators({ fetchUser }, dispatch); bindActionCreators({ fetchUser }, dispatch);
const propTypes = { const propTypes = {
children: PropTypes.func, children: PropTypes.func,
fetchUser: PropTypes.func.isRequired fetchUser: PropTypes.func.isRequired,
theme: PropTypes.string
}; };
class Layout extends PureComponent { class Layout extends PureComponent {
@@ -76,7 +81,7 @@ class Layout extends PureComponent {
} }
} }
render() { render() {
const { children } = this.props; const { children, theme } = this.props;
return ( return (
<Fragment> <Fragment>
<Helmet <Helmet
@@ -91,7 +96,7 @@ class Layout extends PureComponent {
]} ]}
/> />
<Header /> <Header />
<div className='app-wrapper'> <div className={'app-wrapper ' + theme}>
<main>{children()}</main> <main>{children()}</main>
</div> </div>
<DonationModal /> <DonationModal />