Make all Header's provider clickable

This commit is contained in:
apanizo 2018-10-16 12:33:10 +02:00
parent 70da5608b3
commit 82cac576e5
3 changed files with 8 additions and 5 deletions

View File

@ -44,7 +44,7 @@ const styles = () => ({
})
const Layout = openHoc(({
open, toggle, classes, providerInfo, providerDetails,
open, toggle, clickAway, classes, providerInfo, providerDetails,
}: Props) => (
<React.Fragment>
<Row className={classes.summary}>
@ -61,7 +61,7 @@ const Layout = openHoc(({
<Grow
{...TransitionProps}
>
<ClickAwayListener onClickAway={toggle}>
<ClickAwayListener onClickAway={clickAway} mouseEvent="onClick" touchEvent={false}>
<List className={classes.root} component="div">
{providerDetails}
</List>

View File

@ -54,10 +54,9 @@ class Provider extends React.Component<Props> {
return (
<React.Fragment>
<div ref={this.myRef} className={classes.root}>
<Col end="sm" middle="xs" className={classes.provider}>
<Col end="sm" middle="xs" className={classes.provider} onClick={toggle}>
{ info }
<IconButton
onClick={toggle}
disableRipple
className={classes.expand}
>

View File

@ -4,9 +4,13 @@ import { withStateHandlers } from 'recompose'
export type Open = {
open: boolean,
toggle: () => void,
clickAway: () => void,
}
export default withStateHandlers(
() => ({ open: false }),
{ toggle: ({ open }) => () => ({ open: !open }) },
{
toggle: ({ open }) => () => ({ open: !open }),
clickAway: () => () => ({ open: false }),
},
)