@@ -7,10 +7,11 @@ import { useTheme } from '@mui/material';
7
7
import Card from '@mui/material/Card' ;
8
8
import CardContent from '@mui/material/CardContent' ;
9
9
import Collapse from '@mui/material/Collapse' ;
10
- import Slider from '@mui/material/Slider' ;
11
10
import Stack from '@mui/material/Stack' ;
12
11
import Switch from '@mui/material/Switch' ;
13
12
import { styled } from '@mui/material/styles' ;
13
+ import ToggleButton from '@mui/material/ToggleButton' ;
14
+ import ToggleButtonGroup from '@mui/material/ToggleButtonGroup' ;
14
15
import Typography from '@mui/material/Typography' ;
15
16
import { amount } from '@wormhole-foundation/sdk' ;
16
17
@@ -40,34 +41,8 @@ const useStyles = makeStyles()(() => ({
40
41
alignItems : 'center' ,
41
42
width : '100%' ,
42
43
} ,
43
- } ) ) ;
44
-
45
- type SliderProps = {
46
- baseColor : string ;
47
- railColor : string ;
48
- } ;
49
-
50
- const StyledSlider = styled ( Slider , {
51
- shouldForwardProp : ( prop ) =>
52
- ! [ 'baseColor' , 'railColor' ] . includes ( prop . toString ( ) ) ,
53
- } ) < SliderProps > ( ( { baseColor, railColor, theme } ) => ( {
54
- alignSelf : 'start' ,
55
- color : baseColor ,
56
- height : 8 ,
57
- left : '10px' ,
58
- width : 'calc(100% - 20px)' ,
59
- '& .MuiSlider-rail' : {
60
- height : '8px' ,
61
- backgroundColor : railColor ,
62
- opacity : 0.1 ,
63
- } ,
64
- '& .MuiSlider-track' : {
65
- height : '8px' ,
66
- } ,
67
- '& .MuiSlider-thumb' : {
68
- height : 20 ,
69
- width : 20 ,
70
- backgroundColor : theme . palette . primary . main ,
44
+ gasButton : {
45
+ borderRadius : '8px' ,
71
46
} ,
72
47
} ) ) ;
73
48
@@ -105,6 +80,7 @@ const GasSlider = (props: {
105
80
106
81
const [ isGasSliderOpen , setIsGasSliderOpen ] = useState ( false ) ;
107
82
const [ percentage , setPercentage ] = useState ( 0 ) ;
83
+ const [ gasSelection , setGasSelection ] = useState ( ) ;
108
84
109
85
const [ debouncedPercentage ] = useDebounce ( percentage , 500 ) ;
110
86
@@ -154,7 +130,7 @@ const GasSlider = (props: {
154
130
alignItems = "center"
155
131
justifyContent = "space-between"
156
132
>
157
- < Typography > { `Need more gas on ${ destChain } ?` } </ Typography >
133
+ < Typography > { `Need extra ${ nativeGasToken . symbol } on ${ destChain } ?` } </ Typography >
158
134
< StyledSwitch
159
135
checked = { isGasSliderOpen }
160
136
disabled = { props . disabled }
@@ -165,41 +141,63 @@ const GasSlider = (props: {
165
141
166
142
if ( ! checked ) {
167
143
setPercentage ( 0 ) ;
144
+ setGasSelection ( undefined ) ;
168
145
dispatch ( setToNativeToken ( 0 ) ) ;
169
146
}
170
147
} }
171
148
/>
172
149
</ Stack >
173
150
< Collapse in = { isGasSliderOpen } unmountOnExit >
174
- < div className = { classes . container } >
175
- < Typography color = { theme . palette . text . secondary } fontSize = { 14 } >
176
- { `Use the slider to buy extra ${ nativeGasToken . symbol } for future transactions.` }
177
- </ Typography >
178
- < div >
179
- < StyledSlider
180
- aria-label = "Native gas conversion amount"
181
- defaultValue = { 0 }
182
- disabled = { props . disabled }
183
- value = { percentage }
184
- baseColor = { theme . palette . primary . main }
185
- railColor = { theme . palette . background . default }
186
- step = { 1 }
187
- min = { 0 }
188
- max = { 100 }
189
- valueLabelFormat = { ( ) => `${ percentage } %` }
190
- valueLabelDisplay = "auto"
191
- onChange = { ( e : any ) => setPercentage ( e . target . value ) }
192
- />
193
- < div className = { classes . amounts } >
194
- < Typography color = { theme . palette . text . secondary } fontSize = { 14 } >
195
- Additional gas
196
- </ Typography >
197
- < Typography color = { theme . palette . text . secondary } fontSize = { 14 } >
198
- { nativeGasPrice }
199
- </ Typography >
200
- </ div >
151
+ < Stack className = { classes . container } >
152
+ < ToggleButtonGroup
153
+ color = "primary"
154
+ value = { gasSelection }
155
+ exclusive
156
+ fullWidth
157
+ onChange = { ( _ , selection ) => {
158
+ setGasSelection ( selection ) ;
159
+ setPercentage (
160
+ selection === 'small'
161
+ ? 25
162
+ : selection === 'medium'
163
+ ? 50
164
+ : selection === 'large'
165
+ ? 100
166
+ : 0 ,
167
+ ) ;
168
+ } }
169
+ >
170
+ < ToggleButton
171
+ disableRipple
172
+ className = { classes . gasButton }
173
+ value = "small"
174
+ >
175
+ Small
176
+ </ ToggleButton >
177
+ < ToggleButton
178
+ disableRipple
179
+ className = { classes . gasButton }
180
+ value = "medium"
181
+ >
182
+ Medium
183
+ </ ToggleButton >
184
+ < ToggleButton
185
+ disableRipple
186
+ className = { classes . gasButton }
187
+ value = "large"
188
+ >
189
+ Large
190
+ </ ToggleButton >
191
+ </ ToggleButtonGroup >
192
+ < div className = { classes . amounts } >
193
+ < Typography color = { theme . palette . text . secondary } fontSize = { 14 } >
194
+ Additional gas
195
+ </ Typography >
196
+ < Typography color = { theme . palette . text . secondary } fontSize = { 14 } >
197
+ { nativeGasPrice }
198
+ </ Typography >
201
199
</ div >
202
- </ div >
200
+ </ Stack >
203
201
</ Collapse >
204
202
</ CardContent >
205
203
</ Card >
0 commit comments