From dc879a449b41d744c4f036ac03c0dca5ef4fe743 Mon Sep 17 00:00:00 2001 From: apanizo Date: Tue, 4 Sep 2018 17:00:58 +0200 Subject: [PATCH] Extracting general Provider info layout into a common shared local component --- src/components/Header/component/Provider.jsx | 73 +++++++++++++++++++ .../Header/component/Provider/index.jsx | 49 ------------- 2 files changed, 73 insertions(+), 49 deletions(-) create mode 100644 src/components/Header/component/Provider.jsx delete mode 100644 src/components/Header/component/Provider/index.jsx diff --git a/src/components/Header/component/Provider.jsx b/src/components/Header/component/Provider.jsx new file mode 100644 index 00000000..9abad16b --- /dev/null +++ b/src/components/Header/component/Provider.jsx @@ -0,0 +1,73 @@ +// @flow +import * as React from 'react' +import { withStyles } from '@material-ui/core/styles' +import IconButton from '@material-ui/core/IconButton' +import ExpandLess from '@material-ui/icons/ExpandLess' +import ExpandMore from '@material-ui/icons/ExpandMore' +import Col from '~/components/layout/Col' +import { type Open } from '~/components/hoc/OpenHoc' +import { sm, md } from '~/theme/variables' + +type Props = Open & { + classes: Object, + popupDetails: React$Node, + info: React$Node, + children: Function, +} + +const styles = () => ({ + root: { + height: '100%', + display: 'flex', + alignItems: 'center', + }, + provider: { + padding: `${sm} ${md}`, + alignItems: 'center', + flex: '0 1 auto', + display: 'flex', + cursor: 'pointer', + }, + expand: { + width: '30px', + height: '30px', + }, +}) + +type ProviderRef = { current: null | HTMLDivElement } + +class Provider extends React.Component { + constructor(props: Props) { + super(props) + + this.myRef = React.createRef() + } + + myRef: ProviderRef + + render() { + const { + open, toggle, children, classes, info, + } = this.props + + return ( + +
+ + { info } + + { open ? : } + + +
+ { children(this.myRef) } +
+ ) + } +} + +export default withStyles(styles)(Provider) diff --git a/src/components/Header/component/Provider/index.jsx b/src/components/Header/component/Provider/index.jsx deleted file mode 100644 index 9153f3bf..00000000 --- a/src/components/Header/component/Provider/index.jsx +++ /dev/null @@ -1,49 +0,0 @@ -// @flow -import * as React from 'react' -import openHoc, { type Open } from '~/components/hoc/OpenHoc' -import ClickAwayListener from '@material-ui/core/ClickAwayListener' -import Grow from '@material-ui/core/Grow' -import Popper from '@material-ui/core/Popper' -import Connected from './Connected' -import UserDetails from './UserDetails' - -type Props = Open & { - provider: string, - network: string, - userAddress: string, - connected: boolean, -} - -const Provider = ({ - open, toggle, provider, network, userAddress, connected, -}: Props) => ( - - {providerRef => ( - - {({ TransitionProps }) => ( - - - - - - )} - - )} - -) - -export default openHoc(Provider)