Skip to content

Commit

Permalink
more component setup
Browse files Browse the repository at this point in the history
  • Loading branch information
dwilt committed Feb 15, 2018
1 parent bb52bd4 commit 222c0d1
Show file tree
Hide file tree
Showing 17 changed files with 62 additions and 58 deletions.
4 changes: 2 additions & 2 deletions src/components/App/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import React, { Component } from 'react';
import './App.css';

import {
AssessmentQuiz
Quiz
} from 'components';

class App extends Component {
render() {
return (
<div className={`App`}>
<AssessmentQuiz/>
<Quiz />
</div>
);
}
Expand Down

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion src/components/AssessmentQuiz/AssessmentQuiz/index.js

This file was deleted.

This file was deleted.

This file was deleted.

2 changes: 0 additions & 2 deletions src/components/AssessmentQuiz/index.js

This file was deleted.

33 changes: 33 additions & 0 deletions src/components/QuestionAnswer/QuestionAnswer.component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React, { PureComponent } from 'react';

import Highlight from 'react-highlight';

import Markdown from 'react-remarkable';

import PropTypes from 'prop-types';

import './QuestionAnswer.css';

export default class QuestionAnswer extends PureComponent {
static propTypes = {
text: PropTypes.string.isRequired,
type: PropTypes.oneOf([
`code`,
`markdown`,
]),
};

static defaultProps = {
type: `markdown`,
};

render() {
const { type, text } = this.props;

return type === `code` ? (
<Highlight className={`javascript`}>{text}</Highlight>
) : (
<Markdown>{text}</Markdown>
);
}
}
3 changes: 3 additions & 0 deletions src/components/QuestionAnswer/QuestionAnswer.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.QuestionAnswer {

}
1 change: 1 addition & 0 deletions src/components/QuestionAnswer/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as QuestionAnswer } from './QuestionAnswer.component';
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,17 @@ const answers = [
},
];

const incorrectFeedback = `This is a basic question. If this wasn't a mistake input, you need to learn the fundamentals of Javascript.`;

export default class VariableDeclarationQuestion extends PureComponent {
static propTypes = {};

export default class VariableDeclaration extends PureComponent {
render() {
const {} = this.props;

return (
<QuizQuestion
codeFigure={codeFigure}
question={question}
answers={answers}
incorrectFeedback={incorrectFeedback}
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { connect } from 'react-redux';

import VariableDeclaration from './VariableDeclaration.component';

export default VariableDeclaration;
1 change: 1 addition & 0 deletions src/components/Questions/VariableDeclaration/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as VariableDeclaration } from './VariableDeclaration.container';
1 change: 1 addition & 0 deletions src/components/Questions/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './VariableDeclaration';
10 changes: 2 additions & 8 deletions src/components/Quiz/Quiz.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,16 @@ import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';

import {
QuizQuestion
VariableDeclaration,
} from 'components';

import './Quiz.css';

export default class Quiz extends PureComponent {
static propTypes = {
children: PropTypes.array,
};

render() {
const {children} = this.props;

return (
<div className={`Quiz`}>
{children}
<VariableDeclaration/>
</div>
);
}
Expand Down
15 changes: 9 additions & 6 deletions src/components/QuizQuestion/QuizQuestion.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import Highlight from 'react-highlight';

import Markdown from 'react-remarkable';

import {
QuestionAnswer,
} from 'components';

import 'highlight.js/styles/github-gist.css';

import PropTypes from 'prop-types';
Expand All @@ -14,13 +18,12 @@ export default class QuizQuestion extends PureComponent {
static propTypes = {
codeFigure: PropTypes.string,
question: PropTypes.string.isRequired,
answers: PropTypes.arrayOf(PropTypes.shape({
text: PropTypes.string.isRequired,
}))
answers: PropTypes.array,
incorrectFeedback: PropTypes.node,
};

render() {
const { codeFigure, question, answers } = this.props;
const { codeFigure, question, answers, incorrectFeedback } = this.props;

return (
<div className={`QuizQuestion`}>
Expand All @@ -33,10 +36,10 @@ export default class QuizQuestion extends PureComponent {
<Markdown>{question}</Markdown>
</div>
<ol className={`QuizQuestion__answers-list`}>
{answers.map(({ text }, i) => {
{answers.map((answer = {}, i) => {
return (
<li key={i}>
<Highlight className={`javascript`}>{text}</Highlight>
<QuestionAnswer {...answer} />
</li>
);
})}
Expand Down
3 changes: 2 additions & 1 deletion src/components/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './App';
export * from './AssessmentQuiz';
export * from './QuestionAnswer';
export * from './Questions';
export * from './Quiz';
export * from './QuizQuestion';

0 comments on commit 222c0d1

Please sign in to comment.