import React, { PropTypes } from 'react'; import ReactDom from 'react-dom'; import { createSelector } from 'reselect'; import { connect } from 'react-redux'; import PureComponent from 'react-pure-render/component'; import { Col, Row } from 'react-bootstrap'; import TestSuite from './Test-Suite.jsx'; import Output from './Output.jsx'; import ToolPanel from './Tool-Panel.jsx'; import { challengeSelector } from '../../redux/selectors'; import { openBugModal, updateHint, executeChallenge } from '../../redux/actions'; import { makeToast } from '../../../../toasts/redux/actions'; import { toggleHelpChat } from '../../../../redux/actions'; const bindableActions = { makeToast, executeChallenge, updateHint, toggleHelpChat, openBugModal }; const mapStateToProps = createSelector( challengeSelector, state => state.app.windowHeight, state => state.app.navHeight, state => state.challengesApp.tests, state => state.challengesApp.output, state => state.challengesApp.hintIndex, ( { challenge: { title, description, hints = [] } = {} }, windowHeight, navHeight, tests, output, hintIndex ) => ({ title, description, height: windowHeight - navHeight - 20, tests, output, hint: hints[hintIndex] }) ); export class SidePanel extends PureComponent { constructor(...args) { super(...args); this.descriptionRegex = /\
{ if (descriptionRegex.test(line)) { return ( ); } return ( ); }); } componentWillReceiveProps(nextProps) { if (this.props.title !== nextProps.title) { ReactDom.findDOMNode(this).scrollTop = 0; } } render() { const { title, description, height, tests = [], output, hint, executeChallenge, updateHint, makeToast, toggleHelpChat, openBugModal } = this.props; const style = {}; if (height) { style.height = height + 'px'; } return (); } } export default connect( mapStateToProps, bindableActions )(SidePanel);{ title || 'Happy Coding!' }
|
{ this.renderDescription(description, this.descriptionRegex) }