From b3f01770c9fbd5e1d0950517d1422dcd772f55d7 Mon Sep 17 00:00:00 2001 From: George Lima Date: Wed, 10 Apr 2019 19:53:32 -0300 Subject: [PATCH] feat(status-pill): add status tooltip onHover --- app/components/status-pill.js | 78 ++++++++++++++++++++++++++++++++++- 1 file changed, 76 insertions(+), 2 deletions(-) diff --git a/app/components/status-pill.js b/app/components/status-pill.js index 25c2d8d..ef8e68d 100644 --- a/app/components/status-pill.js +++ b/app/components/status-pill.js @@ -32,6 +32,7 @@ const Wrapper = styled.div` border: 1px solid ${props => props.theme.colors.statusPillBorder} border-radius: 27px; padding: 8px 16px; + position: relative; `; const Icon = styled.img` @@ -53,16 +54,63 @@ const StatusPillLabel = styled(TextComponent)` user-select: none; `; +const Tooltip = styled.div` + background: ${props => props.theme.colors.walletAddressTooltipBg}; + position: absolute; + bottom: -35px; + right: 5px; + padding: 6px 10px; + border-radius: ${props => props.theme.boxBorderRadius}; + z-index: 100; + white-space: nowrap; + + &:after { + bottom: 100%; + left: 90%; + border: solid transparent; + content: ' '; + height: 0; + width: 0; + position: absolute; + pointer-events: none; + } + + &:after { + border-color: transparent; + border-bottom-color: ${props => props.theme.colors.walletAddressTooltipBg}; + border-width: 5px; + margin-left: -5px; + } +`; + +const TooltipText = styled(TextComponent)` + color: ${props => props.theme.colors.walletAddressTooltip}; + font-size: 10px; + font-weight: 700; +`; + type Props = { theme: AppTheme, } & MapStateToProps & MapDispatchToProps; +type State = { + showTooltip: boolean, +}; + const MINUTE_IN_MILI = 60000; -class Component extends PureComponent { +class Component extends PureComponent { timer: ?IntervalID = null; + constructor(props) { + super(props); + + this.state = { + showTooltip: false, + }; + } + componentDidMount() { const { getBlockchainStatus } = this.props; @@ -124,14 +172,40 @@ class Component extends PureComponent { } }; + getStatusText = () => { + const { nodeSyncType } = this.props; + + switch (nodeSyncType) { + case 'syncing': + return "Syncing blockchain data. You may not send funds or see latest transactions until it's synced 100%"; + case 'ready': + return 'Your chain data is up to date'; + case 'error': + return 'There was an error. Try restarting Zepio'; + default: + return ''; + } + }; + render() { const icon = this.getIcon(); const { nodeSyncType, nodeSyncProgress } = this.props; + const { showTooltip } = this.state; const percent = nodeSyncType === 'syncing' ? `(${nodeSyncProgress.toFixed(2)}%)` : ''; const typeText = nodeSyncType === 'ready' ? 'Synced' : nodeSyncType; return ( - + // eslint-disable-next-line + this.setState({ showTooltip: true })} + onMouseOut={() => this.setState({ showTooltip: false })} + id='status-pill' + > + {showTooltip && ( + + + + )} {icon && }