Skip to content

Commit

Permalink
Fix: Hint Button (freeCodeCamp#196)
Browse files Browse the repository at this point in the history
* Create a guide URL for each challenge

* Format
  • Loading branch information
Bouncey authored and raisedadead committed Jun 28, 2018
1 parent 55af358 commit fd5d384
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 31 deletions.
4 changes: 3 additions & 1 deletion src/components/Header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ function Header() {
<Link to='/'>Curriculum</Link>
</li>
<li>
<a href='https://forum.freecodecamp.org' target='_blank'>Forum</a>
<a href='https://forum.freecodecamp.org' target='_blank'>
Forum
</a>
</li>
<li>
<UserState />
Expand Down
17 changes: 6 additions & 11 deletions src/head/mathjax.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import React from 'react';

const cdnAddr = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/' +
'2.7.4/MathJax.js?config=TeX-AMS_HTML';
const cdnAddr =
'https://cdnjs.cloudflare.com/ajax/libs/mathjax/' +
'2.7.4/MathJax.js?config=TeX-AMS_HTML';

const mathjax = [
<script
key='mathjax'
type='text/javascript'
src={cdnAddr}
/>
];

export default mathjax;
const mathjax = [<script key='mathjax' src={cdnAddr} type='text/javascript' />];

export default mathjax;
8 changes: 6 additions & 2 deletions src/templates/Challenges/backend/Show.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
Form
} from '../../../components/formHelpers';
import Spacer from '../../../components/util/Spacer';
import { createGuideUrl } from '../utils';

// provided by redux form
const reduxFormPropTypes = {
Expand Down Expand Up @@ -105,7 +106,9 @@ export class BackEnd extends PureComponent {

render() {
const {
data: { challengeNode: { fields: { blockName }, title, description } },
data: {
challengeNode: { fields: { blockName, slug }, title, description }
},
output,
tests,
submitting,
Expand Down Expand Up @@ -133,7 +136,7 @@ export class BackEnd extends PureComponent {
options={options}
submit={executeChallenge}
/>
<ProjectToolPanel />
<ProjectToolPanel guideUrl={createGuideUrl(slug)} />
</div>
<div>
<br />
Expand Down Expand Up @@ -181,6 +184,7 @@ export const query = graphql`
challengeType
fields {
blockName
slug
tests {
text
testString
Expand Down
16 changes: 8 additions & 8 deletions src/templates/Challenges/classic/Show.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import HelpModal from '../components/HelpModal';
import ResetModal from '../components/ResetModal';

import { randomCompliment } from '../utils/get-words';

import { createGuideUrl } from '../utils';
import { challengeTypes } from '../../../../utils/challengeTypes';
import { ChallengeNode } from '../../../redux/propTypes';
import {
Expand Down Expand Up @@ -160,10 +160,9 @@ class ShowClassic extends PureComponent {
data: {
challengeNode: {
challengeType,
fields: { blockName },
fields: { blockName, slug },
title,
description,
guideUrl
description
}
},
files,
Expand Down Expand Up @@ -220,16 +219,17 @@ class ShowClassic extends PureComponent {
<SidePanel
className='full-height'
description={description}
guideUrl={guideUrl}
guideUrl={createGuideUrl(slug)}
title={blockNameTitle}
/>
</ReflexElement>
<ReflexSplitter propagate={true} {...this.resizeProps} />
<ReflexElement flex={1} {...this.resizeProps}>
{editors}
</ReflexElement>
{showPreview &&
<ReflexSplitter propagate={true} {...this.resizeProps} />}
{showPreview && (
<ReflexSplitter propagate={true} {...this.resizeProps} />
)}
{showPreview ? (
<ReflexElement flex={0.7} {...this.resizeProps}>
<Preview
Expand Down Expand Up @@ -257,10 +257,10 @@ export const query = graphql`
query ClassicChallenge($slug: String!) {
challengeNode(fields: { slug: { eq: $slug } }) {
title
guideUrl
description
challengeType
fields {
slug
blockName
tests {
text
Expand Down
2 changes: 1 addition & 1 deletion src/templates/Challenges/components/Output.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const options = {
horizontal: 'hidden',
vertical: 'visible',
verticalHasArrows: true
},
}
};

class Output extends PureComponent {
Expand Down
14 changes: 9 additions & 5 deletions src/templates/Challenges/project/ProjectForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,30 +63,34 @@ export class ProjectForm extends PureComponent {
handleKeyDown(e) {
if (e.key === 'Control') {
this.setState(state => ({
...state, keysDown: { ...state.keysDown, Control: true }
...state,
keysDown: { ...state.keysDown, Control: true }
}));
}
if (e.key === 'Enter') {
this.setState(state => ({
...state, keysDown: { ...state.keysDown, Enter: true }
...state,
keysDown: { ...state.keysDown, Enter: true }
}));
}
}
handleKeyUp(e) {
if (e.key === 'Control') {
this.setState(state => ({
...state, keysDown: { ...state.keysDown, Control: false }
...state,
keysDown: { ...state.keysDown, Control: false }
}));
}
if (e.key === 'Enter') {
this.setState(state => ({
...state, keysDown: { ...state.keysDown, Enter: false }
...state,
keysDown: { ...state.keysDown, Enter: false }
}));
}
}
handleSubmit(values) {
const { keysDown: { Control, Enter } } = this.state;
if (Control && Enter || !Enter) {
if ((Control && Enter) || !Enter) {
this.props.openModal('completion');
this.props.updateProjectForm(values);
}
Expand Down
7 changes: 4 additions & 3 deletions src/templates/Challenges/project/Show.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { frontEndProject } from '../../../../utils/challengeTypes';

import './project.css';
import Spacer from '../../../components/util/Spacer';
import { createGuideUrl } from '../utils';

const mapStateToProps = () => ({});
const mapDispatchToProps = dispatch =>
Expand Down Expand Up @@ -92,7 +93,7 @@ export class Project extends PureComponent {
data: {
challengeNode: {
challengeType,
fields: { blockName },
fields: { blockName, slug },
title,
description,
guideUrl
Expand All @@ -119,7 +120,7 @@ export class Project extends PureComponent {
openModal={openCompletionModal}
updateProjectForm={updateProjectFormValues}
/>
<ToolPanel />
<ToolPanel guideUrl={createGuideUrl(slug)} />
<Spacer />
</div>
<CompletionModal />
Expand All @@ -138,11 +139,11 @@ export const query = graphql`
query ProjectChallenge($slug: String!) {
challengeNode(fields: { slug: { eq: $slug } }) {
title
guideUrl
description
challengeType
fields {
blockName
slug
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/templates/Challenges/utils/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const guideBase = 'https://guide.freecodecamp.org/certifications';

export function createGuideUrl(slug = '') {
return guideBase + slug;
}

0 comments on commit fd5d384

Please sign in to comment.