forked from cypress-io/cypress-react-unit-test
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckbox-labels.js
114 lines (110 loc) · 2.87 KB
/
checkbox-labels.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import React from 'react'
import { withStyles } from '@material-ui/core/styles'
import { green } from '@material-ui/core/colors'
import FormGroup from '@material-ui/core/FormGroup'
import FormControlLabel from '@material-ui/core/FormControlLabel'
import Checkbox from '@material-ui/core/Checkbox'
import CheckBoxOutlineBlankIcon from '@material-ui/icons/CheckBoxOutlineBlank'
import CheckBoxIcon from '@material-ui/icons/CheckBox'
import Favorite from '@material-ui/icons/Favorite'
import FavoriteBorder from '@material-ui/icons/FavoriteBorder'
const GreenCheckbox = withStyles({
root: {
color: green[400],
'&$checked': {
color: green[600],
},
},
checked: {},
})(props => <Checkbox color="default" {...props} />)
export default function CheckboxLabels() {
const [state, setState] = React.useState({
checkedA: true,
checkedB: true,
checkedF: true,
checkedG: true,
})
const handleChange = name => event => {
setState({ ...state, [name]: event.target.checked })
}
return (
<FormGroup row>
<FormControlLabel
control={
<Checkbox
checked={state.checkedA}
onChange={handleChange('checkedA')}
value="checkedA"
/>
}
label="Secondary"
/>
<FormControlLabel
control={
<Checkbox
checked={state.checkedB}
onChange={handleChange('checkedB')}
value="checkedB"
color="primary"
/>
}
label="Primary"
/>
<FormControlLabel
control={<Checkbox value="checkedC" />}
label="Uncontrolled"
/>
<FormControlLabel
disabled
control={<Checkbox value="checkedD" />}
label="Disabled"
/>
<FormControlLabel
disabled
control={<Checkbox checked value="checkedE" />}
label="Disabled"
/>
<FormControlLabel
control={
<Checkbox
checked={state.checkedF}
onChange={handleChange('checkedF')}
value="checkedF"
indeterminate
/>
}
label="Indeterminate"
/>
<FormControlLabel
control={
<GreenCheckbox
checked={state.checkedG}
onChange={handleChange('checkedG')}
value="checkedG"
/>
}
label="Custom color"
/>
<FormControlLabel
control={
<Checkbox
icon={<FavoriteBorder />}
checkedIcon={<Favorite />}
value="checkedH"
/>
}
label="Custom icon"
/>
<FormControlLabel
control={
<Checkbox
icon={<CheckBoxOutlineBlankIcon fontSize="small" />}
checkedIcon={<CheckBoxIcon fontSize="small" />}
value="checkedI"
/>
}
label="Custom size"
/>
</FormGroup>
)
}