Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit121d5cb

Browse files
committed
create indeterminate loading checkbox
1 parent12962fa commit121d5cb

File tree

1 file changed

+44
-22
lines changed

1 file changed

+44
-22
lines changed
Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,56 @@
11
import*asReactfrom'react'
22

33
conststyles={
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

1517
interfaceProps{
16-
status:'COMPLETE'|'INCOMPLETE'|'ACTIVE'|'LOADING'
18+
status:'COMPLETE'|'INCOMPLETE'|'ACTIVE'|'LOADING'
1719
}
1820

1921
constCheckbox=(props:Props)=>{
20-
constchecked=props.status==='COMPLETE'
21-
// const loading = props.state === 'LOADING'
22-
constonChange=()=>{
23-
/* read */
24-
}
25-
return(
26-
<divstyle={styles.box}>
27-
<label>
28-
<inputstyle={styles.input}type="checkbox"checked={checked}onChange={onChange}/>
29-
</label>
30-
</div>
31-
)
22+
constonChange=()=>{
23+
/* read only */
24+
}
25+
26+
if(props.status==='LOADING'){
27+
return(
28+
<divstyle={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+
constchecked=props.status==='COMPLETE'
46+
47+
return(
48+
<divstyle={styles.box}>
49+
<label>
50+
<inputstyle={styles.input}type="checkbox"checked={checked}onChange={onChange}/>
51+
</label>
52+
</div>
53+
)
3254
}
3355

3456
exportdefaultCheckbox

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp