diff options
author | Renard | 2019-09-22 00:28:21 -0300 |
---|---|---|
committer | Renard | 2019-09-22 00:28:21 -0300 |
commit | 4f42b5a2b35cf61d6042562195755699f9de177f (patch) | |
tree | d874b49c0aeaa1d98ad9aea978c2f417b6788806 /src/App.js | |
parent | 8db5e7649c1d3ceba35cc52e191da1d264994f45 (diff) | |
download | bai-client-4f42b5a2b35cf61d6042562195755699f9de177f.tar.gz bai-client-4f42b5a2b35cf61d6042562195755699f9de177f.tar.xz bai-client-4f42b5a2b35cf61d6042562195755699f9de177f.zip |
Nightmode
Diffstat (limited to 'src/App.js')
-rw-r--r-- | src/App.js | 43 |
1 files changed, 39 insertions, 4 deletions
@@ -22,8 +22,10 @@ class App extends Component { super(); this.state = { boardList: [], - isLoaded: false + isLoaded: false, + nightMode: true }; + this.toggleTheme = this.toggleTheme.bind(this); } componentDidMount() { @@ -36,6 +38,18 @@ class App extends Component { }); } + componentDidUpdate() { + if (this.state.nightMode) { + document.body.style.backgroundColor = "#313233"; + } else { + document.body.style.backgroundColor = "#FFFFFF"; + } + } + + toggleTheme() { + this.setState({ nightMode: !this.state.nightMode }); + } + render() { if (!this.state.isLoaded) { if (!this.state.isLoaded) { @@ -87,15 +101,36 @@ class App extends Component { )} </Dropdown.Menu> </Dropdown> + <Menu.Menu position="right"> + <Menu.Item as="a" onClick={this.toggleTheme}> + {this.state.nightMode ? ( + <Icon name="sun" /> + ) : ( + <Icon name="moon" /> + )} + </Menu.Item> + </Menu.Menu> </Container> </Menu> <Container className="main"> <Router> - <Home boardList={this.state.boardList} path="/" /> - <Thread boardList={this.state.boardList} path="/:dir/read/:id"> + <Home + boardList={this.state.boardList} + path="/" + nightMode={this.state.nightMode} + /> + <Thread + boardList={this.state.boardList} + path="/:dir/read/:id" + nightMode={this.state.nightMode} + > <Thread path=":active" /> </Thread> - <Board boardList={this.state.boardList} path="/board/:dir" /> + <Board + boardList={this.state.boardList} + path="/board/:dir" + nightMode={this.state.nightMode} + /> <NotFound default /> </Router> </Container> |