1- import { Button } from '@alifd/next'
1+ import { Button , Step } from '@alifd/next'
22import * as React from 'react'
33import CR from 'typings'
4+ import CC from '../../../../typings/context'
45
5- import Divider from '../Divider'
66import Markdown from '../Markdown'
77import LevelStageSummary from './LevelStageSummary'
88
@@ -18,6 +18,9 @@ const styles = {
1818 options : {
1919 padding : '0rem 1rem' ,
2020 } ,
21+ steps : {
22+ padding : '1rem 0.5rem' ,
23+ } ,
2124 title : { } ,
2225}
2326
@@ -31,19 +34,41 @@ interface Props {
3134}
3235
3336const Level = ( { level, stages, onNext, onBack } : Props ) => {
34- const { title, text } = level . content
37+ const { content, stageList } = level
38+ const { title, text } = content
39+ const activeIndex = stageList . findIndex ( ( stageId : string ) => {
40+ return stages [ stageId ] . status . active
41+ } )
42+
3543 return (
3644 < div style = { styles . card } >
3745 < div style = { styles . content } >
3846 < h2 style = { styles . title } > { title } </ h2 >
3947 < Markdown > { text } </ Markdown >
4048 </ div >
41- < Divider />
42- < div style = { styles . list } >
43- { level . stageList . map ( ( stageId : string ) => {
44- const stage = stages [ stageId ]
45- return < LevelStageSummary key = { stageId } stage = { stage } onNext = { onNext } />
46- } ) }
49+ < div style = { styles . steps } >
50+ < Step current = { activeIndex } direction = "ver" animation = { false } >
51+ { stageList . map ( ( stageId : string , index : number ) => {
52+ const stage : CC . StageWithStatus = stages [ stageId ]
53+ const { active } = stage . status
54+ const clickHandler = active ? onNext : ( ) => { }
55+ // note - must add click handler to title, content & step.item
56+ // as all are separted components
57+ return (
58+ < Step . Item
59+ key = { stageId }
60+ style = { { backgroundColor : 'blue' } }
61+ title = {
62+ < span className = { active ? 'hover-select' : '' } onClick = { clickHandler } >
63+ { stage . content . title || `Stage ${ index + 1 } ` }
64+ </ span >
65+ }
66+ content = { < LevelStageSummary key = { stageId } stage = { stage } onNext = { clickHandler } /> }
67+ onClick = { clickHandler }
68+ />
69+ )
70+ } ) }
71+ </ Step >
4772 </ div >
4873 < div style = { styles . options } >
4974 < Button onClick = { onBack } > Back</ Button >
0 commit comments