Moving supported syntax list to gatsby-config

This commit is contained in:
Jeff Avallone
2019-01-13 11:33:33 -05:00
parent 152cf7f7b3
commit c3116bf5b6
4 changed files with 53 additions and 15 deletions
+9 -3
View File
@@ -93,7 +93,8 @@ class App extends React.PureComponent {
const {
syntax,
expr,
permalinkUrl
permalinkUrl,
syntaxList
} = this.props;
const {
loading,
@@ -105,7 +106,8 @@ class App extends React.PureComponent {
const formProps = {
onSubmit: this.handleSubmit,
syntax,
expr
expr,
syntaxList
};
const actionProps = {
imageDetails,
@@ -137,7 +139,11 @@ class App extends React.PureComponent {
App.propTypes = {
syntax: PropTypes.string,
expr: PropTypes.string,
permalinkUrl: PropTypes.string
permalinkUrl: PropTypes.string,
syntaxList: PropTypes.arrayOf(PropTypes.shape({
id: PropTypes.string,
label: PropTypes.string
}))
};
export default App;
+5 -5
View File
@@ -5,11 +5,6 @@ import ExpandIcon from 'react-feather/dist/icons/chevrons-down';
import style from './style.module.css';
const syntaxList = [
{ id: 'js', label: 'JavaScript' },
{ id: 'pcre', label: 'PCRE' }
];
class Form extends React.PureComponent {
state = {
expr: this.props.expr,
@@ -36,6 +31,7 @@ class Form extends React.PureComponent {
render() {
const {
syntaxList,
children
} = this.props;
const { expr, syntax } = this.state;
@@ -70,6 +66,10 @@ class Form extends React.PureComponent {
Form.propTypes = {
expr: PropTypes.string,
syntax: PropTypes.string,
syntaxList: PropTypes.arrayOf(PropTypes.shape({
id: PropTypes.string,
label: PropTypes.string
})),
onSubmit: PropTypes.func.isRequired,
children: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.node),