2019-02-26 15:22:12 +01:00
|
|
|
import React, { PureComponent } from 'react'
|
2019-03-01 20:21:00 +01:00
|
|
|
import { Manager, Reference, Popper } from 'react-popper'
|
2019-02-26 15:22:12 +01:00
|
|
|
import AccountPopover from './Popover'
|
|
|
|
import AccountIndicator from './Indicator'
|
|
|
|
|
|
|
|
interface AccountStatusProps {
|
|
|
|
className?: string
|
|
|
|
}
|
|
|
|
|
|
|
|
interface AccountStatusState {
|
2019-02-27 00:26:53 +01:00
|
|
|
isPopoverOpen: boolean
|
2019-02-26 15:22:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export default class AccountStatus extends PureComponent<
|
|
|
|
AccountStatusProps,
|
|
|
|
AccountStatusState
|
|
|
|
> {
|
|
|
|
public state = {
|
2019-02-27 00:26:53 +01:00
|
|
|
isPopoverOpen: false
|
2019-02-26 15:22:12 +01:00
|
|
|
}
|
|
|
|
|
2019-04-30 19:19:28 +02:00
|
|
|
private togglePopover() {
|
2020-05-19 10:36:18 +02:00
|
|
|
this.setState((prevState) => ({
|
2019-02-27 00:26:53 +01:00
|
|
|
isPopoverOpen: !prevState.isPopoverOpen
|
|
|
|
}))
|
2019-02-26 15:22:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public render() {
|
|
|
|
return (
|
2019-03-01 20:21:00 +01:00
|
|
|
<Manager>
|
|
|
|
<Reference>
|
2019-11-07 11:19:12 +01:00
|
|
|
{({ ref }: { ref: any }) => (
|
2019-03-01 20:21:00 +01:00
|
|
|
<AccountIndicator
|
|
|
|
togglePopover={() => this.togglePopover()}
|
|
|
|
className={this.props.className}
|
|
|
|
forwardedRef={ref}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</Reference>
|
|
|
|
{this.state.isPopoverOpen && (
|
|
|
|
<Popper placement="auto">
|
2019-11-07 11:19:12 +01:00
|
|
|
{({
|
|
|
|
ref,
|
|
|
|
style,
|
|
|
|
placement
|
|
|
|
}: {
|
|
|
|
ref: any
|
|
|
|
style: any
|
|
|
|
placement: any
|
|
|
|
}) => (
|
2019-03-01 20:21:00 +01:00
|
|
|
<AccountPopover
|
|
|
|
forwardedRef={ref}
|
|
|
|
style={style}
|
|
|
|
data-placement={placement}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</Popper>
|
2019-02-27 00:26:53 +01:00
|
|
|
)}
|
2019-03-01 20:21:00 +01:00
|
|
|
</Manager>
|
2019-02-26 15:22:12 +01:00
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|