fix(learn): backend challenge UI

This commit is contained in:
Valeriy
2019-01-12 17:41:41 +03:00
committed by Stuart Taylor
parent 369f150029
commit 7f5758d58a
2 changed files with 66 additions and 46 deletions

View File

@ -1,5 +1,6 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { Grid, Col, Row } from '@freecodecamp/react-bootstrap';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import { reduxForm } from 'redux-form'; import { reduxForm } from 'redux-form';
import { graphql } from 'gatsby'; import { graphql } from 'gatsby';
@ -80,6 +81,12 @@ const options = {
}; };
export class BackEnd extends Component { export class BackEnd extends Component {
constructor(props) {
super(props);
this.state = {};
this.updateDimensions = this.updateDimensions.bind(this);
}
componentDidMount() { componentDidMount() {
const { const {
initTests, initTests,
@ -94,6 +101,15 @@ export class BackEnd extends Component {
} = this.props; } = this.props;
initTests(tests); initTests(tests);
updateChallengeMeta({ ...challengeMeta, challengeType }); updateChallengeMeta({ ...challengeMeta, challengeType });
window.addEventListener('resize', this.updateDimensions);
}
updateDimensions() {
this.setState({ width: window.innerWidth, height: window.innerHeight });
}
componentWillUnmount() {
window.removeEventListener('resize', this.updateDimensions);
} }
componentDidUpdate(prevProps) { componentDidUpdate(prevProps) {
@ -143,6 +159,9 @@ export class BackEnd extends Component {
const blockNameTitle = `${blockName} - ${title}`; const blockNameTitle = `${blockName} - ${title}`;
return ( return (
<LearnLayout> <LearnLayout>
<Grid>
<Row>
<Col xs={12}>
<Spacer /> <Spacer />
<div> <div>
<ChallengeTitle>{blockNameTitle}</ChallengeTitle> <ChallengeTitle>{blockNameTitle}</ChallengeTitle>
@ -170,6 +189,7 @@ export class BackEnd extends Component {
* *
* *
*/`} */`}
dimensions={this.state}
height={150} height={150}
output={output} output={output}
/> />
@ -178,8 +198,11 @@ export class BackEnd extends Component {
<TestSuite tests={tests} /> <TestSuite tests={tests} />
</div> </div>
<Spacer /> <Spacer />
</Col>
<CompletionModal /> <CompletionModal />
<HelpModal /> <HelpModal />
</Row>
</Grid>
</LearnLayout> </LearnLayout>
); );
} }

View File

@ -1,6 +1,5 @@
import React, { Fragment } from 'react'; import React, { Fragment } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { Col, Row } from '@freecodecamp/react-bootstrap';
import './challenge-description.css'; import './challenge-description.css';
@ -12,8 +11,7 @@ const propTypes = {
function ChallengeDescription({ description, instructions, section }) { function ChallengeDescription({ description, instructions, section }) {
return ( return (
<Row> <div className={`challenge-instructions ${section}`}>
<Col className={`challenge-instructions ${section}`} xs={12}>
<div dangerouslySetInnerHTML={{ __html: description }} /> <div dangerouslySetInnerHTML={{ __html: description }} />
{instructions ? ( {instructions ? (
<Fragment> <Fragment>
@ -24,8 +22,7 @@ function ChallengeDescription({ description, instructions, section }) {
) : ( ) : (
<hr /> <hr />
)} )}
</Col> </div>
</Row>
); );
} }