File tree Expand file tree Collapse file tree 1 file changed +44
-22
lines changed
web-app/src/components/Checkbox Expand file tree Collapse file tree 1 file changed +44
-22
lines changed Original file line number Diff line number Diff line change 11import * as React from 'react'
22
33const styles = {
4- box : {
5- display : 'flex' ,
6- alignItems : 'center' ,
7- justifyContent : 'center' ,
8- } ,
9- input : {
10- border : '1px solid black' ,
11- backgroundColor : 'yellow' ,
12- } ,
4+ box : {
5+ display : 'flex' ,
6+ alignItems : 'center' ,
7+ justifyContent : 'center' ,
8+ } ,
9+ input : {
10+ border : '1px solid black' ,
11+ } ,
12+ loading : {
13+ backgroundColor : 'red' ,
14+ } ,
1315}
1416
1517interface Props {
16- status : 'COMPLETE' | 'INCOMPLETE' | 'ACTIVE' | 'LOADING'
18+ status : 'COMPLETE' | 'INCOMPLETE' | 'ACTIVE' | 'LOADING'
1719}
1820
1921const 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- )
22+ const onChange = ( ) => {
23+ /* read only */
24+ }
25+
26+ if ( props . status === 'LOADING' ) {
27+ return (
28+ < div style = { styles . box } >
29+ < input
30+ ref = { input => {
31+ /* ref because unable to apply indeterminate on jsx */
32+ if ( input ) {
33+ input . indeterminate = true
34+ }
35+ } }
36+ type = "checkbox"
37+ checked = { false }
38+ disabled = { true }
39+ onChange = { onChange }
40+ />
41+ </ div >
42+ )
43+ }
44+
45+ const checked = props . status === 'COMPLETE'
46+
47+ return (
48+ < div style = { styles . box } >
49+ < label >
50+ < input style = { styles . input } type = "checkbox" checked = { checked } onChange = { onChange } />
51+ </ label >
52+ </ div >
53+ )
3254}
3355
3456export default Checkbox
You can’t perform that action at this time.
0 commit comments