Skip to content

Commit 814a9ef

Browse files
Tuong TranTuong Tran
authored andcommitted
Update UI in Dark Mode
1 parent d8e7c9d commit 814a9ef

File tree

5 files changed

+22
-9
lines changed

5 files changed

+22
-9
lines changed

src/App.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff 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">

src/Components/Herocontent.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { Fragment } from 'react';
22
import 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

src/Components/Main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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">

src/Components/Navigation.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import React from "react";
22
import { 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">

src/style.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
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;

0 commit comments

Comments
 (0)