@@ -25,6 +25,7 @@ import {
25
25
millisToHumanString ,
26
26
formatDuration ,
27
27
} from 'utils' ;
28
+ import { joinClass } from 'utils/style' ;
28
29
29
30
import type { RouteData } from 'config/routes' ;
30
31
import type { RootState } from 'store' ;
@@ -35,56 +36,65 @@ import GasSlider from 'views/v2/Bridge/GasSlider';
35
36
36
37
const HIGH_FEE_THRESHOLD = 20 ; // dollhairs
37
38
38
- const useStyles = makeStyles ( ) ( ( theme : any ) => ( {
39
- container : {
40
- width : '100%' ,
41
- maxWidth : '420px' ,
42
- marginBottom : '8px' ,
43
- } ,
44
- card : {
45
- borderRadius : '8px' ,
46
- width : '100%' ,
47
- maxWidth : '420px' ,
48
- } ,
49
- cardHeader : {
50
- padding : '20px 20px 0px' ,
51
- } ,
52
- cardContent : {
53
- marginTop : '18px' ,
54
- padding : '0px 20px 20px' ,
55
- } ,
56
- errorIcon : {
57
- color : theme . palette . error . main ,
58
- height : '34px' ,
59
- width : '34px' ,
60
- marginRight : '24px' ,
61
- } ,
62
- fastestBadge : {
63
- width : '14px' ,
64
- height : '14px' ,
65
- position : 'relative' ,
66
- top : '2px' ,
67
- marginRight : '4px' ,
68
- fill : theme . palette . primary . main ,
69
- } ,
70
- cheapestBadge : {
71
- width : '12px' ,
72
- height : '12px' ,
73
- position : 'relative' ,
74
- top : '1px' ,
75
- marginRight : '3px' ,
76
- fill : theme . palette . primary . main ,
77
- } ,
78
- messageContainer : {
79
- padding : '12px 0px 0px' ,
80
- } ,
81
- warningIcon : {
82
- color : theme . palette . warning . main ,
83
- height : '34px' ,
84
- width : '34px' ,
85
- marginRight : '12px' ,
86
- } ,
87
- } ) ) ;
39
+ const useStyles = makeStyles < { isSelected : boolean } > ( ) (
40
+ ( theme : any , { isSelected } ) => ( {
41
+ container : {
42
+ width : '100%' ,
43
+ maxWidth : '420px' ,
44
+ marginBottom : '8px' ,
45
+ } ,
46
+ card : {
47
+ border : '1px solid' ,
48
+ borderColor : isSelected ? theme . palette . primary . main : 'transparent' ,
49
+ borderRadius : '8px' ,
50
+ width : '100%' ,
51
+ maxWidth : '420px' ,
52
+ } ,
53
+ cardHeader : {
54
+ padding : '20px 20px 0px' ,
55
+ } ,
56
+ cardContent : {
57
+ marginTop : '18px' ,
58
+ padding : '0px 20px 20px' ,
59
+ } ,
60
+ disabled : {
61
+ opacity : '0.6' ,
62
+ cursor : 'default' ,
63
+ clickEvent : 'none' ,
64
+ } ,
65
+ errorIcon : {
66
+ color : theme . palette . error . main ,
67
+ height : '34px' ,
68
+ width : '34px' ,
69
+ marginRight : '24px' ,
70
+ } ,
71
+ fastestBadge : {
72
+ width : '14px' ,
73
+ height : '14px' ,
74
+ position : 'relative' ,
75
+ top : '2px' ,
76
+ marginRight : '4px' ,
77
+ fill : theme . palette . primary . main ,
78
+ } ,
79
+ cheapestBadge : {
80
+ width : '12px' ,
81
+ height : '12px' ,
82
+ position : 'relative' ,
83
+ top : '1px' ,
84
+ marginRight : '3px' ,
85
+ fill : theme . palette . primary . main ,
86
+ } ,
87
+ messageContainer : {
88
+ padding : '12px 0px 0px' ,
89
+ } ,
90
+ warningIcon : {
91
+ color : theme . palette . warning . main ,
92
+ height : '34px' ,
93
+ width : '34px' ,
94
+ marginRight : '12px' ,
95
+ } ,
96
+ } ) ,
97
+ ) ;
88
98
89
99
type Props = {
90
100
route : RouteData ;
@@ -99,7 +109,6 @@ type Props = {
99
109
} ;
100
110
101
111
const SingleRoute = ( props : Props ) => {
102
- const { classes } = useStyles ( ) ;
103
112
const theme = useTheme ( ) ;
104
113
const routeConfig = config . routes . get ( props . route . name ) ;
105
114
@@ -115,10 +124,12 @@ const SingleRoute = (props: Props) => {
115
124
( state : RootState ) => state . tokenPrices ,
116
125
) ;
117
126
127
+ const { quote, isSelected } = props ;
118
128
const { name } = props . route ;
119
- const { quote } = props ;
120
129
const receiveNativeAmount = quote ?. destinationNativeGas ;
121
130
131
+ const { classes } = useStyles ( { isSelected } ) ;
132
+
122
133
const destTokenConfig = useMemo (
123
134
( ) => config . tokens [ destToken ] as TokenConfig | undefined ,
124
135
[ destToken ] ,
@@ -566,7 +577,7 @@ const SingleRoute = (props: Props) => {
566
577
// 1- If no action handler provided, fall back to default
567
578
// 2- Otherwise there is an action handler, "pointer"
568
579
const cursor = useMemo ( ( ) => {
569
- if ( props . isSelected || typeof props . onSelect !== 'function' ) {
580
+ if ( isSelected || typeof props . onSelect !== 'function' ) {
570
581
return 'default' ;
571
582
}
572
583
@@ -575,7 +586,7 @@ const SingleRoute = (props: Props) => {
575
586
}
576
587
577
588
return 'pointer' ;
578
- } , [ props . error , props . isSelected , props . onSelect ] ) ;
589
+ } , [ props . error , isSelected , props . onSelect ] ) ;
579
590
580
591
const routeCardBadge = useMemo ( ( ) => {
581
592
if ( props . isFastest ) {
@@ -609,18 +620,16 @@ const SingleRoute = (props: Props) => {
609
620
return (
610
621
< div key = { name } className = { classes . container } >
611
622
< Card
612
- className = { classes . card }
613
- sx = { {
614
- border : '1px solid' ,
615
- borderColor : props . isSelected
616
- ? theme . palette . primary . main
617
- : 'transparent' ,
618
- opacity : 1 ,
619
- } }
623
+ className = { joinClass ( [
624
+ classes . card ,
625
+ isTransactionInProgress && classes . disabled ,
626
+ ] ) }
620
627
>
621
628
< CardActionArea
622
629
disabled = {
623
- typeof props . onSelect !== 'function' || props . error !== undefined
630
+ isTransactionInProgress ||
631
+ typeof props . onSelect !== 'function' ||
632
+ props . error !== undefined
624
633
}
625
634
disableTouchRipple
626
635
sx = { { cursor } }
0 commit comments