From 1df2bd6655f2223d532075abf07a91175b3dba9c Mon Sep 17 00:00:00 2001 From: shmck Date: Sun, 8 Mar 2020 15:26:58 -0700 Subject: [PATCH] closes #132. load solution in menu --- .../NewUserExperience/NuxTutorial.tsx | 50 +++++++++++++++++-- .../containers/Tutorial/LevelPage/Level.tsx | 2 +- .../containers/Tutorial/LevelPage/Step.tsx | 6 --- web-app/stories/NewUserExperience.stories.tsx | 3 +- 4 files changed, 49 insertions(+), 12 deletions(-) diff --git a/web-app/src/components/NewUserExperience/NuxTutorial.tsx b/web-app/src/components/NewUserExperience/NuxTutorial.tsx index a0a232db..ed46e26e 100644 --- a/web-app/src/components/NewUserExperience/NuxTutorial.tsx +++ b/web-app/src/components/NewUserExperience/NuxTutorial.tsx @@ -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' @@ -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 ( + + ) +} + +type NuxProps = { + onClose: () => void + onLoadSolution: () => void +} + +const NewUserExperienceTutorialCollapsible = (props: NuxProps) => { const [expandedKeys, setExpandedKeys] = React.useState([]) return ( @@ -88,8 +115,17 @@ const NewUserExperienceTutorialCollapsible = () => {
  • - 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. +
    +
    + { + setExpandedKeys([]) + props.onClose() + }} + />
  • @@ -103,6 +139,7 @@ const NewUserExperienceTutorialCollapsible = () => { interface Props { css?: React.CSSProperties + onLoadSolution: () => void } const NewUserExperienceTutorial = (props: Props) => { @@ -117,7 +154,12 @@ const NewUserExperienceTutorial = (props: Props) => { Help - {isOpen && } + {isOpen && ( + setIsOpen(false)} + /> + )} ) diff --git a/web-app/src/containers/Tutorial/LevelPage/Level.tsx b/web-app/src/containers/Tutorial/LevelPage/Level.tsx index 8b24b24d..f113bf3d 100644 --- a/web-app/src/containers/Tutorial/LevelPage/Level.tsx +++ b/web-app/src/containers/Tutorial/LevelPage/Level.tsx @@ -137,7 +137,7 @@ const Level = ({ level, onContinue, onLoadSolution, processes, testStatus }: Pro )}
    - +
    diff --git a/web-app/src/containers/Tutorial/LevelPage/Step.tsx b/web-app/src/containers/Tutorial/LevelPage/Step.tsx index 18deb961..97ef775a 100644 --- a/web-app/src/containers/Tutorial/LevelPage/Step.tsx +++ b/web-app/src/containers/Tutorial/LevelPage/Step.tsx @@ -39,7 +39,6 @@ const Step = (props: Props) => { if (!showStep) { return null } - const showLoadSolution = props.status === 'ACTIVE' return (
    @@ -50,11 +49,6 @@ const Step = (props: Props) => { {props.content || ''}
    - {showLoadSolution && ( -
    - -
    - )}
    ) } diff --git a/web-app/stories/NewUserExperience.stories.tsx b/web-app/stories/NewUserExperience.stories.tsx index 22945b5c..b3402e9a 100644 --- a/web-app/stories/NewUserExperience.stories.tsx +++ b/web-app/stories/NewUserExperience.stories.tsx @@ -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' @@ -17,6 +18,6 @@ storiesOf('NewUserExperience', module) .addDecorator(SideBarDecorator) .add('NUXTutorial', () => (
    - +
    ))