-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
268 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
packages/widget/src/components/SettingsDrawer/AdvancedPreferences.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { HelpOutline as HelpOutlineIcon } from '@mui/icons-material'; | ||
import { Box, FormControl, MenuItem, Typography } from '@mui/material'; | ||
import { ChangeEvent, useState } from 'react'; | ||
import { useFormContext } from 'react-hook-form'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { SwapFormKey } from '../../providers/SwapFormProvider'; | ||
import { Select } from '../Select'; | ||
import { Switch } from '../Switch'; | ||
import { EnabledBridgesSelect } from './EnabledBridgesSelect'; | ||
import { EnabledExchangesSelect } from './EnabledExchangesSelect'; | ||
|
||
export const AdvancedPreferences = () => { | ||
const { t } = useTranslation(); | ||
const { register } = useFormContext(); | ||
const [advancedPreferences, setAdvancedPreferences] = | ||
useState<boolean>(false); | ||
|
||
const handleAdvancedPreferences = ( | ||
_: ChangeEvent<HTMLInputElement>, | ||
checked: boolean, | ||
) => { | ||
setAdvancedPreferences(checked); | ||
}; | ||
|
||
return ( | ||
<Box px={3}> | ||
<Box | ||
mt={3} | ||
sx={{ | ||
display: 'flex', | ||
justifyContent: 'space-between', | ||
alignItems: 'center', | ||
}} | ||
> | ||
<Box sx={{ display: 'flex', alignItems: 'center' }}> | ||
<Typography | ||
variant="subtitle1" | ||
color="text.primary" | ||
lineHeight="normal" | ||
> | ||
{t(`settings.advancedPreferences`)} | ||
</Typography> | ||
</Box> | ||
<Switch | ||
value={advancedPreferences} | ||
onChange={handleAdvancedPreferences} | ||
/> | ||
</Box> | ||
{advancedPreferences && ( | ||
<Box mt={3} mb={1}> | ||
<Box sx={{ display: 'flex', alignItems: 'center' }} mb={1}> | ||
<HelpOutlineIcon sx={{ color: 'grey.500' }} /> | ||
<Typography | ||
variant="subtitle1" | ||
color="text.secondary" | ||
lineHeight="normal" | ||
ml={1} | ||
> | ||
{t(`settings.bridgePrioritization`)} | ||
</Typography> | ||
</Box> | ||
<FormControl fullWidth> | ||
<Select | ||
defaultValue={1} | ||
MenuProps={{ elevation: 2 }} | ||
inputProps={{ | ||
...register(SwapFormKey.BridgePrioritization), | ||
}} | ||
> | ||
<MenuItem value={1}> | ||
{t(`swap.routePriority.recommended`)} | ||
</MenuItem> | ||
</Select> | ||
</FormControl> | ||
<EnabledBridgesSelect /> | ||
<EnabledExchangesSelect /> | ||
</Box> | ||
)} | ||
</Box> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
packages/widget/src/components/SettingsDrawer/GasPriceButtonGroup.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { HelpOutline as HelpOutlineIcon } from '@mui/icons-material'; | ||
import { Box, Typography } from '@mui/material'; | ||
import { useEffect } from 'react'; | ||
import { useFormContext, useWatch } from 'react-hook-form'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { SwapFormKey } from '../../providers/SwapFormProvider'; | ||
import { Button, ButtonGroup } from './GasPriceButtonGroup.style'; | ||
|
||
export const GasPriceButtonGroup = () => { | ||
const { t } = useTranslation(); | ||
const { register, setValue } = useFormContext(); | ||
|
||
const value = useWatch({ | ||
name: SwapFormKey.GasPrice, | ||
}); | ||
|
||
const handleChange = (newValue: 'slow' | 'normal' | 'fast') => { | ||
setValue(SwapFormKey.GasPrice, newValue); | ||
}; | ||
|
||
useEffect(() => { | ||
register(SwapFormKey.GasPrice); | ||
}, [register]); | ||
|
||
return ( | ||
<Box> | ||
<Box sx={{ display: 'flex', alignItems: 'center' }} mb={1}> | ||
<HelpOutlineIcon sx={{ color: 'grey.500' }} /> | ||
<Typography | ||
variant="subtitle1" | ||
color="text.secondary" | ||
lineHeight="normal" | ||
ml={1} | ||
> | ||
{t(`settings.gasPrice.title`)} | ||
</Typography> | ||
</Box> | ||
<ButtonGroup size="large"> | ||
<Button | ||
key="slow" | ||
disableElevation | ||
variant={value === 'slow' ? 'contained' : 'outlined'} | ||
onClick={() => handleChange('slow')} | ||
> | ||
{t(`settings.gasPrice.slow`)} | ||
</Button> | ||
<Button | ||
key="normal" | ||
disableElevation | ||
variant={value === 'normal' ? 'contained' : 'outlined'} | ||
onClick={() => handleChange('normal')} | ||
> | ||
{t(`settings.gasPrice.normal`)} | ||
</Button> | ||
<Button | ||
key="fast" | ||
disableElevation | ||
variant={value === 'fast' ? 'contained' : 'outlined'} | ||
onClick={() => handleChange('fast')} | ||
> | ||
{t(`settings.gasPrice.fast`)} | ||
</Button> | ||
</ButtonGroup> | ||
</Box> | ||
); | ||
}; |
Oops, something went wrong.