Skip to content

Fix/checkbox #48

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
Nov 2, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

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
add checkbox component
  • Loading branch information
ShMcK committed Nov 2, 2019
commit 7b505ac3f61e279528785187fe3a81a94aa53e72
34 changes: 34 additions & 0 deletions web-app/src/components/Checkbox/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import * as React from 'react'

const styles = {
box: {
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
},
input: {
border: '1px solid black',
backgroundColor: 'yellow',
},
}

interface Props {
status: 'COMPLETE' | 'INCOMPLETE' | 'ACTIVE' | 'LOADING'
}

const Checkbox = (props: Props) => {
const checked = props.status === 'COMPLETE'
// const loading = props.state === 'LOADING'
const onChange = () => {
/* read */
}
return (
<div style={styles.box}>
<label>
<input style={styles.input} type="checkbox" checked={checked} onChange={onChange} />
</label>
</div>
)
}

export default Checkbox
21 changes: 10 additions & 11 deletions web-app/src/containers/Tutorial/LevelPage/Level/Step/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react'
import * as T from 'typings'
import { Button, Checkbox } from '@alifd/next'

import { Button } from '@alifd/next'
import Checkbox from '../../../../../components/Checkbox'
import Markdown from '../../../../../components/Markdown'

interface Props {
Expand Down Expand Up @@ -36,19 +36,18 @@ const Step = (props: Props) => {
return (
<div style={styles.card}>
<div>
<Checkbox
checked={props.status === 'COMPLETE'}
indeterminate={false /* TODO: running */}
disabled={props.status !== 'INCOMPLETE' /* TODO: and not running */}
onChange={() => {
/* do nothing */
}}
/>
<Checkbox status={props.status} />
</div>
<div>
<Markdown>{props.content || ''}</Markdown>
</div>
<div>{showLoadSolution && <Button onClick={onClickHandler}>Load Solution</Button>}</div>
<div>
{showLoadSolution && (
<Button type="normal" onClick={onClickHandler}>
Load Solution
</Button>
)}
</div>
</div>
)
}
Expand Down
4 changes: 0 additions & 4 deletions web-app/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ import * as React from 'react'
import ReactDOM from 'react-dom'
import App from './App'

// base styles
// TODO: must be a better way to load @alifd styles
// currently these are loaded in src/editor/ReactWebView.ts as well
import '@alifd/next/dist/next.css'
import './styles/index.css'

ReactDOM.render(<App />, document.getElementById('root') as HTMLElement)
28 changes: 28 additions & 0 deletions web-app/stories/Checkbox.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from 'react'
import { storiesOf } from '@storybook/react'
import SideBarDecorator from './utils/SideBarDecorator'

import Checkbox from '../src/components/Checkbox'

const styles = {
container: {
display: 'flex' as 'flex',
flexDirection: 'column' as 'column',
},
}

storiesOf('Checkbox', module)
.addDecorator(SideBarDecorator)
.add('Checkboxes', () => (
<div style={styles.container}>
<span>
<Checkbox status="COMPLETE" /> Checked
</span>
<span>
<Checkbox status="INCOMPLETE" /> Unchecked
</span>
<span>
<Checkbox status="LOADING" /> Loading
</span>
</div>
))