From 7f5758d58a8c7b697cad243820df62f8eee4aa81 Mon Sep 17 00:00:00 2001 From: Valeriy Date: Sat, 12 Jan 2019 17:41:41 +0300 Subject: [PATCH] fix(learn): backend challenge UI --- .../src/templates/Challenges/backend/Show.js | 87 ++++++++++++------- .../components/Challenge-Description.js | 25 +++--- 2 files changed, 66 insertions(+), 46 deletions(-) diff --git a/client/src/templates/Challenges/backend/Show.js b/client/src/templates/Challenges/backend/Show.js index 4ba1dd4ee3..91e5c26d7a 100644 --- a/client/src/templates/Challenges/backend/Show.js +++ b/client/src/templates/Challenges/backend/Show.js @@ -1,5 +1,6 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; +import { Grid, Col, Row } from '@freecodecamp/react-bootstrap'; import { createSelector } from 'reselect'; import { reduxForm } from 'redux-form'; import { graphql } from 'gatsby'; @@ -80,6 +81,12 @@ const options = { }; export class BackEnd extends Component { + constructor(props) { + super(props); + this.state = {}; + this.updateDimensions = this.updateDimensions.bind(this); + } + componentDidMount() { const { initTests, @@ -94,6 +101,15 @@ export class BackEnd extends Component { } = this.props; initTests(tests); 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) { @@ -143,43 +159,50 @@ export class BackEnd extends Component { const blockNameTitle = `${blockName} - ${title}`; return ( - -
- {blockNameTitle} - -
-
-
- -
-
-
- + + + +
+ {blockNameTitle} + +
+
+ + +
+
+
+ -
-
- -
- - - + dimensions={this.state} + height={150} + output={output} + /> +
+
+ +
+ + + + + +
); } diff --git a/client/src/templates/Challenges/components/Challenge-Description.js b/client/src/templates/Challenges/components/Challenge-Description.js index 3d0096a4c5..284a318c61 100644 --- a/client/src/templates/Challenges/components/Challenge-Description.js +++ b/client/src/templates/Challenges/components/Challenge-Description.js @@ -1,6 +1,5 @@ import React, { Fragment } from 'react'; import PropTypes from 'prop-types'; -import { Col, Row } from '@freecodecamp/react-bootstrap'; import './challenge-description.css'; @@ -12,20 +11,18 @@ const propTypes = { function ChallengeDescription({ description, instructions, section }) { return ( - - -
- {instructions ? ( - -
-
-
- - ) : ( +
+
+ {instructions ? ( +
- )} - - +
+
+ + ) : ( +
+ )} +
); }