Skip to content

Commit a68af7b

Browse files
committed
Refactor
Signed-off-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz>
1 parent a55aa88 commit a68af7b

File tree

1 file changed

+50
-64
lines changed
  • wormhole-connect/src/views/v2/Bridge/GasSlider

1 file changed

+50
-64
lines changed

wormhole-connect/src/views/v2/Bridge/GasSlider/index.tsx

+50-64
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import { makeStyles } from 'tss-react/mui';
44
import { useDebounce } from 'use-debounce';
55

66
import { useTheme } from '@mui/material';
7-
import Card from '@mui/material/Card';
8-
import CardContent from '@mui/material/CardContent';
97
import Collapse from '@mui/material/Collapse';
108
import Slider from '@mui/material/Slider';
119
import Stack from '@mui/material/Stack';
@@ -21,18 +19,12 @@ import { setToNativeToken } from 'store/relay';
2119
import { useTokens } from 'contexts/TokensContext';
2220

2321
const useStyles = makeStyles()(() => ({
24-
card: {
22+
content: {
2523
width: '100%',
2624
cursor: 'pointer',
2725
maxWidth: '420px',
2826
overflow: 'visible',
29-
padding: '0 4px',
30-
},
31-
cardContent: {
32-
paddingTop: '8px',
33-
':last-child': {
34-
padding: '16px 20px',
35-
},
27+
padding: '16px 20px',
3628
},
3729
container: {
3830
display: 'flex',
@@ -153,62 +145,56 @@ const GasSlider = (props: {
153145
}
154146

155147
return (
156-
<Card className={classes.card} variant="elevation">
157-
<CardContent className={classes.cardContent}>
158-
<Stack
159-
direction="row"
160-
alignItems="center"
161-
justifyContent="space-between"
162-
>
163-
<Typography>{`Need more gas on ${destChain}?`}</Typography>
164-
<StyledSwitch
165-
checked={isGasSliderOpen}
166-
disabled={props.disabled}
167-
onClick={(e: any) => {
168-
const { checked } = e.target;
169-
170-
setIsGasSliderOpen(checked);
171-
172-
if (!checked) {
173-
setPercentage(0);
174-
dispatch(setToNativeToken(0));
175-
}
176-
}}
177-
/>
178-
</Stack>
179-
<Collapse in={isGasSliderOpen} unmountOnExit>
180-
<div className={classes.container}>
181-
<Typography color={theme.palette.text.secondary} fontSize={14}>
182-
{`Use the slider to buy extra ${nativeGasToken.symbol} for future transactions.`}
183-
</Typography>
184-
<div>
185-
<StyledSlider
186-
aria-label="Native gas conversion amount"
187-
defaultValue={0}
188-
disabled={props.disabled}
189-
value={percentage}
190-
baseColor={theme.palette.primary.main}
191-
railColor={theme.palette.secondary.main}
192-
step={1}
193-
min={0}
194-
max={100}
195-
valueLabelFormat={() => `${percentage}%`}
196-
valueLabelDisplay="auto"
197-
onChange={(e: any) => setPercentage(e.target.value)}
198-
/>
199-
<div className={classes.amounts}>
200-
<Typography color={theme.palette.text.secondary} fontSize={14}>
201-
Additional gas
202-
</Typography>
203-
<Typography color={theme.palette.text.secondary} fontSize={14}>
204-
{nativeGasPrice}
205-
</Typography>
206-
</div>
148+
<div className={classes.content}>
149+
<Stack direction="row" alignItems="center" justifyContent="space-between">
150+
<Typography>{`Need more gas on ${destChain}?`}</Typography>
151+
<StyledSwitch
152+
checked={isGasSliderOpen}
153+
disabled={props.disabled}
154+
onClick={(e: any) => {
155+
const { checked } = e.target;
156+
157+
setIsGasSliderOpen(checked);
158+
159+
if (!checked) {
160+
setPercentage(0);
161+
dispatch(setToNativeToken(0));
162+
}
163+
}}
164+
/>
165+
</Stack>
166+
<Collapse in={isGasSliderOpen} unmountOnExit>
167+
<div className={classes.container}>
168+
<Typography color={theme.palette.text.secondary} fontSize={14}>
169+
{`Use the slider to buy extra ${nativeGasToken.symbol} for future transactions.`}
170+
</Typography>
171+
<div>
172+
<StyledSlider
173+
aria-label="Native gas conversion amount"
174+
defaultValue={0}
175+
disabled={props.disabled}
176+
value={percentage}
177+
baseColor={theme.palette.primary.main}
178+
railColor={theme.palette.secondary.main}
179+
step={1}
180+
min={0}
181+
max={100}
182+
valueLabelFormat={() => `${percentage}%`}
183+
valueLabelDisplay="auto"
184+
onChange={(e: any) => setPercentage(e.target.value)}
185+
/>
186+
<div className={classes.amounts}>
187+
<Typography color={theme.palette.text.secondary} fontSize={14}>
188+
Additional gas
189+
</Typography>
190+
<Typography color={theme.palette.text.secondary} fontSize={14}>
191+
{nativeGasPrice}
192+
</Typography>
207193
</div>
208194
</div>
209-
</Collapse>
210-
</CardContent>
211-
</Card>
195+
</div>
196+
</Collapse>
197+
</div>
212198
);
213199
};
214200

0 commit comments

Comments
 (0)