fix(client): challenge SSR and styles

This commit is contained in:
Valeriy S
2019-01-23 12:24:05 +03:00
committed by Stuart Taylor
parent 18a42f37cd
commit 4987f986a9
8 changed files with 85 additions and 85 deletions

View File

@ -30,12 +30,16 @@ class Header extends Component {
<header className={this.state.isMenuOpened ? 'opened' : null}>
<nav id='top-nav'>
<Media query='(min-width: 735px)'>
{matches =>
matches && (
<Fragment>
<Link className='home-link' to='/'>
<NavLogo />
</Link>
{disableSettings ? null : <FCCSearch />}
</Fragment>
)
}
</Media>
<ul id='top-right-nav'>
@ -58,7 +62,9 @@ class Header extends Component {
</ul>
</nav>
<Media query='(max-width: 734px)'>
<Media defaultMatches={false} query='(max-width: 734px)'>
{matches =>
matches && (
<div className='mobile-menu'>
<Link className='home-link' to='/'>
<NavLogo />
@ -68,6 +74,8 @@ class Header extends Component {
Menu
</span>
</div>
)
}
</Media>
</header>
);

View File

@ -5,10 +5,7 @@ import { connect } from 'react-redux';
import ToolPanel from '../components/Tool-Panel';
import { createStructuredSelector } from 'reselect';
import {
currentTabSelector,
moveToTab,
} from '../redux';
import { currentTabSelector, moveToTab } from '../redux';
import { bindActionCreators } from 'redux';
const mapStateToProps = createStructuredSelector({
@ -18,24 +15,23 @@ const mapStateToProps = createStructuredSelector({
const mapDispatchToProps = dispatch =>
bindActionCreators(
{
moveToTab,
moveToTab
},
dispatch
);
const propTypes = {
moveToTab: PropTypes.func,
currentTab: PropTypes.number,
instructions: PropTypes.element,
editor: PropTypes.element,
testOutput: PropTypes.element,
hasPreview: PropTypes.bool,
preview: PropTypes.element,
guideUrl: PropTypes.string,
hasPreview: PropTypes.bool,
instructions: PropTypes.element,
moveToTab: PropTypes.func,
preview: PropTypes.element,
testOutput: PropTypes.element,
videoUrl: PropTypes.string
};
class MobileLayout extends Component {
render() {
const {
@ -60,21 +56,17 @@ class MobileLayout extends Component {
<Tabs
activeKey={currentTab}
defaultActiveKey={1}
id='challege-page-tabs'
onSelect={(key) => moveToTab(key)}
id='challenge-page-tabs'
onSelect={moveToTab}
>
<TabPane eventKey={1} title='Instructions'>
{ instructions }
{instructions}
</TabPane>
<TabPane eventKey={2} title='Code' {...editorTabPaneProps}>
<div className='challege-edittor-wrapper'>
{editor}
</div>
<div className='challenge-editor-wrapper'>{editor}</div>
</TabPane>
<TabPane eventKey={3} title='Tests' {...editorTabPaneProps}>
<div className='challege-edittor-wrapper'>
{testOutput}
</div>
<div className='challenge-editor-wrapper'>{testOutput}</div>
</TabPane>
{hasPreview && (
<TabPane eventKey={4} title='Preview'>
@ -82,11 +74,7 @@ class MobileLayout extends Component {
</TabPane>
)}
</Tabs>
<ToolPanel
guideUrl={guideUrl}
isMobile={true}
videoUrl={videoUrl}
/>
<ToolPanel guideUrl={guideUrl} isMobile={true} videoUrl={videoUrl} />
</Fragment>
);
}
@ -95,4 +83,7 @@ class MobileLayout extends Component {
MobileLayout.displayName = 'MobileLayout';
MobileLayout.propTypes = propTypes;
export default connect(mapStateToProps, mapDispatchToProps)(MobileLayout);
export default connect(
mapStateToProps,
mapDispatchToProps
)(MobileLayout);

View File

@ -72,7 +72,7 @@ const propTypes = {
output: PropTypes.string,
pageContext: PropTypes.shape({
challengeMeta: PropTypes.shape({
nextchallengePath: PropTypes.string
nextChallengePath: PropTypes.string
})
}),
tests: PropTypes.arrayOf(
@ -178,7 +178,9 @@ class ShowClassic extends Component {
}
getGuideUrl() {
const {fields: { slug }} = this.getChallenge();
const {
fields: { slug }
} = this.getChallenge();
return createGuideUrl(slug);
}
@ -201,7 +203,7 @@ class ShowClassic extends Component {
const {
fields: { blockName },
description,
instructions,
instructions
} = this.getChallenge();
return (
@ -221,8 +223,8 @@ class ShowClassic extends Component {
renderEditor() {
const { files } = this.props;
const challengeFile = first(Object.keys(files).map(key => files[key]));
return challengeFile && (
<Editor {...challengeFile} fileKey={challengeFile.key} />
return (
challengeFile && <Editor {...challengeFile} fileKey={challengeFile.key} />
);
}
@ -242,10 +244,7 @@ class ShowClassic extends Component {
renderPreview() {
return (
<Preview
className='full-height'
disableIframe={this.state.resizing}
/>
<Preview className='full-height' disableIframe={this.state.resizing} />
);
}
@ -255,29 +254,31 @@ class ShowClassic extends Component {
<Helmet
title={`Learn ${this.getBlockNameTitle()} | freeCodeCamp.org`}
/>
<Media query={{ maxWidth: MAX_MOBILE_WIDTH }}>
<Media defaultMatches={false} query={{ maxWidth: MAX_MOBILE_WIDTH }}>
{matches =>
matches
? (
matches ? (
<MobileLayout
instructions={this.renderInstructionsPanel({ showToolPanel: false })}
editor={this.renderEditor()}
testOutput={this.renderTestOutput()}
hasPreview={this.hasPreview()}
preview={this.renderPreview()}
guideUrl={this.getGuideUrl()}
hasPreview={this.hasPreview()}
instructions={this.renderInstructionsPanel({
showToolPanel: false
})}
preview={this.renderPreview()}
testOutput={this.renderTestOutput()}
videoUrl={this.getVideoUrl()}
/>
)
: (
) : (
<DesktopLayout
instructions={this.renderInstructionsPanel({ showToolPanel: true })}
challengeFile={this.getChallengeFile()}
editor={this.renderEditor()}
testOutput={this.renderTestOutput()}
hasPreview={this.hasPreview()}
instructions={this.renderInstructionsPanel({
showToolPanel: true
})}
preview={this.renderPreview()}
resizeProps={this.resizeProps}
challengeFile={this.getChallengeFile()}
testOutput={this.renderTestOutput()}
/>
)
}

View File

@ -31,21 +31,21 @@
letter-spacing: 0.02em;
}
#challege-page-tabs .nav-tabs {
#challenge-page-tabs .nav-tabs {
margin-left: 2px;
display: flex;
}
#challege-page-tabs .nav-tabs > li {
#challenge-page-tabs .nav-tabs > li {
flex: 1;
text-align: center;
}
#challege-page-tabs .nav-tabs > li > a {
#challenge-page-tabs .nav-tabs > li > a {
padding: 5px 10px;
}
.challege-edittor-wrapper {
.challenge-editor-wrapper {
height: calc(100vh - 112px);
overflow: hidden;
}

View File

@ -10,7 +10,7 @@
width: 30vh;
}
@media screen, (max-width: 767px) {
@media screen and (max-width: 767px) {
.challenge-success-modal .btn-lg {
font-size: 16px;
}

View File

@ -1,4 +1,4 @@
@media screen, (max-width: 767px) {
@media screen and (max-width: 767px) {
.help-modal .btn-lg {
font-size: 16px;
}

View File

@ -10,7 +10,7 @@
text-shadow: none;
}
@media screen, (max-width: 767px) {
@media screen and (max-width: 767px) {
.reset-modal .btn-lg {
font-size: 16px;
}

View File

@ -1,4 +1,4 @@
@media screen, (max-width: 767px) {
@media screen and (max-width: 767px) {
.intro-layout-container {
padding: 0 10px;
}