chore(learn): Merge learn in to the client app
This commit is contained in:
135
client/src/templates/Challenges/components/Tool-Panel.js
Normal file
135
client/src/templates/Challenges/components/Tool-Panel.js
Normal file
@@ -0,0 +1,135 @@
|
||||
import React, { Fragment } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { bindActionCreators } from 'redux';
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import { Button } from '@freecodecamp/react-bootstrap';
|
||||
|
||||
import './tool-panel.css';
|
||||
import { openModal, executeChallenge } from '../redux';
|
||||
|
||||
const mapStateToProps = () => ({});
|
||||
const mapDispatchToProps = dispatch =>
|
||||
bindActionCreators(
|
||||
{
|
||||
executeChallenge,
|
||||
openHelpModal: () => openModal('help'),
|
||||
openVideoModal: () => openModal('video'),
|
||||
openResetModal: () => openModal('reset')
|
||||
},
|
||||
dispatch
|
||||
);
|
||||
|
||||
const propTypes = {
|
||||
executeChallenge: PropTypes.func.isRequired,
|
||||
guideUrl: PropTypes.string,
|
||||
openHelpModal: PropTypes.func.isRequired,
|
||||
openResetModal: PropTypes.func.isRequired,
|
||||
openVideoModal: PropTypes.func.isRequired,
|
||||
videoUrl: PropTypes.string
|
||||
};
|
||||
|
||||
function ToolPanel({
|
||||
executeChallenge,
|
||||
openHelpModal,
|
||||
openVideoModal,
|
||||
openResetModal,
|
||||
guideUrl,
|
||||
videoUrl
|
||||
}) {
|
||||
return (
|
||||
<Fragment>
|
||||
<div className='tool-panel-group'>
|
||||
<Button block={true} bsStyle='primary' onClick={executeChallenge}>
|
||||
Run the Tests
|
||||
</Button>
|
||||
<Button
|
||||
block={true}
|
||||
bsStyle='primary'
|
||||
className='btn-primary-invert'
|
||||
onClick={openResetModal}
|
||||
>
|
||||
Reset All Code
|
||||
</Button>
|
||||
{guideUrl ? (
|
||||
<Button
|
||||
block={true}
|
||||
bsStyle='primary'
|
||||
className='btn-primary-invert'
|
||||
href={guideUrl}
|
||||
target='_blank'
|
||||
>
|
||||
Get a hint
|
||||
</Button>
|
||||
) : null}
|
||||
{videoUrl ? (
|
||||
<Button
|
||||
block={true}
|
||||
bsStyle='primary'
|
||||
className='btn-primary-invert'
|
||||
onClick={openVideoModal}
|
||||
>
|
||||
Watch a video
|
||||
</Button>
|
||||
) : null}
|
||||
<Button
|
||||
block={true}
|
||||
bsStyle='primary'
|
||||
className='btn-primary-invert'
|
||||
onClick={openHelpModal}
|
||||
>
|
||||
Ask for help
|
||||
</Button>
|
||||
</div>
|
||||
</Fragment>
|
||||
);
|
||||
}
|
||||
|
||||
ToolPanel.displayName = 'ToolPanel';
|
||||
ToolPanel.propTypes = propTypes;
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(ToolPanel);
|
||||
|
||||
/*
|
||||
<Button
|
||||
block={true}
|
||||
bsStyle='default'
|
||||
className='btn-big'
|
||||
onClick={executeChallenge}
|
||||
>
|
||||
Run tests (Ctrl + Enter)
|
||||
</Button>
|
||||
<div className='button-spacer' />
|
||||
<Button
|
||||
block={true}
|
||||
bsStyle='default'
|
||||
className='btn-big'
|
||||
onClick={openResetModal}
|
||||
>
|
||||
Reset this lesson
|
||||
</Button>
|
||||
<div className='button-spacer' />
|
||||
{guideUrl && (
|
||||
<div>
|
||||
<Button
|
||||
block={true}
|
||||
bsStyle='default'
|
||||
className='btn-big'
|
||||
href={guideUrl}
|
||||
target='_blank'
|
||||
>
|
||||
Get a hint
|
||||
</Button>
|
||||
<div className='button-spacer' />
|
||||
</div>
|
||||
)}
|
||||
<Button
|
||||
block={true}
|
||||
bsStyle='default'
|
||||
className='btn-big'
|
||||
onClick={openHelpModal}
|
||||
>
|
||||
Ask for help on the forum
|
||||
</Button>
|
||||
<div className='button-spacer' />
|
||||
*/
|
Reference in New Issue
Block a user