@@ -2,6 +2,8 @@ import * as React from 'react'
22import * as T from 'typings'
33import * as TT from 'typings/tutorial'
44import { css , jsx } from '@emotion/core'
5+ import { Dropdown } from '@alifd/next'
6+ import Icon from '../../../components/Icon'
57import Button from '../../../components/Button'
68import Markdown from '../../../components/Markdown'
79import ProcessMessages from '../../../components/ProcessMessages'
@@ -22,12 +24,19 @@ const styles = {
2224paddingBottom :'5rem' ,
2325} ,
2426header :{
27+ display :'flex' as 'flex' ,
28+ alignItems :'center' ,
29+ justifyContent :'space-between' ,
2530height :'2rem' ,
2631backgroundColor :'#EBEBEB' ,
2732fontSize :'1rem' ,
2833lineHeight :'1rem' ,
2934padding :'10px 1rem' ,
3035} ,
36+ learn :{
37+ textDecoration :'none' ,
38+ color :'inherit' ,
39+ } ,
3140text :{
3241padding :'0rem 1rem' ,
3342paddingBottom :'1rem' ,
@@ -77,18 +86,34 @@ const styles = {
7786}
7887
7988interface Props {
80- level :TT . Level & { status :T . ProgressStatus ; index :number ; steps :Array < TT . Step & { status :T . ProgressStatus } > }
89+ menu :any
90+ steps :Array < TT . Step & { status :T . ProgressStatus } >
91+ title :string
92+ index :number
93+ content :string
94+ status :'COMPLETE' | 'ACTIVE' | 'INCOMPLETE'
8195processes :T . ProcessEvent [ ]
8296testStatus :T . TestStatus | null
8397onContinue ( ) :void
8498onLoadSolution ( ) :void
8599}
86100
87- const Level = ( { level, onContinue, onLoadSolution, processes, testStatus} :Props ) => {
101+ const Level = ( {
102+ menu,
103+ steps,
104+ title,
105+ content,
106+ index,
107+ status,
108+ onContinue,
109+ onLoadSolution,
110+ processes,
111+ testStatus,
112+ } :Props ) => {
88113//@ts -ignore
89- let currentStep = level . steps . findIndex ( ( s ) => s . status === 'ACTIVE' )
114+ let currentStep = steps . findIndex ( ( s ) => s . status === 'ACTIVE' )
90115if ( currentStep === - 1 ) {
91- currentStep = level . steps . length
116+ currentStep = steps . length
92117}
93118
94119const pageBottomRef = React . useRef ( null )
@@ -103,18 +128,27 @@ const Level = ({ level, onContinue, onLoadSolution, processes, testStatus }: Pro
103128< div css = { styles . page } >
104129< div css = { styles . content } >
105130< div css = { styles . header } >
106- < span > Learn</ span >
131+ < Dropdown
132+ trigger = {
133+ < a css = { styles . learn } >
134+ Learn< Icon type = "arrow-down" size = "xxs" />
135+ </ a >
136+ }
137+ triggerType = "click"
138+ >
139+ { menu }
140+ </ Dropdown >
107141</ div >
108142< div css = { styles . text } >
109- < h2 css = { styles . title } > { level . title } </ h2 >
110- < Markdown > { level . content || '' } </ Markdown >
143+ < h2 css = { styles . title } > { title } </ h2 >
144+ < Markdown > { content || '' } </ Markdown >
111145</ div >
112146
113- { level . steps . length ?(
147+ { steps . length ?(
114148< div css = { styles . tasks } >
115149< div css = { styles . header } > Tasks</ div >
116150< div css = { styles . steps } >
117- { level . steps . map ( ( step :( TT . Step & { status :T . ProgressStatus } ) | null , index :number ) => {
151+ { steps . map ( ( step :( TT . Step & { status :T . ProgressStatus } ) | null , index :number ) => {
118152if ( ! step ) {
119153return null
120154}
@@ -146,17 +180,17 @@ const Level = ({ level, onContinue, onLoadSolution, processes, testStatus }: Pro
146180
147181< div css = { styles . footer } >
148182< span >
149- { typeof level . index === 'number' ?`${ level . index + 1 } . ` :'' }
150- { level . title }
183+ { typeof index === 'number' ?`${ index + 1 } . ` :'' }
184+ { title }
151185</ span >
152186< span >
153- { level . status === 'COMPLETE' || ! level . steps . length ?(
187+ { status === 'COMPLETE' || ! steps . length ?(
154188< Button type = "primary" onClick = { onContinue } >
155189 Continue
156190</ Button >
157191) :(
158192< span css = { styles . taskCount } >
159- { currentStep } of{ level . steps . length } tasks
193+ { currentStep } of{ steps . length } tasks
160194</ span >
161195) }
162196</ span >