mirror of
https://github.com/status-im/safe-react.git
synced 2025-01-15 12:34:17 +00:00
Moving Popper into Header's Layout and reusing openHoc attrs from there
This commit is contained in:
parent
89a8951247
commit
425a0db985
@ -6,14 +6,19 @@ import openHoc, { type Open } from '~/components/hoc/OpenHoc'
|
|||||||
import Col from '~/components/layout/Col'
|
import Col from '~/components/layout/Col'
|
||||||
import Img from '~/components/layout/Img'
|
import Img from '~/components/layout/Img'
|
||||||
import Row from '~/components/layout/Row'
|
import Row from '~/components/layout/Row'
|
||||||
|
import Grow from '@material-ui/core/Grow'
|
||||||
|
import ClickAwayListener from '@material-ui/core/ClickAwayListener'
|
||||||
|
import Popper from '@material-ui/core/Popper'
|
||||||
import Spacer from '~/components/Spacer'
|
import Spacer from '~/components/Spacer'
|
||||||
import { border, sm, md } from '~/theme/variables'
|
import { border, sm, md } from '~/theme/variables'
|
||||||
|
import Provider from './Provider'
|
||||||
|
|
||||||
const logo = require('../assets/gnosis-safe-logo.svg')
|
const logo = require('../assets/gnosis-safe-logo.svg')
|
||||||
|
|
||||||
type Props = Open & {
|
type Props = Open & {
|
||||||
classes: Object,
|
classes: Object,
|
||||||
children: React$Node,
|
providerDetails: React$Node,
|
||||||
|
providerInfo: React$Node,
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = () => ({
|
const styles = () => ({
|
||||||
@ -29,7 +34,9 @@ const styles = () => ({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const Header = openHoc(({ classes, children }: Props) => (
|
const Layout = openHoc(({
|
||||||
|
open, toggle, classes, providerInfo, providerDetails,
|
||||||
|
}: Props) => (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<Row className={classes.summary}>
|
<Row className={classes.summary}>
|
||||||
<Col start="xs" middle="xs" className={classes.logo}>
|
<Col start="xs" middle="xs" className={classes.logo}>
|
||||||
@ -38,9 +45,23 @@ const Header = openHoc(({ classes, children }: Props) => (
|
|||||||
<Divider />
|
<Divider />
|
||||||
<Spacer />
|
<Spacer />
|
||||||
<Divider />
|
<Divider />
|
||||||
{ children }
|
<Provider open={open} toggle={toggle} info={providerInfo}>
|
||||||
|
{providerRef => (
|
||||||
|
<Popper open={open} anchorEl={providerRef.current} placement="bottom-end">
|
||||||
|
{({ TransitionProps }) => (
|
||||||
|
<Grow
|
||||||
|
{...TransitionProps}
|
||||||
|
>
|
||||||
|
<ClickAwayListener onClickAway={toggle}>
|
||||||
|
{providerDetails}
|
||||||
|
</ClickAwayListener>
|
||||||
|
</Grow>
|
||||||
|
)}
|
||||||
|
</Popper>
|
||||||
|
)}
|
||||||
|
</Provider>
|
||||||
</Row>
|
</Row>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
))
|
))
|
||||||
|
|
||||||
export default withStyles(styles)(Header)
|
export default withStyles(styles)(Layout)
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
// @flow
|
// @flow
|
||||||
import { select } from '@storybook/addon-knobs'
|
|
||||||
import { storiesOf } from '@storybook/react'
|
import { storiesOf } from '@storybook/react'
|
||||||
import * as React from 'react'
|
import * as React from 'react'
|
||||||
import styles from '~/components/layout/PageFrame/index.scss'
|
import styles from '~/components/layout/PageFrame/index.scss'
|
||||||
import Component from './Layout'
|
import Layout from './Layout'
|
||||||
|
import ProviderInfo from './ProviderInfo'
|
||||||
|
import ProviderDetails from './ProviderInfo/UserDetails'
|
||||||
|
import ProviderDisconnected from './ProviderDisconnected'
|
||||||
|
import ConnectDetails from './ProviderDisconnected/ConnectDetails'
|
||||||
|
|
||||||
const FrameDecorator = story => (
|
const FrameDecorator = story => (
|
||||||
<div className={styles.frame}>
|
<div className={styles.frame}>
|
||||||
@ -13,8 +16,18 @@ const FrameDecorator = story => (
|
|||||||
|
|
||||||
storiesOf('Components', module)
|
storiesOf('Components', module)
|
||||||
.addDecorator(FrameDecorator)
|
.addDecorator(FrameDecorator)
|
||||||
.add('Header', () => {
|
.add('Connected Header', () => {
|
||||||
// https://github.com/storybooks/storybook/tree/master/addons/knobs#select
|
const provider = 'METAMASK'
|
||||||
const provider = select('Status by Provider', ['', 'UNKNOWN', 'METAMASK', 'PARITY'], 'METAMASK')
|
const userAddress = '0x873faa4cddd5b157e8e5a57e7a5479afc5d30moe'
|
||||||
return <Component provider={provider} reloadWallet={() => {}} />
|
const network = 'RINKEBY'
|
||||||
|
const info = <ProviderInfo provider={provider} network={network} userAddress={userAddress} connected />
|
||||||
|
const details = <ProviderDetails provider={provider} network={network} userAddress={userAddress} connected />
|
||||||
|
|
||||||
|
return <Layout providerInfo={info} providerDetails={details} />
|
||||||
|
})
|
||||||
|
.add('Disconnected Header', () => {
|
||||||
|
const info = <ProviderDisconnected />
|
||||||
|
const details = <ConnectDetails />
|
||||||
|
|
||||||
|
return <Layout providerInfo={info} providerDetails={details} />
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user