From 0dd7ce50d2383b3a7b6f9ceafd080b243cbc7de8 Mon Sep 17 00:00:00 2001 From: wildscotsmen Date: Thu, 29 Nov 2018 23:55:21 -0500 Subject: [PATCH] Added theme swapping. --- src/components/Main.js | 182 ++++++++++++++++++++++++++--------------- 1 file changed, 117 insertions(+), 65 deletions(-) diff --git a/src/components/Main.js b/src/components/Main.js index d3bde39..95ed1b3 100644 --- a/src/components/Main.js +++ b/src/components/Main.js @@ -33,6 +33,9 @@ import ExpandLess from '@material-ui/icons/ExpandLess'; import ExpandMore from '@material-ui/icons/ExpandMore'; import Collapse from '@material-ui/core/Collapse'; import FlameLinkCollectionGallery from '../components/FlameLinkCollectionGallery'; +import { MuiThemeProvider, createMuiTheme } from '@material-ui/core/styles'; +import Switch from '@material-ui/core/Switch'; +import indigo from '@material-ui/core/colors/indigo'; const drawerWidth = 240; @@ -77,6 +80,17 @@ class ResponsiveDrawer extends React.Component { key: 'Home', open: false, open2: false, + theme: createMuiTheme({ + typography: { + useNextVariants: true, + }, + palette: { + primary: indigo, + secondary: indigo + } + }), + themeName: 'light', + themeChecked: true }; handleDrawerToggle = () => { @@ -97,8 +111,38 @@ class ResponsiveDrawer extends React.Component { }); } + handleChange = name => event => { + this.setState({ [name]: event.target.checked }); + if (this.state.themeName === 'light') { + this.setState({ + themeName: 'dark', + theme: createMuiTheme({ + typography: { + useNextVariants: true, + }, + palette: { + type: 'dark' + } + }) + }) + } else { + this.setState({ + themeName: 'light', + theme: createMuiTheme({ + typography: { + useNextVariants: true, + }, + palette: { + primary: indigo, + secondary: indigo + } + }) + }) + } + }; + render() { - const { classes, theme } = this.props; + const { classes } = this.props; const drawer = (
@@ -178,70 +222,78 @@ class ResponsiveDrawer extends React.Component { ); return ( -
- - - - - - - - Marten Tracker - - - - -
-
- {this.state.key === 'Home' && } - {this.state.key === 'Report' && } - {this.state.key === 'Map' && } - {this.state.key === 'List' && } - {this.state.key === 'About' && } - {this.state.key === 'Contact' && } - {this.state.key === 'Easy-Quiz' && } - {this.state.key === 'Intermediate-Quiz' && } - {this.state.key === 'Advanced-Quiz' && } - {this.state.key === 'Gallery1' && } - {this.state.key === 'Gallery2' && } - {this.state.key === 'Gallery3' && } - {this.state.key === 'Gallery4' && } -
-
+ +
+ + + + + + + + Marten Tracker + + + + + +
+
+ {this.state.key === 'Home' && } + {this.state.key === 'Report' && } + {this.state.key === 'Map' && } + {this.state.key === 'List' && } + {this.state.key === 'About' && } + {this.state.key === 'Contact' && } + {this.state.key === 'Easy-Quiz' && } + {this.state.key === 'Intermediate-Quiz' && } + {this.state.key === 'Advanced-Quiz' && } + {this.state.key === 'Gallery1' && } + {this.state.key === 'Gallery2' && } + {this.state.key === 'Gallery3' && } + {this.state.key === 'Gallery4' && } +
+
+
); } }