1
1
import * as React from 'react'
2
2
import * as CR from 'typings'
3
3
import * as TT from 'typings/tutorial'
4
+ import { Progress } from '@alifd/next'
4
5
import BetaBadge from '../../components/BetaBadge'
5
6
import { css , jsx } from '@emotion/core'
6
7
import Button from '../../components/Button'
@@ -41,7 +42,29 @@ const styles = {
41
42
justifyContent :'flex-start' as 'flex-start' ,
42
43
alignItems :'center' as 'center' ,
43
44
} ,
45
+ buttonLarge :( theme :Theme ) => ( {
46
+ padding :'0.2rem 1rem' ,
47
+ border :`solid 1px${ theme [ '$color-line1-3' ] } ` ,
48
+ borderRadius :'3px' ,
49
+ minHeight :'2rem' ,
50
+ fontSize :'16px' ,
51
+ backgroundColor :'white' ,
52
+ lineHeight :'1.5rem' ,
53
+ color :theme [ '$color-text1-4' ] ,
54
+ '&:hover,&:focus' :css ( {
55
+ backgroundColor :theme [ '$color-fill1-1' ] ,
56
+ borderColor :theme [ '$color-line1-4' ] ,
57
+ } ) ,
58
+ } ) ,
59
+ continueTitle :( theme :Theme ) => ( {
60
+ color :theme [ '$color-text1-3' ] ,
61
+ fontSize :'12px' ,
62
+ } ) ,
44
63
buttonContainer :{
64
+ display :'flex' as 'flex' ,
65
+ flexDirection :'column' as 'column' ,
66
+ justifyContent :'center' as 'center' ,
67
+ alignItems :'center' as 'center' ,
45
68
margin :'0.5rem' ,
46
69
} ,
47
70
}
@@ -50,6 +73,7 @@ interface Props {
50
73
onContinue ( ) :void
51
74
onNew ( ) :void
52
75
tutorial ?:TT . Tutorial
76
+ progress ?:number
53
77
}
54
78
55
79
export const StartPage = ( props :Props ) => (
@@ -72,9 +96,11 @@ export const StartPage = (props: Props) => (
72
96
</ div >
73
97
{ props . tutorial && (
74
98
< div css = { styles . buttonContainer } >
75
- < Button size = "large" onClick = { props . onContinue } style = { { padding :'0 1rem' } } >
76
- Continue Current Tutorial
77
- </ Button >
99
+ < button onClick = { props . onContinue } css = { styles . buttonLarge } >
100
+ Continue Tutorial
101
+ < div css = { styles . continueTitle } > "{ props . tutorial . summary . title } "</ div >
102
+ < Progress style = { { marginLeft :'1rem' } } percent = { props . progress || 0 } hasBorder size = "large" />
103
+ </ button >
78
104
</ div >
79
105
) }
80
106
</ div >
@@ -88,11 +114,18 @@ interface ContainerProps {
88
114
89
115
const StartPageContainer = ( { context, send} :ContainerProps ) => {
90
116
const tutorial = context . tutorial || undefined
117
+ let progress
118
+ if ( tutorial ) {
119
+ const totalLevels = tutorial . levels . length
120
+ const firstIncompleteLevelIndex = tutorial . levels . findIndex ( ( level ) => ! context . progress . levels [ level . id ] )
121
+ progress = Math . round ( ( firstIncompleteLevelIndex / totalLevels ) * 100 )
122
+ }
91
123
return (
92
124
< StartPage
93
125
onContinue = { ( ) => send ( { type :'CONTINUE_TUTORIAL' } ) }
94
126
onNew = { ( ) => send ( { type :'NEW_TUTORIAL' } ) }
95
127
tutorial = { tutorial }
128
+ progress = { progress }
96
129
/>
97
130
)
98
131
}