diff --git a/src/images/done.png b/src/images/success.png similarity index 100% rename from src/images/done.png rename to src/images/success.png diff --git a/src/js/App.js b/src/js/App.js index 0c45bcb..eb8dfca 100644 --- a/src/js/App.js +++ b/src/js/App.js @@ -5,20 +5,39 @@ import { Route } from 'react-router-dom' +// Pages import Menu from 'components/Menu' import About from 'components/About' import Thread from 'components/Thread' export default class App extends React.Component { + constructor(props) { + super(props) + + this.state = { + statusText: null, + statusImage: null + } + + this.onStatusChange = this.onStatusChange.bind(this) + } + + handleStatusChange(text, image) { + this.setState({ + statusText: text, + statusImage: image + }) + } + render() { return ( <> - + - + {/* */} diff --git a/src/js/components/Menu.js b/src/js/components/Menu.js index 32b6440..430ac33 100644 --- a/src/js/components/Menu.js +++ b/src/js/components/Menu.js @@ -1,4 +1,5 @@ import React from 'react' +import StatusBox from 'components/StatusBox' export default class Menu extends React.Component { render () { @@ -9,15 +10,12 @@ export default class Menu extends React.Component { Removeddit -
-

- -
+ ) } diff --git a/src/js/components/StatusBox.js b/src/js/components/StatusBox.js index e69de29..971b5c0 100644 --- a/src/js/components/StatusBox.js +++ b/src/js/components/StatusBox.js @@ -0,0 +1,14 @@ +import React from 'react' + +export default class StatusBox extends React.Component { + render() { + return ( +
+ {this.props.text && +

{this.props.text}

} + {this.props.image && + } +
+ ) + } +} \ No newline at end of file diff --git a/src/js/components/Subreddit.js b/src/js/components/Subreddit.js new file mode 100644 index 0000000..ba0ebc2 --- /dev/null +++ b/src/js/components/Subreddit.js @@ -0,0 +1,8 @@ +import React from 'react' + +export default class Thread extends React.Component { + render() { + return

Subreddit

+ } + +} \ No newline at end of file diff --git a/src/js/components/Thread.js b/src/js/components/Thread.js index e07e590..7942b5c 100644 --- a/src/js/components/Thread.js +++ b/src/js/components/Thread.js @@ -1,5 +1,5 @@ import React from 'react' -import {prettyScore} from 'utils' +import {prettyScore, statusImages, redditThumbnails} from 'utils' export default class Thread extends React.Component { constructor() { @@ -12,11 +12,12 @@ export default class Thread extends React.Component { thumbnail: '', position: 0, score: 0 - } } - + handleStateChange(text, image) { + this.props.onStateChange(text, image) + } render () { const url = this.props.url.replace('reddit.com', 'removeddit.com') diff --git a/src/js/pushshift/index.js b/src/js/pushshift/index.js new file mode 100644 index 0000000..e69de29 diff --git a/src/js/reddit/index.js b/src/js/reddit/index.js index 89fa2a5..bce4f20 100644 --- a/src/js/reddit/index.js +++ b/src/js/reddit/index.js @@ -35,8 +35,6 @@ const fetchToken = () => { export default { comments(subreddit, threadID) { return fetchToken() - .then(() => console.log('hi')) } - } \ No newline at end of file diff --git a/src/js/utils.js b/src/js/utils.js index 6d56856..644c8b7 100644 --- a/src/js/utils.js +++ b/src/js/utils.js @@ -2,6 +2,15 @@ import SnuOwnd from 'libraries/snuownd.js' const markdown = SnuOwnd.getParser() +export const redditThumbnails = ['self', 'default', 'image', 'nsfw'] + +// Images for the status box in right side of header +export const statusImages = { + loading: '/images/loading.gif', + error: '/images/error.png', + success: '/images/done.png' +} + // JSON parsing for fetch export const json = x => x.json()