Implemented Markdown panel, wrote an update
This commit is contained in:
@@ -9,7 +9,6 @@ export default class Blurb extends React.Component {
|
||||
<p className='centered'><em>A game in early development.</em></p>
|
||||
<br />
|
||||
<p>This is a resource accumulation game, with some similarities to idle games. The idea is that you recruit new units once per day, train them as soldiers, and send them to attack other players. You can also train spies and scientists, which each grant their own benefits.</p>
|
||||
<p>Untrained recruits gain you 1 gold piece evey half hour - the only unit type that grants a passive income.</p>
|
||||
<p>You can follow the developer KR Game Studios here:</p>
|
||||
<ul>
|
||||
<li><Link to='https://facebook.com/KRGameStudios' /></li>
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import ReactMarkdown from 'react-markdown';
|
||||
|
||||
class Markdown extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
if (this.props.source) {
|
||||
this.state = {
|
||||
data: this.props.source
|
||||
};
|
||||
} else {
|
||||
this.state = {
|
||||
data: ''
|
||||
};
|
||||
this.sendRequest(props.url);
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
if (this.state) {
|
||||
return (<ReactMarkdown source={this.state.data} escapeHtml={false} />);
|
||||
} else {
|
||||
return (<p className='centered'>Loading markdown...</p>);
|
||||
}
|
||||
}
|
||||
|
||||
sendRequest(url, args = {}) {
|
||||
//build the XHR
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', url, true);
|
||||
|
||||
xhr.onreadystatechange = () => {
|
||||
if (xhr.readyState === 4) {
|
||||
if (xhr.status === 200) {
|
||||
//on success
|
||||
this.setState({ data: xhr.responseText });
|
||||
}
|
||||
else if (this.props.setWarning) {
|
||||
this.props.setWarning(xhr.responseText);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
xhr.send();
|
||||
}
|
||||
};
|
||||
|
||||
Markdown.propTypes = {
|
||||
source: PropTypes.string,
|
||||
url: PropTypes.string,
|
||||
setWarning: PropTypes.func
|
||||
};
|
||||
|
||||
export default Markdown;
|
||||
Reference in New Issue
Block a user