-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Selection Control] Symmetry between the demos (#10279)
- Loading branch information
1 parent
9ad0049
commit 02081e2
Showing
10 changed files
with
286 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { withStyles } from 'material-ui/styles'; | ||
import green from 'material-ui/colors/green'; | ||
import { FormGroup, FormControlLabel } from 'material-ui/Form'; | ||
import Checkbox from 'material-ui/Checkbox'; | ||
|
||
const styles = { | ||
checked: { | ||
color: green[500], | ||
}, | ||
}; | ||
|
||
class CheckboxLabels extends React.Component { | ||
state = { | ||
checkedA: true, | ||
checkedB: true, | ||
checkedF: true, | ||
checkedG: true, | ||
}; | ||
|
||
handleChange = name => event => { | ||
this.setState({ [name]: event.target.checked }); | ||
}; | ||
|
||
render() { | ||
const { classes } = this.props; | ||
|
||
return ( | ||
<FormGroup row> | ||
<FormControlLabel | ||
control={ | ||
<Checkbox | ||
checked={this.state.checkedA} | ||
onChange={this.handleChange('checkedA')} | ||
value="checkedA" | ||
/> | ||
} | ||
label="Secondary" | ||
/> | ||
<FormControlLabel | ||
control={ | ||
<Checkbox | ||
checked={this.state.checkedB} | ||
onChange={this.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={this.state.checkedF} | ||
onChange={this.handleChange('checkedF')} | ||
value="checkedF" | ||
indeterminate | ||
/> | ||
} | ||
label="Indeterminate" | ||
/> | ||
<FormControlLabel | ||
control={ | ||
<Checkbox | ||
checked={this.state.checkedG} | ||
onChange={this.handleChange('checkedG')} | ||
value="checkedG" | ||
classes={{ | ||
checked: classes.checked, | ||
}} | ||
/> | ||
} | ||
label="Custom color" | ||
/> | ||
</FormGroup> | ||
); | ||
} | ||
} | ||
|
||
CheckboxLabels.propTypes = { | ||
classes: PropTypes.object.isRequired, | ||
}; | ||
|
||
export default withStyles(styles)(CheckboxLabels); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,92 +1,43 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { withStyles } from 'material-ui/styles'; | ||
import green from 'material-ui/colors/green'; | ||
import { FormGroup, FormControlLabel } from 'material-ui/Form'; | ||
import Checkbox from 'material-ui/Checkbox'; | ||
|
||
const styles = { | ||
checked: { | ||
color: green[500], | ||
}, | ||
}; | ||
|
||
class Checkboxes extends React.Component { | ||
state = { | ||
checkedA: true, | ||
checkedB: true, | ||
checkedF: true, | ||
checkedG: true, | ||
}; | ||
|
||
handleChange = name => event => { | ||
this.setState({ [name]: event.target.checked }); | ||
}; | ||
|
||
render() { | ||
const { classes } = this.props; | ||
|
||
return ( | ||
<FormGroup row> | ||
<FormControlLabel | ||
control={ | ||
<Checkbox | ||
checked={this.state.checkedA} | ||
onChange={this.handleChange('checkedA')} | ||
value="checkedA" | ||
/> | ||
} | ||
label="Option A" | ||
/> | ||
<FormControlLabel | ||
control={ | ||
<Checkbox | ||
checked={this.state.checkedB} | ||
onChange={this.handleChange('checkedB')} | ||
value="checkedB" | ||
color="primary" | ||
/> | ||
} | ||
label="Option B" | ||
<div> | ||
<Checkbox | ||
checked={this.state.checkedA} | ||
onChange={this.handleChange('checkedA')} | ||
value="checkedA" | ||
/> | ||
<FormControlLabel control={<Checkbox value="checkedC" />} label="Option C" /> | ||
<FormControlLabel disabled control={<Checkbox value="checkedD" />} label="Disabled" /> | ||
<FormControlLabel | ||
disabled | ||
control={<Checkbox checked value="checkedE" />} | ||
label="Disabled" | ||
<Checkbox | ||
checked={this.state.checkedB} | ||
onChange={this.handleChange('checkedB')} | ||
value="checkedB" | ||
color="primary" | ||
/> | ||
<FormControlLabel | ||
control={ | ||
<Checkbox | ||
checked={this.state.checkedF} | ||
onChange={this.handleChange('checkedF')} | ||
value="checkedF" | ||
indeterminate | ||
/> | ||
} | ||
label="Indeterminate" | ||
<Checkbox value="checkedC" /> | ||
<Checkbox disabled value="checkedD" /> | ||
<Checkbox disabled checked value="checkedE" /> | ||
<Checkbox | ||
checked={this.state.checkedF} | ||
onChange={this.handleChange('checkedF')} | ||
value="checkedF" | ||
indeterminate | ||
/> | ||
<FormControlLabel | ||
control={ | ||
<Checkbox | ||
checked={this.state.checkedG} | ||
onChange={this.handleChange('checkedG')} | ||
classes={{ | ||
checked: classes.checked, | ||
}} | ||
value="checkedG" | ||
/> | ||
} | ||
label="Custom color" | ||
/> | ||
</FormGroup> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
Checkboxes.propTypes = { | ||
classes: PropTypes.object.isRequired, | ||
}; | ||
|
||
export default withStyles(styles)(Checkboxes); | ||
export default Checkboxes; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,81 @@ | ||
import React from 'react'; | ||
import { FormControlLabel, FormGroup } from 'material-ui/Form'; | ||
import PropTypes from 'prop-types'; | ||
import { withStyles } from 'material-ui/styles'; | ||
import green from 'material-ui/colors/green'; | ||
import { FormGroup, FormControlLabel } from 'material-ui/Form'; | ||
import Switch from 'material-ui/Switch'; | ||
|
||
const styles = { | ||
checked: { | ||
color: green[500], | ||
'& + $bar': { | ||
backgroundColor: green[500], | ||
}, | ||
}, | ||
bar: {}, | ||
}; | ||
|
||
class SwitchLabels extends React.Component { | ||
state = { | ||
checkedA: true, | ||
checkedB: false, | ||
checkedB: true, | ||
checkedF: true, | ||
}; | ||
|
||
handleChange = name => event => { | ||
this.setState({ [name]: event.target.checked }); | ||
}; | ||
|
||
render() { | ||
const { classes } = this.props; | ||
|
||
return ( | ||
<FormGroup> | ||
<FormGroup row> | ||
<FormControlLabel | ||
control={ | ||
<Switch | ||
checked={this.state.checkedA} | ||
onChange={(event, checked) => this.setState({ checkedA: checked })} | ||
onChange={this.handleChange('checkedA')} | ||
value="checkedA" | ||
/> | ||
} | ||
label="A" | ||
label="Secondary" | ||
/> | ||
<FormControlLabel | ||
control={ | ||
<Switch | ||
checked={this.state.checkedB} | ||
onChange={(event, checked) => this.setState({ checkedB: checked })} | ||
onChange={this.handleChange('checkedB')} | ||
value="checkedB" | ||
color="primary" | ||
/> | ||
} | ||
label="B" | ||
label="Primary" | ||
/> | ||
<FormControlLabel control={<Switch value="checkedC" />} label="Uncontrolled" /> | ||
<FormControlLabel disabled control={<Switch value="checkedD" />} label="Disabled" /> | ||
<FormControlLabel disabled control={<Switch checked value="checkedE" />} label="Disabled" /> | ||
<FormControlLabel | ||
control={ | ||
<Switch | ||
checked={this.state.checkedF} | ||
onChange={this.handleChange('checkedF')} | ||
value="checkedF" | ||
classes={{ | ||
checked: classes.checked, | ||
bar: classes.bar, | ||
}} | ||
/> | ||
} | ||
label="Custom color" | ||
/> | ||
<FormControlLabel control={<Switch />} disabled label="C" /> | ||
</FormGroup> | ||
); | ||
} | ||
} | ||
|
||
export default SwitchLabels; | ||
SwitchLabels.propTypes = { | ||
classes: PropTypes.object.isRequired, | ||
}; | ||
|
||
export default withStyles(styles)(SwitchLabels); |
Oops, something went wrong.