2016-03-21 15:39:45 -07:00
|
|
|
import React, { PropTypes } from 'react';
|
2016-03-23 15:01:01 -07:00
|
|
|
import classnames from 'classnames';
|
2016-03-21 15:39:45 -07:00
|
|
|
import PureComponent from 'react-pure-render/component';
|
2016-06-21 12:15:18 -07:00
|
|
|
import { InputGroup, FormControl, Button, Row } from 'react-bootstrap';
|
2016-03-21 15:39:45 -07:00
|
|
|
|
2016-03-22 22:13:05 -07:00
|
|
|
import SuperBlock from './Super-Block.jsx';
|
|
|
|
import FullStack from './Full-Stack.jsx';
|
|
|
|
import CodingPrep from './Coding-Prep.jsx';
|
2016-03-21 15:39:45 -07:00
|
|
|
|
2016-03-23 16:19:16 -07:00
|
|
|
const clearIcon = <i className='fa fa-times' />;
|
|
|
|
const searchIcon = <i className='fa fa-search' />;
|
2016-06-21 12:15:18 -07:00
|
|
|
const ESC = 27;
|
2016-03-21 15:39:45 -07:00
|
|
|
export default class ShowMap extends PureComponent {
|
2016-06-21 12:15:18 -07:00
|
|
|
constructor(...props) {
|
|
|
|
super(...props);
|
|
|
|
this.handleKeyDown = this.handleKeyDown.bind(this);
|
|
|
|
}
|
2016-03-21 15:39:45 -07:00
|
|
|
static displayName = 'Map';
|
|
|
|
static propTypes = {
|
2016-03-23 16:19:16 -07:00
|
|
|
clearFilter: PropTypes.func,
|
2016-03-23 15:01:01 -07:00
|
|
|
filter: PropTypes.string,
|
2016-03-23 16:19:16 -07:00
|
|
|
superBlocks: PropTypes.array,
|
2016-03-23 15:01:01 -07:00
|
|
|
updateFilter: PropTypes.func
|
2016-03-21 15:39:45 -07:00
|
|
|
};
|
|
|
|
|
2016-06-21 12:15:18 -07:00
|
|
|
handleKeyDown(e) {
|
|
|
|
if (e.keyCode === ESC) {
|
|
|
|
this.props.clearFilter();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-10 21:25:12 -07:00
|
|
|
renderSuperBlocks(superBlocks, updateCurrentChallenge) {
|
2016-03-21 15:39:45 -07:00
|
|
|
if (!Array.isArray(superBlocks) || !superBlocks.length) {
|
|
|
|
return <div>No Super Blocks</div>;
|
|
|
|
}
|
|
|
|
return superBlocks.map((superBlock) => {
|
|
|
|
return (
|
2016-03-22 22:13:05 -07:00
|
|
|
<SuperBlock
|
|
|
|
key={ superBlock.title }
|
2016-05-10 21:25:12 -07:00
|
|
|
updateCurrentChallenge={ updateCurrentChallenge }
|
2016-06-21 11:50:58 -07:00
|
|
|
{ ...superBlock }
|
|
|
|
/>
|
2016-03-21 15:39:45 -07:00
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-06-21 12:15:18 -07:00
|
|
|
renderSearchAddon(filter, clearFilter) {
|
|
|
|
if (!filter) {
|
|
|
|
return searchIcon;
|
|
|
|
}
|
|
|
|
return <span onClick={ clearFilter }>{ clearIcon }</span>;
|
|
|
|
}
|
|
|
|
|
2016-03-21 15:39:45 -07:00
|
|
|
render() {
|
2016-05-09 13:42:39 -07:00
|
|
|
const {
|
2016-05-10 21:25:12 -07:00
|
|
|
updateCurrentChallenge,
|
2016-05-09 13:42:39 -07:00
|
|
|
superBlocks,
|
|
|
|
updateFilter,
|
|
|
|
clearFilter,
|
|
|
|
filter
|
|
|
|
} = this.props;
|
2016-03-23 15:01:01 -07:00
|
|
|
const inputClass = classnames({
|
|
|
|
'map-filter': true,
|
|
|
|
filled: !!filter
|
|
|
|
});
|
2016-03-21 15:39:45 -07:00
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<div className='map-wrapper'>
|
|
|
|
<div
|
|
|
|
className='text-center map-fixed-header'
|
2016-06-21 11:50:58 -07:00
|
|
|
style={{ top: '50px' }}
|
|
|
|
>
|
2016-03-21 15:39:45 -07:00
|
|
|
<p>Challenges required for certifications are marked with a *</p>
|
|
|
|
<Row className='map-buttons'>
|
|
|
|
<Button
|
|
|
|
block={ true }
|
|
|
|
bsStyle='primary'
|
2016-06-21 11:50:58 -07:00
|
|
|
className='center-block'
|
|
|
|
>
|
2016-03-21 15:39:45 -07:00
|
|
|
Collapse all challenges
|
|
|
|
</Button>
|
|
|
|
</Row>
|
|
|
|
<Row className='map-buttons'>
|
2016-06-21 12:15:18 -07:00
|
|
|
<InputGroup>
|
|
|
|
<FormControl
|
|
|
|
autocompleted='off'
|
|
|
|
className={ inputClass }
|
|
|
|
onChange={ updateFilter }
|
|
|
|
onKeyDown={ this.handleKeyDown }
|
|
|
|
placeholder='Type a challenge name'
|
|
|
|
type='text'
|
|
|
|
value={ filter }
|
|
|
|
/>
|
|
|
|
<InputGroup.Addon>
|
|
|
|
{ this.renderSearchAddon(filter, clearFilter) }
|
|
|
|
</InputGroup.Addon>
|
|
|
|
</InputGroup>
|
2016-03-21 15:39:45 -07:00
|
|
|
</Row>
|
|
|
|
<hr />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div
|
2016-06-21 11:50:58 -07:00
|
|
|
className='map-accordion'
|
|
|
|
>
|
2016-05-10 21:25:12 -07:00
|
|
|
{ this.renderSuperBlocks(superBlocks, updateCurrentChallenge) }
|
2016-03-22 22:13:05 -07:00
|
|
|
<FullStack />
|
|
|
|
<CodingPrep />
|
2016-03-21 15:39:45 -07:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|