fix: improve HoverableTooltip behavior and UX

feat: add market currency selector for exchange 3rd party services
This commit is contained in:
Sérgio Salgado 2022-07-13 15:55:45 +01:00 committed by Rafael
parent d0573daa74
commit 4427258dd5
26 changed files with 646 additions and 320 deletions

View file

@ -1,8 +1,13 @@
import { Box } from '@material-ui/core'
import MAutocomplete from '@material-ui/lab/Autocomplete'
import sort from 'match-sorter'
import * as R from 'ramda'
import React from 'react'
import { HoverableTooltip } from 'src/components/Tooltip'
import { P } from 'src/components/typography'
import { errorColor, orangeYellow, spring4 } from 'src/styling/variables'
import TextInput from './TextInput'
const Autocomplete = ({
@ -95,6 +100,39 @@ const Autocomplete = ({
/>
)
}}
renderOption={props => {
if (!props.warning && !props.warningMessage)
return R.path([labelProp])(props)
const warningColors = {
clean: spring4,
partial: orangeYellow,
important: errorColor
}
const hoverableElement = (
<Box
width={18}
height={18}
borderRadius={6}
bgcolor={warningColors[props.warning]}
/>
)
return (
<Box
width="100%"
display="flex"
flexDirection="row"
justifyContent="space-between"
alignItems="center">
<Box>{R.path([labelProp])(props)}</Box>
<HoverableTooltip parentElements={hoverableElement} width={250}>
<P>{props.warningMessage}</P>
</HoverableTooltip>
</Box>
)
}}
/>
)
}