Skip to content

closes #132. load solution in menu #136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 46 additions & 4 deletions web-app/src/components/NewUserExperience/NuxTutorial.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react'
import { Collapse, Icon } from '@alifd/next'
import Button from '../Button'
import ReactCSSTransitionGroup from 'react-addons-css-transition-group'
import './transition.css'

Expand All @@ -26,7 +27,33 @@ const styles = {
},
}

const NewUserExperienceTutorialCollapsible = () => {
type LoadSolutionButtonProps = {
onLoadSolution: () => void
close: () => void
}

const LoadSolutionButton = (props: LoadSolutionButtonProps) => {
const [loadedSolution, setLoadedSolution] = React.useState(false)
const onClickHandler = () => {
props.close()
if (!loadedSolution) {
setLoadedSolution(true)
props.onLoadSolution()
}
}
return (
<Button type="secondary" onClick={onClickHandler} disabled={loadedSolution}>
Load Solution
</Button>
)
}

type NuxProps = {
onClose: () => void
onLoadSolution: () => void
}

const NewUserExperienceTutorialCollapsible = (props: NuxProps) => {
const [expandedKeys, setExpandedKeys] = React.useState<string[]>([])
return (
<Collapse onExpand={setExpandedKeys} expandedKeys={expandedKeys}>
Expand Down Expand Up @@ -88,8 +115,17 @@ const NewUserExperienceTutorialCollapsible = () => {
</li>
<br />
<li>
Load the solution. Each step in CodeRoad is stored as a Git commit - including the solution. Load the
solution by pressing the help icon under the current task, and select the option "load solution".
Still stuck? Load the solution. Each step in CodeRoad is stored as a Git commit - including the solution.
Load the solution commit by pressing the button below.
<br />
<br />
<LoadSolutionButton
onLoadSolution={props.onLoadSolution}
close={() => {
setExpandedKeys([])
props.onClose()
}}
/>
</li>
</ol>
</Panel>
Expand All @@ -103,6 +139,7 @@ const NewUserExperienceTutorialCollapsible = () => {

interface Props {
css?: React.CSSProperties
onLoadSolution: () => void
}

const NewUserExperienceTutorial = (props: Props) => {
Expand All @@ -117,7 +154,12 @@ const NewUserExperienceTutorial = (props: Props) => {
<span css={styles.title}>Help</span>
</div>
<ReactCSSTransitionGroup transitionName="slide" transitionEnterTimeout={500} transitionLeaveTimeout={300}>
{isOpen && <NewUserExperienceTutorialCollapsible />}
{isOpen && (
<NewUserExperienceTutorialCollapsible
onLoadSolution={props.onLoadSolution}
onClose={() => setIsOpen(false)}
/>
)}
</ReactCSSTransitionGroup>
</div>
)
Expand Down
2 changes: 1 addition & 1 deletion web-app/src/containers/Tutorial/LevelPage/Level.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const Level = ({ level, onContinue, onLoadSolution, processes, testStatus }: Pro
)}

<div css={styles.nux}>
<NuxTutorial />
<NuxTutorial onLoadSolution={onLoadSolution} />
</div>

<div css={styles.footer}>
Expand Down
6 changes: 0 additions & 6 deletions web-app/src/containers/Tutorial/LevelPage/Step.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ const Step = (props: Props) => {
if (!showStep) {
return null
}
const showLoadSolution = props.status === 'ACTIVE'
return (
<div>
<div css={styles.card}>
Expand All @@ -50,11 +49,6 @@ const Step = (props: Props) => {
<Markdown>{props.content || ''}</Markdown>
</div>
</div>
{showLoadSolution && (
<div css={styles.options}>
<StepHelp onLoadSolution={props.onLoadSolution} />
</div>
)}
</div>
)
}
Expand Down
3 changes: 2 additions & 1 deletion web-app/stories/NewUserExperience.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { storiesOf } from '@storybook/react'
import { action } from '@storybook/addon-actions'
import React from 'react'
import { css, jsx } from '@emotion/core'
import SideBarDecorator from './utils/SideBarDecorator'
Expand All @@ -17,6 +18,6 @@ storiesOf('NewUserExperience', module)
.addDecorator(SideBarDecorator)
.add('NUXTutorial', () => (
<div css={styles.container}>
<NewUserExperienceTutorial />
<NewUserExperienceTutorial onLoadSolution={action('onLoadSolution')} />
</div>
))