feat: hoverable tooltip
This commit is contained in:
parent
6170624be0
commit
c1d781d488
9 changed files with 57 additions and 24 deletions
|
|
@ -51,4 +51,35 @@ const Tooltip = memo(({ children, width, Icon = HelpIcon }) => {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
export default Tooltip
|
const HoverableTooltip = memo(({ parentElements, children, width }) => {
|
||||||
|
const classes = useStyles({ width })
|
||||||
|
const [helpPopperAnchorEl, setHelpPopperAnchorEl] = useState(null)
|
||||||
|
|
||||||
|
const handleOpenHelpPopper = event => {
|
||||||
|
setHelpPopperAnchorEl(helpPopperAnchorEl ? null : event.currentTarget)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleCloseHelpPopper = () => {
|
||||||
|
setHelpPopperAnchorEl(null)
|
||||||
|
}
|
||||||
|
|
||||||
|
const helpPopperOpen = Boolean(helpPopperAnchorEl)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<div
|
||||||
|
onMouseEnter={handleOpenHelpPopper}
|
||||||
|
onMouseLeave={handleCloseHelpPopper}>
|
||||||
|
{parentElements}
|
||||||
|
</div>
|
||||||
|
<Popper
|
||||||
|
open={helpPopperOpen}
|
||||||
|
anchorEl={helpPopperAnchorEl}
|
||||||
|
placement="bottom">
|
||||||
|
<div className={classes.popoverContent}>{children}</div>
|
||||||
|
</Popper>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
export { Tooltip, HoverableTooltip }
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import gql from 'graphql-tag'
|
||||||
import * as R from 'ramda'
|
import * as R from 'ramda'
|
||||||
import React, { useState } from 'react'
|
import React, { useState } from 'react'
|
||||||
|
|
||||||
import Tooltip from 'src/components/Tooltip'
|
import { Tooltip } from 'src/components/Tooltip'
|
||||||
import { Link } from 'src/components/buttons'
|
import { Link } from 'src/components/buttons'
|
||||||
import { Switch } from 'src/components/inputs'
|
import { Switch } from 'src/components/inputs'
|
||||||
import Sidebar from 'src/components/layout/Sidebar'
|
import Sidebar from 'src/components/layout/Sidebar'
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import gql from 'graphql-tag'
|
||||||
import * as R from 'ramda'
|
import * as R from 'ramda'
|
||||||
import React, { useState } from 'react'
|
import React, { useState } from 'react'
|
||||||
|
|
||||||
import Tooltip from 'src/components/Tooltip'
|
import { Tooltip } from 'src/components/Tooltip'
|
||||||
import { NamespacedTable as EditableTable } from 'src/components/editableTable'
|
import { NamespacedTable as EditableTable } from 'src/components/editableTable'
|
||||||
import { Switch } from 'src/components/inputs'
|
import { Switch } from 'src/components/inputs'
|
||||||
import TitleSection from 'src/components/layout/TitleSection'
|
import TitleSection from 'src/components/layout/TitleSection'
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import { makeStyles } from '@material-ui/core/styles'
|
||||||
import gql from 'graphql-tag'
|
import gql from 'graphql-tag'
|
||||||
import React, { memo } from 'react'
|
import React, { memo } from 'react'
|
||||||
|
|
||||||
import Tooltip from 'src/components/Tooltip'
|
import { Tooltip } from 'src/components/Tooltip'
|
||||||
import { Switch } from 'src/components/inputs'
|
import { Switch } from 'src/components/inputs'
|
||||||
import { H4, P, Label2 } from 'src/components/typography'
|
import { H4, P, Label2 } from 'src/components/typography'
|
||||||
import { fromNamespace, toNamespace, namespaces } from 'src/utils/config'
|
import { fromNamespace, toNamespace, namespaces } from 'src/utils/config'
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
import { makeStyles, Box, Tooltip } from '@material-ui/core'
|
import { makeStyles, Box } from '@material-ui/core'
|
||||||
import BigNumber from 'bignumber.js'
|
import BigNumber from 'bignumber.js'
|
||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
import React, { memo } from 'react'
|
import React, { memo } from 'react'
|
||||||
|
|
||||||
|
import { HoverableTooltip } from 'src/components/Tooltip'
|
||||||
import { IDButton } from 'src/components/buttons'
|
import { IDButton } from 'src/components/buttons'
|
||||||
import { Label1 } from 'src/components/typography'
|
import { P, Label1 } from 'src/components/typography'
|
||||||
import { ReactComponent as CardIdInverseIcon } from 'src/styling/icons/ID/card/white.svg'
|
import { ReactComponent as CardIdInverseIcon } from 'src/styling/icons/ID/card/white.svg'
|
||||||
import { ReactComponent as CardIdIcon } from 'src/styling/icons/ID/card/zodiac.svg'
|
import { ReactComponent as CardIdIcon } from 'src/styling/icons/ID/card/zodiac.svg'
|
||||||
import { ReactComponent as PhoneIdInverseIcon } from 'src/styling/icons/ID/phone/white.svg'
|
import { ReactComponent as PhoneIdInverseIcon } from 'src/styling/icons/ID/phone/white.svg'
|
||||||
|
|
@ -53,7 +54,12 @@ const DetailsRow = ({ it: tx }) => {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(tx)
|
const errorElements = (
|
||||||
|
<>
|
||||||
|
<Label>Transaction status</Label>
|
||||||
|
<span className={classes.bold}>{getStatus(tx)}</span>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classes.wrapper}>
|
<div className={classes.wrapper}>
|
||||||
|
|
@ -82,7 +88,7 @@ const DetailsRow = ({ it: tx }) => {
|
||||||
)}
|
)}
|
||||||
{tx.customerIdCardPhotoPath && !tx.customerIdCardData && (
|
{tx.customerIdCardPhotoPath && !tx.customerIdCardData && (
|
||||||
<IDButton
|
<IDButton
|
||||||
popoverClassname={classes.popover}
|
popoverClassname={classes.clipboardPopover}
|
||||||
className={classes.idButton}
|
className={classes.idButton}
|
||||||
name="card"
|
name="card"
|
||||||
Icon={CardIdIcon}
|
Icon={CardIdIcon}
|
||||||
|
|
@ -186,10 +192,13 @@ const DetailsRow = ({ it: tx }) => {
|
||||||
</div>
|
</div>
|
||||||
<div className={classes.lastRow}>
|
<div className={classes.lastRow}>
|
||||||
<div>
|
<div>
|
||||||
<Label>Transaction status</Label>
|
{getStatusDetails(tx) ? (
|
||||||
<Tooltip disableFocusListener title={getStatusDetails(tx)}>
|
<HoverableTooltip parentElements={errorElements} width={200}>
|
||||||
<span className={classes.bold}>{getStatus(tx)}</span>
|
<P>{getStatusDetails(tx)}</P>
|
||||||
</Tooltip>
|
</HoverableTooltip>
|
||||||
|
) : (
|
||||||
|
errorElements
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ export default {
|
||||||
txIcon: {
|
txIcon: {
|
||||||
marginRight: 10
|
marginRight: 10
|
||||||
},
|
},
|
||||||
popover: {
|
clipboardPopover: {
|
||||||
height: 164,
|
height: 164,
|
||||||
width: 215
|
width: 215
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,7 @@ const getCashOutStatus = it => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const getCashOutStatusDetails = it => {
|
const getCashOutStatusDetails = it => {
|
||||||
if (it.hasError) return it.hasError
|
return it.hasError ? it.hasError : null
|
||||||
if (it.dispense) return ''
|
|
||||||
if (it.expired) return ''
|
|
||||||
return 'Pending'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const getCashInStatus = it => {
|
const getCashInStatus = it => {
|
||||||
|
|
@ -21,11 +18,7 @@ const getCashInStatus = it => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const getCashInStatusDetails = it => {
|
const getCashInStatusDetails = it => {
|
||||||
if (it.operatorCompleted) return ''
|
return it.hasError ? it.hasError : null
|
||||||
if (it.hasError) return it.hasError
|
|
||||||
if (it.sendConfirmed) return ''
|
|
||||||
if (it.expired) return ''
|
|
||||||
return 'Pending'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const getStatus = it => {
|
const getStatus = it => {
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import * as R from 'ramda'
|
||||||
import React, { useState } from 'react'
|
import React, { useState } from 'react'
|
||||||
import { v4 } from 'uuid'
|
import { v4 } from 'uuid'
|
||||||
|
|
||||||
import Tooltip from 'src/components/Tooltip'
|
import { Tooltip } from 'src/components/Tooltip'
|
||||||
import { Link, Button } from 'src/components/buttons'
|
import { Link, Button } from 'src/components/buttons'
|
||||||
import { Table as EditableTable } from 'src/components/editableTable'
|
import { Table as EditableTable } from 'src/components/editableTable'
|
||||||
import { Switch } from 'src/components/inputs'
|
import { Switch } from 'src/components/inputs'
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import gql from 'graphql-tag'
|
||||||
import React, { useState } from 'react'
|
import React, { useState } from 'react'
|
||||||
|
|
||||||
import InfoMessage from 'src/components/InfoMessage'
|
import InfoMessage from 'src/components/InfoMessage'
|
||||||
import Tooltip from 'src/components/Tooltip'
|
import { Tooltip } from 'src/components/Tooltip'
|
||||||
import { Button, SupportLinkButton } from 'src/components/buttons'
|
import { Button, SupportLinkButton } from 'src/components/buttons'
|
||||||
import { RadioGroup } from 'src/components/inputs'
|
import { RadioGroup } from 'src/components/inputs'
|
||||||
import { H1, H4, P } from 'src/components/typography'
|
import { H1, H4, P } from 'src/components/typography'
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue