File tree Expand file tree Collapse file tree 5 files changed +22
-9
lines changed
Expand file tree Collapse file tree 5 files changed +22
-9
lines changed Original file line number Diff line number Diff line change @@ -19,10 +19,17 @@ class App extends React.Component {
1919 super ( props ) ;
2020 this . state = {
2121 count : 5 ,
22- posts1 : [ ]
22+ posts1 : [ ] ,
23+ isDark : false
2324 }
2425 }
2526
27+ isDarkTheme = ( dark ) => {
28+ this . setState ( {
29+ isDark : dark
30+ } )
31+ }
32+
2633 componentDidMount ( ) {
2734 var newPosts = [ ] ;
2835 const posts = markdownFiles . forEach (
@@ -96,8 +103,10 @@ class App extends React.Component {
96103 return (
97104 < div >
98105 < BrowserRouter >
99- < Navigation />
100- < Route exact path = "/" component = { Herocontent } />
106+ < Navigation dark = { this . isDarkTheme } />
107+ < Route exact path = "/" component = { ( ) => (
108+ < Herocontent isDark = { this . state . isDark } />
109+ ) } />
101110 < Route path = "/login" component = { Login } />
102111 < Fragment >
103112 < section className = "section" >
Original file line number Diff line number Diff line change 11import React , { Fragment } from 'react' ;
22import Main from './Main' ;
33
4- const Herocontent = ( ) => (
4+ const Herocontent = ( props ) => (
55 < Fragment >
66 < div className = "main thememain-blue" >
77 < div className = "container main hero-content-main" >
@@ -32,7 +32,7 @@ const Herocontent = () => (
3232 </ div >
3333 </ div >
3434 </ div >
35- < Main />
35+ < Main isDark = { props . isDark } />
3636 </ Fragment >
3737) ;
3838
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ class Main extends React.Component {
1818
1919 render ( ) {
2020 return (
21- < div className = " main thememain-white" >
21+ < div className = { this . props . isDark ? ' main thememain-dark' : 'main thememain- white' } >
2222 {
2323 titleMetaData . map ( ( title ) =>
2424 < div className = "container content-main" >
Original file line number Diff line number Diff line change 11import React from "react" ;
22import { Link } from 'react-router-dom' ;
33
4- const Navigation = ( ) => {
4+ const Navigation = ( props ) => {
55 const [ currentmode , changeState ] = React . useState ( "Light Mode" ) ;
66 const DocBody = document . getElementById ( "Apptheme" ) ;
77 const changemode = ( ) => {
88 currentmode === "Light Mode"
9- ? ( ( DocBody . className = "thememain-dark" ) , changeState ( "Dark Mode" ) )
10- : ( ( DocBody . className = "thememain-white " ) , changeState ( "Light Mode" ) ) ;
9+ ? ( ( DocBody . className = "thememain-dark" ) , changeState ( "Dark Mode" ) , props . dark ( true ) )
10+ : ( ( DocBody . className = "thememain-white " ) , changeState ( "Light Mode" ) , props . dark ( false ) ) ;
1111 } ;
1212 return (
1313 < div className = "main thememain-header" >
Original file line number Diff line number Diff line change 3737 background : # fff ;
3838}
3939
40+ .thememain-white h3 {
41+ color : # 333 ;
42+ }
43+
4044.thememain-white .thememain-header {
4145 background : linear-gradient (165deg , # 6e60cc, # 484389 );
4246 color : # fff ;
You can’t perform that action at this time.
0 commit comments