8000 add checkbox component · crabbedbushel/coderoad-vscode@7b505ac · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7b505ac

Browse files
committed
add checkbox component
1 parent c855eca commit 7b505ac

File tree

4 files changed

+72
-15
lines changed

4 files changed

+72
-15
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import * as React from 'react'
2+
3+
const styles = {
4+
box: {
5+
display: 'flex',
6+
alignItems: 'center',
7+
justifyContent: 'center',
8+
},
9+
input: {
10+
border: '1px solid black',
11+
backgroundColor: 'yellow',
12+
},
13+
}
14+
15+
interface Props {
16+
status: 'COMPLETE' | 'INCOMPLETE' | 'ACTIVE' | 'LOADING'
17+
}
18+
19+
const Checkbox = (props: Props) => {
20+
const checked = props.status === 'COMPLETE'
21+
// const loading = props.state === 'LOADING'
22+
const onChange = () => {
23+
/* read */
24+
}
25+
return (
26+
<div style={styles.box}>
27+
<label>
28+
<input style={styles.input} type="checkbox" checked={checked} onChange={onChange} />
29+
</label>
30+
</div>
31+
)
32+
}
33+
34+
export default Checkbox

web-app/src/containers/Tutorial/LevelPage/Level/Step/index.tsx

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react'
22
import * as T from 'typings'
3-
import { Button, Checkbox } from '@alifd/next'
4-
3+
import { Button } from '@alifd/next'
4+
import Checkbox from '../../../../../components/Checkbox'
55
import Markdown from '../../../../../components/Markdown'
66

77
interface Props {
@@ -36,19 +36,18 @@ const Step = (props: Props) => {
3636
return (
3737
<div style={styles.card}>
3838
<div>
39-
<Checkbox
40-
checked={props.status === 'COMPLETE'}
41-
indeterminate={false /* TODO: running */}
42-
disabled={props.status !== 'INCOMPLETE' /* TODO: and not running */}
43-
onChange={() => {
44-
/* do nothing */
45-
}}
46-
/>
39+
<Checkbox status={props.status} />
4740
</div>
4841
<div>
4942
<Markdown>{props.content || ''}</Markdown>
5043
</div>
51-
<div>{showLoadSolution && <Button onClick={onClickHandler}>Load Solution</Button>}</div>
44+
<div>
45+
{showLoadSolution && (
46+
<Button type="normal" onClick={onClickHandler}>
47+
Load Solution
48+
</Button>
49+
)}
50+
</div>
5251
</div>
5352
)
5453
}

web-app/src/index.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ import * as React from 'react'
22
import ReactDOM from 'react-dom'
33
import App from './App'
44

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

117
ReactDOM.render(<App />, document.getElementById('root') as HTMLElement)

web-app/stories/Checkbox.stories.tsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import React from 'react'
2+
import { storiesOf } from '@storybook/react'
3+
import SideBarDecorator from './utils/SideBarDecorator'
4+
5+
import Checkbox from '../src/components/Checkbox'
6+
7+
const styles = {
8+
container: {
9+
display: 'flex' as 'flex',
10+
flexDirection: 'column' as 'column',
11+
},
12+
}
13+
14+
storiesOf('Checkbox', module)
15+
.addDecorator(SideBarDecorator)
16+
.add('Checkboxes', () => (
17+
<div style={styles.container}>
18+
<span>
19+
<Checkbox status="COMPLETE" /> Checked
20+
</span>
21+
<span>
22+
341A <Checkbox status="INCOMPLETE" /> Unchecked
23+
</span>
24+
<span>
25+
<Checkbox status="LOADING" /> Loading
26+
</span>
27+
</div>
28+
))

0 commit comments

Comments
 (0)
0