1
- import { Flex } from '@chakra-ui/react'
2
1
import Image from 'next/image'
3
2
4
3
import { StyledSkeleton } from '@/components/skeleton'
5
- import { colors } from '@/lib/styles/colors'
6
4
import { cn } from '@/lib/utils/tailwind'
7
5
8
6
import { QuoteDisplay } from './types'
@@ -15,73 +13,58 @@ type QuoteAvailableProps = {
15
13
onClick : ( ) => void
16
14
}
17
15
18
- function getBackgroundColor ( isSelected : boolean , isBestQuote : boolean ) {
19
- // return for best quote (whether selected or not)
20
- if ( isBestQuote ) return '#F0FEFF'
21
- if ( ! isBestQuote && isSelected ) return '#FFF5FA'
22
- return colors . ic . gray [ 50 ]
23
- }
24
-
25
- function useHighlightColor ( isSelected : boolean , isBestQuote : boolean ) {
26
- if ( isBestQuote && isSelected ) {
27
- return { border : colors . ic . blue [ 600 ] , text : 'text-ic-blue-600' }
28
- }
29
- if ( isBestQuote && ! isSelected ) {
30
- return { border : '#CFF5F6' , text : 'text-[#CFF5F6]' }
31
- }
32
- if ( ! isBestQuote && isSelected ) {
33
- return {
34
- border : '#F178B6' ,
35
- text : 'text-[#F178B6]' ,
36
- }
37
- }
38
- return {
39
- border : colors . ic . gray [ 400 ] ,
40
- text : 'text-ic-gray-400' ,
41
- }
42
- }
43
-
44
16
export const QuoteAvailable = ( props : QuoteAvailableProps ) => {
45
17
const { type, isLoading, isSelected, onClick, quote } = props
46
- const background = getBackgroundColor ( isSelected , quote ?. isBestQuote ?? false )
47
- const highlight = useHighlightColor ( isSelected , quote ?. isBestQuote ?? false )
48
- const borderWidth = isSelected ? 2 : 0
18
+ const isBestQuote = quote ?. isBestQuote
49
19
return (
50
- < Flex
51
- bg = { background }
52
- borderColor = { highlight . border }
53
- borderRadius = '12'
54
- borderWidth = { borderWidth }
55
- cursor = 'pointer'
56
- direction = { 'column' }
57
- p = '16px'
58
- w = '100%'
59
- h = '110px'
20
+ < div
21
+ className = { cn (
22
+ 'border-ic-gray-400 flex h-[110px] w-full cursor-pointer flex-col rounded-xl p-4' ,
23
+ isSelected ? 'border' : 'border-0' ,
24
+ {
25
+ 'bg-[#F0FEFF]' : isBestQuote ,
26
+ 'border-[#F178B6] bg-[#FFF5FA]' : ! isBestQuote && isSelected ,
27
+ 'bg-ic-gray-50' : ! isBestQuote && ! isSelected ,
28
+ 'border-ic-blue-600' : isBestQuote && isSelected ,
29
+ 'border-[#CFF5F6]' : isBestQuote && ! isSelected ,
30
+ } ,
31
+ ) }
60
32
onClick = { onClick }
61
33
>
62
- < Flex align = 'space-between' direction = 'column' justify = { 'flex -start'} >
63
- < Flex justify = { 'space -between'} >
34
+ < div className = 'flex flex-col justify-start'>
35
+ < div className = 'flex justify -between'>
64
36
< p className = 'text-ic-gray-500 text-xs font-medium' >
65
37
{ isLoading && < StyledSkeleton width = { 50 } /> }
66
38
{ ! isLoading && quote && quote . inputAmount }
67
39
</ p >
68
- < Flex direction = { 'row' } gap = { 1 } >
40
+ < div className = 'flex gap-1' >
69
41
{ quote ?. isBestQuote && (
70
- < Flex opacity = { isSelected ? 1 : 0.2 } >
42
+ < div
43
+ className = { cn (
44
+ 'flex' ,
45
+ isSelected ? 'opacity-100' : 'opacity-20' ,
46
+ ) }
47
+ >
71
48
< Image
72
49
src = { '/assets/icon-trophy.svg' }
73
50
alt = { 'token icon' }
74
51
width = { 12 }
75
52
height = { 12 }
76
53
/>
77
- </ Flex >
54
+ </ div >
78
55
) }
79
- < p className = { cn ( 'text-sm font-semibold' , highlight . text ) } >
56
+ < p
57
+ className = { cn ( 'text-ic-gray-400 text-sm font-semibold' , {
58
+ 'text-[#F178B6]' : ! isBestQuote && isSelected ,
59
+ 'text-ic-blue-600' : isBestQuote && isSelected ,
60
+ 'text-[#CFF5F6]' : isBestQuote && ! isSelected ,
61
+ } ) }
62
+ >
80
63
{ type . toUpperCase ( ) }
81
64
</ p >
82
- </ Flex >
83
- </ Flex >
84
- </ Flex >
65
+ </ div >
66
+ </ div >
67
+ </ div >
85
68
< p
86
69
className = { cn (
87
70
'text-2xl font-medium' ,
@@ -91,16 +74,13 @@ export const QuoteAvailable = (props: QuoteAvailableProps) => {
91
74
{ isLoading && < StyledSkeleton width = { 200 } /> }
92
75
{ ! isLoading && quote && quote . outputAmount }
93
76
</ p >
94
- < Flex
95
- direction = { [ 'column' , 'row' ] }
96
- justify = { [ 'flex-start' , 'space-between' ] }
97
- >
77
+ < div className = 'xs:flex-row xs:justify-between flex flex-col justify-start' >
98
78
< p className = 'text-ic-gray-500 text-xs font-medium' >
99
79
{ isLoading && < StyledSkeleton width = { 80 } /> }
100
80
{ ! isLoading && quote && quote . feesTotal }
101
81
</ p >
102
82
{ quote && (
103
- < Flex direction = ' row' gap = '6px '>
83
+ < div className = 'flex flex- row gap-1.5 '>
104
84
< Image
105
85
className = 'text-ic-gray-500'
106
86
alt = 'Gas fees icon'
@@ -111,9 +91,9 @@ export const QuoteAvailable = (props: QuoteAvailableProps) => {
111
91
< p className = 'text-ic-gray-500 text-xs font-medium' >
112
92
{ quote . feesGas }
113
93
</ p >
114
- </ Flex >
94
+ </ div >
115
95
) }
116
- </ Flex >
117
- </ Flex >
96
+ </ div >
97
+ </ div >
118
98
)
119
99
}
0 commit comments