-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4292592
commit 974f250
Showing
27 changed files
with
285 additions
and
709 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
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import React from 'react'; | ||
import Button from '@material-ui/core/Button'; | ||
import Menu from '@material-ui/core/Menu'; | ||
import MenuItem from '@material-ui/core/MenuItem'; | ||
import toRenderProps from 'recompose/toRenderProps'; | ||
import withState from 'recompose/withState'; | ||
|
||
const WithState = toRenderProps(withState('anchorEl', 'updateAnchorEl', null)); | ||
|
||
function RenderPropsMenu() { | ||
return ( | ||
<WithState> | ||
{({ anchorEl, updateAnchorEl }) => { | ||
const open = Boolean(anchorEl); | ||
const handleClose = () => { | ||
updateAnchorEl(null); | ||
}; | ||
|
||
return ( | ||
<React.Fragment> | ||
<Button | ||
aria-owns={open ? 'render-props-menu' : null} | ||
aria-haspopup="true" | ||
onClick={event => { | ||
updateAnchorEl(event.currentTarget); | ||
}} | ||
> | ||
Open Menu | ||
</Button> | ||
<Menu id="render-props-menu" anchorEl={anchorEl} open={open} onClose={handleClose}> | ||
<MenuItem onClick={handleClose}>Profile</MenuItem> | ||
<MenuItem onClick={handleClose}>My account</MenuItem> | ||
<MenuItem onClick={handleClose}>Logout</MenuItem> | ||
</Menu> | ||
</React.Fragment> | ||
); | ||
}} | ||
</WithState> | ||
); | ||
} | ||
|
||
export default RenderPropsMenu; |
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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { withStyles } from '@material-ui/core/styles'; | ||
import Typography from '@material-ui/core/Typography'; | ||
import Button from '@material-ui/core/Button'; | ||
import Popover from '@material-ui/core/Popover'; | ||
import toRenderProps from 'recompose/toRenderProps'; | ||
import withState from 'recompose/withState'; | ||
|
||
const WithState = toRenderProps(withState('anchorEl', 'updateAnchorEl', null)); | ||
|
||
const styles = theme => ({ | ||
typography: { | ||
margin: theme.spacing.unit * 2, | ||
}, | ||
}); | ||
|
||
function RenderPropsPopover(props) { | ||
const { classes } = props; | ||
|
||
return ( | ||
<WithState> | ||
{({ anchorEl, updateAnchorEl }) => { | ||
const open = Boolean(anchorEl); | ||
return ( | ||
<React.Fragment> | ||
<Button | ||
aria-owns={open ? 'render-props-popover' : null} | ||
aria-haspopup="true" | ||
variant="contained" | ||
onClick={event => { | ||
updateAnchorEl(event.currentTarget); | ||
}} | ||
> | ||
Open Popover | ||
</Button> | ||
<Popover | ||
id="render-props-popover" | ||
open={open} | ||
anchorEl={anchorEl} | ||
onClose={() => { | ||
updateAnchorEl(null); | ||
}} | ||
anchorOrigin={{ | ||
vertical: 'bottom', | ||
horizontal: 'center', | ||
}} | ||
transformOrigin={{ | ||
vertical: 'top', | ||
horizontal: 'center', | ||
}} | ||
> | ||
<Typography className={classes.typography}>The content of the Popover.</Typography> | ||
</Popover> | ||
</React.Fragment> | ||
); | ||
}} | ||
</WithState> | ||
); | ||
} | ||
|
||
RenderPropsPopover.propTypes = { | ||
classes: PropTypes.object.isRequired, | ||
}; | ||
|
||
export default withStyles(styles)(RenderPropsPopover); |
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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { withStyles } from '@material-ui/core/styles'; | ||
import Popper from '@material-ui/core/Popper'; | ||
import Typography from '@material-ui/core/Typography'; | ||
import Button from '@material-ui/core/Button'; | ||
import Fade from '@material-ui/core/Fade'; | ||
import Paper from '@material-ui/core/Paper'; | ||
import toRenderProps from 'recompose/toRenderProps'; | ||
import withState from 'recompose/withState'; | ||
|
||
const WithState = toRenderProps(withState('anchorEl', 'updateAnchorEl', null)); | ||
|
||
const styles = theme => ({ | ||
typography: { | ||
padding: theme.spacing.unit * 2, | ||
}, | ||
}); | ||
|
||
function RenderPropsPopper(props) { | ||
const { classes } = props; | ||
|
||
return ( | ||
<WithState> | ||
{({ anchorEl, updateAnchorEl }) => { | ||
const open = Boolean(anchorEl); | ||
const id = open ? 'render-props-popper' : null; | ||
return ( | ||
<React.Fragment> | ||
<Button | ||
aria-describedby={id} | ||
variant="contained" | ||
onClick={event => { | ||
updateAnchorEl(anchorEl ? null : event.currentTarget); | ||
}} | ||
> | ||
Toggle Popper | ||
</Button> | ||
<Popper id={id} open={open} anchorEl={anchorEl} transition> | ||
{({ TransitionProps }) => ( | ||
<Fade {...TransitionProps} timeout={350}> | ||
<Paper> | ||
<Typography className={classes.typography}> | ||
The content of the Popper. | ||
</Typography> | ||
</Paper> | ||
</Fade> | ||
)} | ||
</Popper> | ||
</React.Fragment> | ||
); | ||
}} | ||
</WithState> | ||
); | ||
} | ||
|
||
RenderPropsPopper.propTypes = { | ||
classes: PropTypes.object.isRequired, | ||
}; | ||
|
||
export default withStyles(styles)(RenderPropsPopper); |
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
Oops, something went wrong.