Files
freeCodeCamp/common/app/routes/Hikes/components/Lecture.jsx

72 lines
1.7 KiB
JavaScript
Raw Normal View History

2015-07-09 00:29:29 -07:00
import React, { PropTypes } from 'react';
2015-07-15 23:36:33 -07:00
import { Button, Col, Row, Panel } from 'react-bootstrap';
import { History } from 'react-router';
2015-07-09 00:29:29 -07:00
import Vimeo from 'react-vimeo';
import debugFactory from 'debug';
const debug = debugFactory('freecc:hikes');
2015-07-19 13:36:35 -07:00
export default React.createClass({
displayName: 'Lecture',
mixins: [History],
2015-07-09 00:29:29 -07:00
propTypes: {
currentHike: PropTypes.object,
params: PropTypes.object
},
handleError: debug,
2015-07-15 20:50:11 -07:00
handleFinish() {
debug('loading questions');
const { dashedName } = this.props.params;
this.history.pushState(null, `/hikes/${dashedName}/questions/1`);
},
2015-07-14 23:44:21 -07:00
renderTranscript(transcript, dashedName) {
return transcript.map((line, index) => (
<p key={ dashedName + index }>{ line }</p>
));
},
2015-07-16 09:04:57 -07:00
render() {
const {
title,
challengeSeed = ['1'],
description = []
} = this.props.currentHike;
const { dashedName } = this.props.params;
2015-07-14 23:06:54 -07:00
const [ id ] = challengeSeed;
2015-07-09 00:29:29 -07:00
const videoTitle = <h2>{ title }</h2>;
return (
<Col xs={ 12 }>
<Row>
<Panel className={ 'text-center' } title={ videoTitle }>
<Vimeo
onError={ this.handleError }
2015-07-20 14:55:27 -07:00
onFinish= { this.handleFinish }
videoId={ id } />
</Panel>
</Row>
<Row>
<Col xs={ 12 }>
<Panel>
{ this.renderTranscript(description, dashedName) }
</Panel>
<Panel>
<Button
block={ true }
bsSize='large'
2015-07-20 14:55:27 -07:00
onClick={ this.handleFinish }>
Take me to the Questions
</Button>
</Panel>
</Col>
</Row>
</Col>
);
}
2015-07-19 13:36:35 -07:00
});