|
| 1 | +import * as React from 'react' |
| 2 | +import * as CR from 'typings' |
| 3 | +import * as G from 'typings/graphql' |
| 4 | +import { Badge } from '@alifd/next' |
| 5 | +import { css, jsx } from '@emotion/core' |
| 6 | +import Button from '../../components/Button' |
| 7 | + |
| 8 | +const styles = { |
| 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 | +interface Props { |
| 51 | + onContinue(): void |
| 52 | + onNew(): void |
| 53 | + tutorial?: G.Tutorial |
| 54 | +} |
| 55 | + |
| 56 | +export const StartPage = (props: Props) => ( |
| 57 | + <div css={styles.page}> |
| 58 | + <div css={styles.header}> |
| 59 | + <Badge content="beta" style={styles.betaBadge}> |
| 60 | + <span css={styles.title}>CodeRoad </span> |
| 61 | + </Badge> |
| 62 | + <h3 css={styles.subtitle}>Play Interactive Coding Tutorials in VSCode</h3> |
| 63 | + </div> |
| 64 | + |
| 65 | + <div css={styles.options}> |
| 66 | + <div css={styles.buttonContainer}> |
| 67 | + <Button size="large" type="primary" onClick={props.onNew} style={{ width: '12rem' }}> |
| 68 | + New Tutorial |
| 69 | + </Button> |
| 70 | + </div> |
| 71 | + {props.tutorial && ( |
| 72 | + <div css={styles.buttonContainer}> |
| 73 | + <Button size="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 | +interface ContainerProps { |
| 83 | + context: CR.MachineContext |
| 84 | + send(action: CR.Action | string): void |
| 85 | +} |
| 86 | + |
| 87 | +const StartPageContainer = ({ context, send }: ContainerProps) => { |
| 88 | + const tutorial = context.tutorial || undefined |
| 89 | + return ( |
| 90 | + <StartPage onContinue={() => send('CONTINUE_TUTORIAL')} onNew={() => send('NEW_TUTORIAL')} tutorial={tutorial} /> |
| 91 | + ) |
| 92 | +} |
| 93 | + |
| 94 | +export default StartPageContainer |
0 commit comments