Files
freeCodeCamp/common/app/routes/challenges/components/project/Project.jsx

84 lines
1.7 KiB
JavaScript
Raw Normal View History

2016-06-03 18:37:53 -07:00
import React, { PropTypes } from 'react';
import { createSelector } from 'reselect';
import { connect } from 'react-redux';
import Youtube from 'react-youtube';
import PureComponent from 'react-pure-render/component';
2016-06-07 20:41:42 -07:00
import { Col } from 'react-bootstrap';
import SidePanel from './Side-Panel.jsx';
import ToolPanel from './Tool-Panel.jsx';
2016-06-03 18:37:53 -07:00
import { challengeSelector } from '../../redux/selectors';
const mapStateToProps = createSelector(
challengeSelector,
(
{
challenge: {
id,
title,
description,
2016-06-07 20:41:42 -07:00
challengeSeed: [ videoId = '' ] = []
2016-06-03 18:37:53 -07:00
} = {}
2016-06-07 20:41:42 -07:00
}
2016-06-03 18:37:53 -07:00
) => ({
id,
videoId,
title,
2016-06-07 20:41:42 -07:00
description
2016-06-03 18:37:53 -07:00
})
);
export class Project extends PureComponent {
static displayName = 'Project';
static propTypes = {
id: PropTypes.string,
videoId: PropTypes.string,
title: PropTypes.string,
description: PropTypes.arrayOf(PropTypes.string),
2016-06-07 20:41:42 -07:00
isCompleted: PropTypes.bool
2016-06-03 18:37:53 -07:00
};
render() {
const {
id,
title,
videoId,
isCompleted,
2016-06-07 20:41:42 -07:00
description
2016-06-03 18:37:53 -07:00
} = this.props;
return (
<div>
<Col md={ 4 }>
2016-06-07 20:41:42 -07:00
<SidePanel
description={ description }
isCompleted={ isCompleted }
title={ title }
/>
2016-06-03 18:37:53 -07:00
</Col>
<Col
md={ 8 }
xs={ 12 }
2016-06-07 20:41:42 -07:00
>
2016-06-03 18:37:53 -07:00
<div className='embed-responsive embed-responsive-16by9'>
<Youtube
className='embed-responsive-item'
id={ id }
videoId={ videoId }
/>
</div>
<br />
2016-06-07 20:41:42 -07:00
<ToolPanel />
2016-06-03 18:37:53 -07:00
<br />
</Col>
</div>
);
}
}
export default connect(
2016-06-07 20:41:42 -07:00
mapStateToProps
2016-06-03 18:37:53 -07:00
)(Project);