Skip to content

fix level stories #385

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
Jul 6, 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
fix level stories
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
  • Loading branch information
ShMcK committed Jul 6, 2020
commit 259f01e9909651e72dd955a6e8aa5c678afb46ed
4 changes: 4 additions & 0 deletions typings/tutorial.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { ProgressStatus } from './index'

export type Maybe<T> = T | null

export type TutorialConfig = {
Expand All @@ -19,6 +21,7 @@ export type Level = {
setup?: Maybe<StepActions>
/** A set of tasks for users linked to unit tests */
steps: Array<Step>
status?: ProgressStatus
}

/** A level task */
Expand All @@ -29,6 +32,7 @@ export type Step = {
solution: Maybe<StepActions>
hints?: string[]
subtasks?: string[]
status?: ProgressStatus
}

/** A tutorial for use in VSCode CodeRoad */
Expand Down
8 changes: 4 additions & 4 deletions web-app/src/containers/Tutorial/components/ContentMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@ import { Menu } from '@alifd/next'
import Icon from '../../../components/Icon'

interface Props {
tutorial: TT.Tutorial
levels: TT.Level[]
position: T.Position
progress: T.Progress
setTitle: (title: string) => void
setContent: (content: string) => void
}

const ContentMenu = ({ tutorial, position, progress, setTitle, setContent }: Props) => {
const ContentMenu = ({ levels, position, progress, setTitle, setContent }: Props) => {
const setMenuContent = (levelId: string) => {
const selectedLevel: TT.Level | undefined = tutorial.levels.find((l: TT.Level) => l.id === levelId)
const selectedLevel: TT.Level | undefined = levels.find((l: TT.Level) => l.id === levelId)
if (selectedLevel) {
setTitle(selectedLevel.title)
setContent(selectedLevel.content)
}
}
return (
<Menu>
{tutorial.levels.map((level: TT.Level) => {
{levels.map((level: TT.Level) => {
const isCurrent = level.id === position.levelId
const isComplete = progress.levels[level.id]
let icon
Expand Down
8 changes: 5 additions & 3 deletions web-app/src/containers/Tutorial/components/Level.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const styles = {
}

interface Props {
tutorial: TT.Tutorial
tutorial: Exclude<TT.Tutorial, 'config'>
index: number
status: 'COMPLETE' | 'ACTIVE' | 'INCOMPLETE'
progress: T.Progress
Expand All @@ -114,7 +114,9 @@ const Level = ({
processes,
testStatus,
}: Props) => {
const level = tutorial.levels[index]
const level: TT.Level = tutorial.levels[index]

console.log(level)

const [title, setTitle] = React.useState<string>(level.title)
const [content, setContent] = React.useState<string>(level.content)
Expand All @@ -135,7 +137,7 @@ const Level = ({

const menu = (
<ContentMenu
tutorial={tutorial}
levels={tutorial.levels || []}
position={position}
progress={progress}
setTitle={setTitle}
Expand Down
Loading