|
| 1 | +import*asReactfrom'react' |
| 2 | +import*asCRfrom'typings' |
| 3 | +import*asGfrom'typings/graphql' |
| 4 | +import{Badge}from'@alifd/next' |
| 5 | +import{css,jsx}from'@emotion/core' |
| 6 | +importButtonfrom'../../components/Button' |
| 7 | + |
| 8 | +conststyles={ |
| 9 | +page:{ |
| 10 | +position:'relative'as'relative', |
| 11 | +display:'flex'as'flex', |
| 12 | +flexDirection:'column'as'column', |
| 13 | +width:'100%', |
| 14 | +height:window.innerHeight, |
| 15 | +}, |
| 16 | +header:{ |
| 17 | +flex:1, |
| 18 | +display:'flex'as'flex', |
| 19 | +flexDirection:'column'as'column', |
| 20 | +justifyContent:'flex-end'as'flex-end', |
| 21 | +alignItems:'center'as'center', |
| 22 | +fontSize:'1rem', |
| 23 | +lineHeight:'1rem', |
| 24 | +padding:'1rem', |
| 25 | +}, |
| 26 | +title:{ |
| 27 | +fontSize:'3rem', |
| 28 | +}, |
| 29 | +subtitle:{ |
| 30 | +fontSize:'1.3rem', |
| 31 | +}, |
| 32 | +options:{ |
| 33 | +flex:1, |
| 34 | +backgroundColor:'#EBEBEB', |
| 35 | +display:'flex'as'flex', |
| 36 | +flexDirection:'column'as'column', |
| 37 | +justifyContent:'flex-start'as'flex-start', |
| 38 | +alignItems:'center'as'center', |
| 39 | +padding:'1rem', |
| 40 | +}, |
| 41 | +betaBadge:{ |
| 42 | +backgroundColor:'#6a67ce', |
| 43 | +color:'#FFFFFF', |
| 44 | +}, |
| 45 | +buttonContainer:{ |
| 46 | +margin:'0.5rem', |
| 47 | +}, |
| 48 | +} |
| 49 | + |
| 50 | +interfaceProps{ |
| 51 | +onContinue():void |
| 52 | +onNew():void |
| 53 | +tutorial?:G.Tutorial |
| 54 | +} |
| 55 | + |
| 56 | +exportconstStartPage=(props:Props)=>( |
| 57 | +<divcss={styles.page}> |
| 58 | +<divcss={styles.header}> |
| 59 | +<Badgecontent="beta"style={styles.betaBadge}> |
| 60 | +<spancss={styles.title}>CodeRoad </span> |
| 61 | +</Badge> |
| 62 | +<h3css={styles.subtitle}>Play Interactive Coding Tutorials in VSCode</h3> |
| 63 | +</div> |
| 64 | + |
| 65 | +<divcss={styles.options}> |
| 66 | +<divcss={styles.buttonContainer}> |
| 67 | +<Buttonsize="large"type="primary"onClick={props.onNew}style={{width:'12rem'}}> |
| 68 | + New Tutorial |
| 69 | +</Button> |
| 70 | +</div> |
| 71 | +{props.tutorial&&( |
| 72 | +<divcss={styles.buttonContainer}> |
| 73 | +<Buttonsize="large"onClick={props.onContinue}style={{width:'12rem'}}> |
| 74 | + Continue "{props.tutorial.summary.title}" |
| 75 | +</Button> |
| 76 | +</div> |
| 77 | +)} |
| 78 | +</div> |
| 79 | +</div> |
| 80 | +) |
| 81 | + |
| 82 | +interfaceContainerProps{ |
| 83 | +context:CR.MachineContext |
| 84 | +send(action:CR.Action|string):void |
| 85 | +} |
| 86 | + |
| 87 | +constStartPageContainer=({ context, send}:ContainerProps)=>{ |
| 88 | +consttutorial=context.tutorial||undefined |
| 89 | +return( |
| 90 | +<StartPageonContinue={()=>send('CONTINUE_TUTORIAL')}onNew={()=>send('NEW_TUTORIAL')}tutorial={tutorial}/> |
| 91 | +) |
| 92 | +} |
| 93 | + |
| 94 | +exportdefaultStartPageContainer |