forked from mui/material-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Badge] Add invisible property (mui#13534)
* [Badge] Added hide property [Badge] Added hide property tests [docs] Added hide property demo * [Badge] Changed style to use theme transition helper [Badge] Merged shown class into root class * [Badge] Changed hide property to invisible property [docs] Updated Docs with Badge property change * [docs] Fixed incorrect import * let's merge
- Loading branch information
1 parent
bfeec95
commit 48d6076
Showing
7 changed files
with
140 additions
and
1 deletion.
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,58 @@ | ||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { withStyles } from '@material-ui/core/styles'; | ||
import Badge from '@material-ui/core/Badge'; | ||
import MailIcon from '@material-ui/icons/Mail'; | ||
import Switch from '@material-ui/core/Switch'; | ||
import FormGroup from '@material-ui/core/FormGroup'; | ||
import FormControlLabel from '@material-ui/core/FormControlLabel'; | ||
|
||
const styles = theme => ({ | ||
root: { | ||
display: 'flex', | ||
flexDirection: 'column', | ||
alignItems: 'center', | ||
}, | ||
margin: { | ||
margin: theme.spacing.unit, | ||
}, | ||
}); | ||
|
||
class BadgeVisibility extends Component { | ||
state = { | ||
invisible: false, | ||
}; | ||
|
||
handleBadgeVisibility = () => { | ||
this.setState(prevState => ({ invisible: !prevState.invisible })); | ||
}; | ||
|
||
render() { | ||
const { classes } = this.props; | ||
const { invisible } = this.state; | ||
|
||
return ( | ||
<div className={classes.root}> | ||
<div className={classes.margin}> | ||
<Badge color="secondary" badgeContent={4} invisible={invisible}> | ||
<MailIcon /> | ||
</Badge> | ||
</div> | ||
<FormGroup row> | ||
<FormControlLabel | ||
control={ | ||
<Switch color="primary" checked={!invisible} onChange={this.handleBadgeVisibility} /> | ||
} | ||
label="Show Badge" | ||
/> | ||
</FormGroup> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
BadgeVisibility.propTypes = { | ||
classes: PropTypes.object.isRequired, | ||
}; | ||
|
||
export default withStyles(styles)(BadgeVisibility); |
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
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