1
0
mirror of https://github.com/oceanprotocol/commons.git synced 2023-03-15 18:03:00 +01:00
commons/src/components/molecules/AccountStatus/index.tsx

53 lines
1.4 KiB
TypeScript
Raw Normal View History

import React, { PureComponent } from 'react'
import Popover from 'react-popover'
import AccountPopover from './Popover'
import AccountIndicator from './Indicator'
interface AccountStatusProps {
className?: string
}
interface AccountStatusState {
popoverIsOpen: boolean
}
export default class AccountStatus extends PureComponent<
AccountStatusProps,
AccountStatusState
> {
public state = {
popoverIsOpen: false
}
public togglePopover(toState?: boolean) {
const popoverIsOpen =
typeof toState === 'boolean' ? toState : !this.state.popoverIsOpen
this.setState({ popoverIsOpen })
}
public render() {
const popoverProps = {
isOpen: this.state.popoverIsOpen,
enterExitTransitionDurationMs: 300,
tipSize: 0.01,
onOuterAction: () => this.togglePopover(false),
2019-02-26 17:32:47 +01:00
body: (
<AccountPopover
showPopover={() => this.togglePopover(true)}
hidePopover={() => this.togglePopover(false)}
/>
)
}
return (
<Popover {...popoverProps}>
<AccountIndicator
showPopover={() => this.togglePopover(true)}
2019-02-26 17:32:47 +01:00
hidePopover={() => this.togglePopover(false)}
className={this.props.className}
/>
</Popover>
)
}
}