diff --git a/common/app/routes/challenges/components/Challenges.jsx b/common/app/routes/challenges/components/Challenges.jsx
index 46629e6f99..5f2fc05d7e 100644
--- a/common/app/routes/challenges/components/Challenges.jsx
+++ b/common/app/routes/challenges/components/Challenges.jsx
@@ -1,19 +1,72 @@
-import React from 'react';
-
+import React, { PropTypes } from 'react';
+import { compose } from 'redux';
+import { contain } from 'redux-epic';
+import { connect } from 'react-redux';
+import { createSelector } from 'reselect';
import PureComponent from 'react-pure-render/component';
-// import Challenge from './Challenge.jsx';
+import Challenge from './Challenge.jsx';
import Step from './step/Step.jsx';
+import { fetchChallenge } from '../../../redux/actions';
+import { STEP, HTML } from '../../../utils/challengeTypes';
+const bindableActions = {
+ fetchChallenge
+};
-//
-export default class extends PureComponent {
+const challengeSelector = createSelector(
+ state => state.challengesApp.challenge,
+ state => state.entities.challenge,
+ (challengeName, challengeMap) => {
+ const challenge = challengeMap[challengeName];
+ return {
+ challenge: challenge,
+ showPreview: !!challenge && challenge.challengeType === HTML,
+ isStep: !!challenge && challenge.challengeType === STEP,
+ mode: !!challenge && challenge.challengeType === HTML ?
+ 'text/html' :
+ 'javascript'
+ };
+ }
+);
+
+const mapStateToProps = createSelector(
+ challengeSelector,
+ state => state.challengesApp.content,
+ (challengeProps, content) => ({
+ ...challengeProps,
+ content
+ })
+);
+
+const fetchOptions = {
+ fetchAction: 'fetchChallenge',
+ getActionArgs({ params: { dashedName } }) {
+ return [ dashedName ];
+ },
+ isPrimed({ challenge }) {
+ return challenge;
+ }
+};
+
+export class Challenges extends PureComponent {
static displayName = 'Challenges';
- static propTypes = {};
+ static propTypes = {
+ challenge: PropTypes.object,
+ showPreview: PropTypes.bool,
+ mode: PropTypes.string,
+ isStep: PropTypes.bool
+ };
render() {
- return (
-
- );
+ if (this.props.isStep) {
+ return ;
+ }
+ return ;
}
}
+
+export default compose(
+ connect(mapStateToProps, bindableActions),
+ contain(fetchOptions)
+)(Challenges);
diff --git a/common/app/routes/challenges/components/Editor.jsx b/common/app/routes/challenges/components/Editor.jsx
index 69546ae6e6..17d08499b5 100644
--- a/common/app/routes/challenges/components/Editor.jsx
+++ b/common/app/routes/challenges/components/Editor.jsx
@@ -28,11 +28,18 @@ const options = {
export class Editor extends PureComponent {
static displayName = 'Editor';
static propTypes = {
- height: PropTypes.number
+ height: PropTypes.number,
+ content: PropTypes.string,
+ mode: PropTypes.string
+ };
+
+ static defaultProps = {
+ content: '// Happy Coding!',
+ mode: 'javascript'
};
render() {
- const { height } = this.props;
+ const { content, height, mode } = this.props;
const style = {};
if (height) {
style.height = height + 'px';
@@ -43,8 +50,8 @@ export class Editor extends PureComponent {
style={ style }>
+ options={{ ...options, mode }}
+ value={ content } />
);
diff --git a/common/app/routes/challenges/components/Side-Panel.jsx b/common/app/routes/challenges/components/Side-Panel.jsx
index e3964516f1..1d93526c5a 100644
--- a/common/app/routes/challenges/components/Side-Panel.jsx
+++ b/common/app/routes/challenges/components/Side-Panel.jsx
@@ -15,20 +15,6 @@ const mapStateToProps = createSelector(
(windowHeight, navHeight) => ({ height: windowHeight - navHeight - 50 })
);
-/* eslint-disable max-len */
-const description = [
- 'Comments are lines of code that JavaScript will intentionally ignore. Comments are a great way to leave notes to yourself and to other people who will later need to figure out what that code does.',
- 'There are two ways to write comments in JavaScript:',
- 'Using // will tell JavaScript to ignore the remainder of the text on the current line:',
- '
// This is an in-line comment.
',
- 'You can make a multi-line comment beginning with /* and ending with */:',
- '
/* This is a multi-line comment */
',
- 'Best Practice As you write code, you should regularly add comments to clarify the function of parts of your code. Good commenting can help communicate the intent of your code—both for others and for your future self.',
- '
diff --git a/common/app/routes/challenges/components/step/Step.jsx b/common/app/routes/challenges/components/step/Step.jsx
index 4b66d86f8d..9941d486db 100644
--- a/common/app/routes/challenges/components/step/Step.jsx
+++ b/common/app/routes/challenges/components/step/Step.jsx
@@ -8,6 +8,7 @@ import ReactTransitionReplace from 'react-css-transition-replace';
import { Button, Col, Image, Row } from 'react-bootstrap';
+const transitionTimeout = 1000;
const mapStateToProps = createSelector(
state => state.challengesApp.currentStep,
state => state.challengesApp.previousStep,
@@ -22,87 +23,6 @@ const dispatchActions = {
goToStep
};
-const transitionTimeout = 1000;
-/* eslint-disable max-len, quotes */
-const challenge = {
- title: "Learn how Free Code Camp Works",
- description: [
- [
- "http://i.imgur.com/6ibIavQ.jpg",
- "A picture of Free Code Camp's 4 benefits: Get connected, Learn JavaScript, Build your Portfolio, Help nonprofits",
- "Welcome to Free Code Camp. We're an open source community of busy people who learn to code and help nonprofits.",
- "http://www.foo.com"
- ],
- [
- "http://i.imgur.com/Elb3dfj.jpg",
- "A screenshot of some of our campers coding together in Toronto.",
- "Learning to code is hard. To succeed, you'll need lots of practice and support. That's why we've created a rigorous curriculum and supportive community.",
- ""
- ],
- [
- "http://i.imgur.com/D7Y5luw.jpg",
- "A graph of the rate of job growth against growth in computer science degree graduates. There are 1.4 million jobs and only 400 thousand people to fill them.",
- "There are thousands of coding jobs currently going unfilled, and the demand for coders grows every year.",
- ""
- ],
- [
- "http://i.imgur.com/WD3STY6.jpg",
- "Photos of three campers who've gotten jobs after learning to code at Free Code Camp.",
- "Free Code Camp is a proven path to your first coding job. In fact, no one has actually completed our entire program, because campers get jobs before they're able to.",
- ""
- ],
- [
- "http://i.imgur.com/vLNso6h.jpg",
- "An illustration showing that you will learn HTML5, CSS3, JavaScript, Databases, Git, Node.js, React and D3.",
- "We have hundreds of optional coding challenges that will teach you fundamental web development technologies like HTML5, Node.js and databases.",
- ""
- ],
- [
- "http://i.imgur.com/UVB9hxp.jpg",
- "An image of a camper at a cafe building projects on Free Code Camp.",
- "We believe humans learn best by doing. So you'll spend most of your time actually building projects. We'll give you a list of specifications (agile user stories), and you'll figure out how to build apps that fulfill those specifications.",
- ""
- ],
- [
- "http://i.imgur.com/pbW7K5S.jpg",
- "An image of showing our front end, back end, and data visualization certifications (400 hours each), our nonprofit projects (800 hours), and interview prep (80 hours) for a total of 2,080 hours of coding experience.",
- "Our curriculum is divided into 4 certifications. These certifications are standardized, and instantly verifiable by your freelance clients and future employers. Like everything else at Free Code Camp, these certifications are free. We recommend doing them in order, but you are free to jump around. The first three certifications take 400 hours each, and the final certification takes 800 hours, and involves building real-life projects for nonprofits.",
- ""
- ],
- [
- "http://i.imgur.com/k8btNUB.jpg",
- "A screenshot of our Front End Development Certificate",
- "To earn our verified Front End Development Certification, you'll build 10 projects using HTML, CSS, jQuery, and JavaScript.",
- ""
- ],
- [
- "http://i.imgur.com/Et3iD74.jpg",
- "A screenshot of our Data Visualization Certificate",
- "To earn our Data Visualization Certification, you'll build 10 projects using React, Sass and D3.js.",
- ""
- ],
- [
- "http://i.imgur.com/8v3t84p.jpg",
- "A screenshot of our Back End Development Certificate",
- "To earn our Back End Development Certification, you'll build 10 projects using Node.js, Express, and MongoDB. You'll use Git and Heroku to deploy them to the cloud.",
- ""
- ],
- [
- "http://i.imgur.com/yXyxbDd.jpg",
- "A screen shot of our nonprofit project directory.",
- "After you complete all three of these certificates, you'll team up with another camper and use agile software development methodologies to build two real-life projects for nonprofits. You'll also add functionality to two legacy code nonprofit projects. By the time you finish, you'll have a portfolio of real apps that people use every day.",
- ""
- ],
- [
- "http://i.imgur.com/PDGQ9ZM.jpg",
- "An image of campers building projects together in a cafe in Seoul.",
- "If you complete all 2,080 hours worth of challenges and projects, you'll earn our Full Stack Development Certification. We'll offer you free coding interview practice. We even offer a job board where employers specifically hire campers who've earned Free Code Camp certifications.",
- "http://foo.com"
- ]
- ]
-};
-/* eslint-disable max-len, quotes */
-
export class StepChallenge extends PureComponent {
static displayName = 'StepChallenge';
static defaultProps = {
@@ -111,6 +31,7 @@ export class StepChallenge extends PureComponent {
};
static propTypes = {
+ challenge: PropTypes.object,
currentStep: PropTypes.number,
previousStep: PropTypes.number,
isGoingForward: PropTypes.bool,
@@ -163,7 +84,7 @@ export class StepChallenge extends PureComponent {
const isLastStep = index + 1 >= numOfSteps;
const btnClass = classnames({
'col-sm-4 col-xs-12': true,
- 'disabled': hasAction && !isCompleted
+ disabled: hasAction && !isCompleted
});
return (