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

83 lines
1.6 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 PureComponent from 'react-pure-render/component';
import { Col, Row, Image } from 'react-bootstrap';
2016-10-29 00:46:45 +01:00
2016-06-07 20:41:42 -07:00
import SidePanel from './Side-Panel.jsx';
import ToolPanel from './Tool-Panel.jsx';
import BugModal from '../../Bug-Modal.jsx';
2016-06-03 18:37:53 -07:00
import { challengeSelector } from '../../redux/selectors';
const mapStateToProps = createSelector(
challengeSelector,
(
{
challenge: {
id,
description,
image
2016-10-29 00:46:45 +01:00
} = {},
title
2016-06-07 20:41:42 -07:00
}
2016-06-03 18:37:53 -07:00
) => ({
id,
image,
2016-06-03 18:37:53 -07:00
title,
2016-06-07 20:41:42 -07:00
description
2016-06-03 18:37:53 -07:00
})
);
2017-01-12 06:54:43 +00:00
const propTypes = {
description: PropTypes.arrayOf(PropTypes.string),
id: PropTypes.string,
image: PropTypes.string,
2017-01-12 06:54:43 +00:00
isCompleted: PropTypes.bool,
title: PropTypes.string
2017-01-12 06:54:43 +00:00
};
2016-06-03 18:37:53 -07:00
export class Project extends PureComponent {
render() {
const {
id,
title,
image,
2016-06-03 18:37:53 -07:00
isCompleted,
2016-06-07 20:41:42 -07:00
description
2016-06-03 18:37:53 -07:00
} = this.props;
const imageURL = '//i.imgur.com/' + image + '.png';
2016-06-03 18:37:53 -07:00
return (
<Row>
2016-06-03 18:37:53 -07:00
<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
>
<Image
id={ id }
responsive={ true }
src={ imageURL }
/>
2016-06-03 18:37:53 -07:00
<br />
2016-06-07 20:41:42 -07:00
<ToolPanel />
2016-06-03 18:37:53 -07:00
<br />
<BugModal />
2016-06-03 18:37:53 -07:00
</Col>
</Row>
2016-06-03 18:37:53 -07:00
);
}
}
2017-01-12 06:54:43 +00:00
Project.displayName = 'Project';
Project.propTypes = propTypes;
2016-06-03 18:37:53 -07:00
export default connect(
2016-06-07 20:41:42 -07:00
mapStateToProps
2016-06-03 18:37:53 -07:00
)(Project);