forked from safe-global/safe-wallet-web
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: mobile CSS and wallet connection
- Loading branch information
Showing
8 changed files
with
95 additions
and
92 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,31 @@ | ||
import { ReactElement } from 'react' | ||
import { Button } from '@mui/material' | ||
import { ReactElement, useCallback } from 'react' | ||
import { Box, Button } from '@mui/material' | ||
import { hexValue } from 'ethers/lib/utils' | ||
import { useCurrentChain } from '@/hooks/useChains' | ||
import useOnboard from '@/hooks/wallets/useOnboard' | ||
import useIsWrongChain from '@/hooks/useIsWrongChain' | ||
|
||
const Circle = ({ color }: { color: string }): ReactElement => { | ||
return ( | ||
<span | ||
style={{ | ||
width: '0.8em', | ||
height: '0.8em', | ||
borderRadius: '50%', | ||
backgroundColor: color, | ||
marginLeft: 1, | ||
}} | ||
/> | ||
) | ||
} | ||
import css from './styles.module.css' | ||
|
||
const ChainSwitcher = (): ReactElement | null => { | ||
const chain = useCurrentChain() | ||
const onboard = useOnboard() | ||
const isWrongChain = useIsWrongChain() | ||
|
||
const handleChainSwitch = () => { | ||
const handleChainSwitch = useCallback(() => { | ||
if (!chain) return | ||
const chainId = hexValue(parseInt(chain.chainId)) | ||
onboard?.setChain({ chainId }) | ||
} | ||
}, [onboard, chain]) | ||
|
||
return isWrongChain ? ( | ||
if (!isWrongChain) return null | ||
|
||
return ( | ||
<Button onClick={handleChainSwitch} variant="outlined" size="small"> | ||
Switch to | ||
<Circle color={chain?.theme?.backgroundColor || ''} /> | ||
<Box className={css.circle} bgcolor={chain?.theme?.backgroundColor || ''} /> | ||
{chain?.chainName} | ||
</Button> | ||
) : null | ||
) | ||
} | ||
|
||
export default ChainSwitcher |
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,6 @@ | ||
.circle { | ||
width: 0.8em; | ||
height: 0.8em; | ||
border-radius: 50%; | ||
margin-left: 0.2em; | ||
} |
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 |
---|---|---|
|
@@ -29,4 +29,8 @@ | |
.menuButton { | ||
display: block; | ||
} | ||
|
||
.container button { | ||
font-size: 8px; | ||
} | ||
} |
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
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