2019-08-24 05:04:51 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { BrowserRouter as Router, Route, Link } from 'react-router-dom';
|
|
|
|
import './Style-light.css';
|
|
|
|
import './Style-dark.css';
|
2019-08-25 07:46:58 +00:00
|
|
|
import './fonts/Fonts.css';
|
2019-08-24 05:04:51 +00:00
|
|
|
import Feed from './Feed.js';
|
|
|
|
import Article from './Article.js';
|
|
|
|
import Comments from './Comments.js';
|
2019-08-30 06:22:26 +00:00
|
|
|
import ScrollToTop from './ScrollToTop.js';
|
2019-08-24 05:04:51 +00:00
|
|
|
|
|
|
|
class App extends React.Component {
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
theme: localStorage.getItem('theme') || '',
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
light() {
|
|
|
|
this.setState({ theme: '' });
|
|
|
|
localStorage.setItem('theme', '');
|
|
|
|
}
|
|
|
|
|
|
|
|
dark() {
|
|
|
|
this.setState({ theme: 'dark' });
|
|
|
|
localStorage.setItem('theme', 'dark');
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const theme = this.state.theme;
|
2019-08-25 07:46:58 +00:00
|
|
|
document.body.style.backgroundColor = theme === 'dark' ? '#000' : '#eeeeee';
|
2019-08-24 05:04:51 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={theme}>
|
|
|
|
<Router>
|
|
|
|
<div className='container menu'>
|
|
|
|
<p>
|
|
|
|
<Link to='/'>QNN - Home</Link>
|
|
|
|
<span className='theme'>Theme: <a href='#' onClick={() => this.light()}>Light</a> - <a href='#' onClick={() => this.dark()}>Dark</a></span>
|
2019-08-25 01:25:28 +00:00
|
|
|
<br />
|
|
|
|
<span className='slogan'>Reddit, Hacker News, and Tildes combined, then pre-rendered in reader mode.</span>
|
2019-08-24 05:04:51 +00:00
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
<Route path='/' exact component={Feed} />
|
|
|
|
<Route path='/:id' exact component={Comments} />
|
|
|
|
<Route path='/:id/a' exact component={Article} />
|
2019-08-30 06:22:26 +00:00
|
|
|
|
|
|
|
<ScrollToTop />
|
2019-08-24 05:04:51 +00:00
|
|
|
</Router>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default App;
|