Skip to content

Feature/styles #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 14, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
clean up styles
  • Loading branch information
ShMcK committed Jul 14, 2019
commit 8d57540c08cff7023f777303dc9c6cd79a985be2
4 changes: 2 additions & 2 deletions web-app/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as React from 'react'
import * as CR from 'typings'

import Debugger from './components/Debugger'
// import Debugger from './components/Debugger'
import Routes from './Routes'
import DataContext, { initialData, initialState } from './utils/DataContext'
import { send } from './utils/vscode'
import DataContext, { initialState, initialData } from './utils/DataContext'

interface ReceivedEvent {
data: CR.Action
Expand Down
12 changes: 12 additions & 0 deletions web-app/src/components/Divider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import * as React from 'react'

const styles = {
divider: {
backgroundColor: '#e8e8e8',
height: '0.1rem',
},
}

const Divider = () => <div style={styles.divider} />

export default Divider
51 changes: 51 additions & 0 deletions web-app/src/components/Level/LevelStageSummary.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { Button } from '@alifd/next'
import * as React from 'react'
import CC from '../../../../typings/context'

import Markdown from '../Markdown'

const styles = {
active: {
backgroundColor: '#e6f7ff',
},
card: {
padding: '0.5rem 1rem',
},
completed: {
backgroundColor: '#f6ffed',
},
disabled: {
// backgroundColor: 'blue',
},
options: {},
title: {
margin: 0,
},
}

interface Props {
stage: CC.StageWithStatus
onNext(): void
}

const LevelStageSummary = (props: Props) => {
const { stage, onNext } = props
const { complete, active } = stage.status
const cardStyle = {
...styles.card,
...(active ? styles.active : styles.disabled),
...(complete ? styles.completed : {}),
}
return (
<div style={cardStyle}>
<h3 style={styles.title}>{stage.content.title}</h3>
<Markdown>{stage.content.text}</Markdown>
<div style={styles.options}>
{active && <Button onClick={onNext}>Continue</Button>}
{complete && <div>Complete</div>}
</div>
</div>
)
}

export default LevelStageSummary
48 changes: 27 additions & 21 deletions web-app/src/components/Level/index.tsx
Original file line number Diff line number Diff line change
@@ -1,48 +1,54 @@
import { Button } from '@alifd/next'
import * as React from 'react'
import { Button, Card } from '@alifd/next'
import CR from 'typings'

import Divider from '../Divider'
import Markdown from '../Markdown'
import LevelStageSummary from './LevelStageSummary'

const styles = {
card: {
// width: '20rem',
card: {},
content: {
padding: '0rem 1rem',
paddingBottom: '1rem',
},
disabled: {
backgroundColor: 'grey',
list: {
padding: '0rem',
},
options: {
padding: '0rem 1rem',
},
title: {},
}

interface Props {
level: CR.TutorialLevel
onNext(): void
onBack(): void
stages: {
[stageId: string]: any // CC.StageWithStatus
}
onNext(): void
onBack(): void
}

const Level = ({ level, stages, onNext, onBack }: Props) => {
const { title, text } = level.content
return (
<Card style={styles.card} title={title} showTitleBullet={false} contentHeight="auto">
<Markdown>{text}</Markdown>
<div>
<div style={styles.card}>
<div style={styles.content}>
<h2 style={styles.title}>{title}</h2>
<Markdown>{text}</Markdown>
</div>
<Divider />
<div style={styles.list}>
{level.stageList.map((stageId: string) => {
const stage = stages[stageId]
const unavailable = !stage.status.complete && !stage.status.active
return (
<div key={stageId} style={unavailable ? styles.disabled : {}}>
<h3>{stage.content.title}</h3>
<p>{stage.content.text}</p>
{stage.status.active && <Button onClick={onNext}>Continue</Button>}
{stage.status.complete && <div>Complete</div>}
</div>
)
return <LevelStageSummary key={stageId} stage={stage} onNext={onNext} />
})}
</div>
<Button onClick={onBack}>Back</Button>
</Card>
<div style={styles.options}>
<Button onClick={onBack}>Back</Button>
</div>
</div>
)
}

Expand Down
9 changes: 8 additions & 1 deletion web-app/src/components/Stage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Button } from '@alifd/next'
import * as React from 'react'
import CR from 'typings'

import Divider from '../Divider'
import Markdown from '../Markdown'
import Step from '../Step'

Expand All @@ -11,6 +12,10 @@ const styles = {
},
content: {
padding: '0rem 1rem',
paddingBottom: '1rem',
},
options: {
padding: '0rem 1rem',
},
title: {},
}
Expand All @@ -32,14 +37,16 @@ const Stage = ({ stage, steps, onNextStage, complete }: Props) => {
<h2 style={styles.title}>{title}</h2>
<Markdown>{text}</Markdown>
</div>
<Divider />
<div>
{stage.stepList.map((stepId: string) => {
const step = steps[stepId]
return <Step key={stepId} content={step.content} status={step.status} />
})}
</div>

{complete && (
<div>
<div style={styles.options}>
<Button onClick={onNextStage}>Continue</Button>
</div>
)}
Expand Down
2 changes: 1 addition & 1 deletion web-app/src/components/Summary/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Button, Card } from '@alifd/next'
import { Button } from '@alifd/next'
import * as React from 'react'
import CR from 'typings'

Expand Down
30 changes: 23 additions & 7 deletions web-app/stories/Level.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,55 @@ import { storiesOf } from '@storybook/react'
import SideBarDecorator from './utils/SideBarDecorator'

import Level from '../src/components/Level'
import demo from './data/basic'

storiesOf('Tutorial SideBar', module)
.addDecorator(SideBarDecorator)
.addDecorator(withKnobs)
.add('Level', () => (
<Level
level={object('level', demo.data.levels.level1Id)}
level={object('level', {
content: {
text: 'A description of this stage',
title: 'Sum Level',
},
stageList: ['stage1Id', 'stage2Id', 'stage3Id'],
})}
stages={object('stages', {
stage1Id: {
stepList: [],
content: {
title: 'Stage 1',
text: 'some description',
title: 'Stage 1',
},
status: {
active: false,
complete: true,
},
stepList: [],
},
stage2Id: {
stepList: [],
content: {
title: 'Stage 2',
text: 'some description',
title: 'Stage 2',
},
status: {
active: true,
complete: false,
},
stepList: [],
},
stage3Id: {
content: {
text: 'some description',
title: 'Stage 3',
},
status: {
active: false,
complete: false,
},
stepList: [],
},
})}
onStageSelect={linkTo('Tutorial SideBar', 'Stage')}
onNext={linkTo('Tutorial SideBar', 'Stage')}
onBack={linkTo('TUtorial SideBar', 'Summary')}
/>
))
10 changes: 5 additions & 5 deletions web-app/stories/Summary.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import React from 'react'

import { storiesOf } from '@storybook/react'
import { object, withKnobs } from '@storybook/addon-knobs'
import { linkTo } from '@storybook/addon-links'
import { withKnobs, object } from '@storybook/addon-knobs'
import { storiesOf } from '@storybook/react'
import SideBarDecorator from './utils/SideBarDecorator'

import demo from './data/basic'
import Summary from '../src/components/Summary'
import demo from './data/basic'

storiesOf('Tutorial SideBar', module)
.addDecorator(SideBarDecorator)
.addDecorator(withKnobs)
.add('Summary', () => (
<Summary
data={object('data', {
summary: demo.data.summary,
levels: demo.data.levels,
summary: demo.data.summary,
})}
onLevelSelect={linkTo('Tutorial SideBar', 'Level')}
onNext={linkTo('Tutorial SideBar', 'Level')}
/>
))