-
Notifications
You must be signed in to change notification settings - Fork 464
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
20 changed files
with
492 additions
and
128 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import useLocalStorage from '@/services/local-storage/useLocalStorage' | ||
import { Grid, Typography, Divider, FormControlLabel, Checkbox, SvgIcon, IconButton, Tooltip } from '@mui/material' | ||
import type { SessionTypes } from '@walletconnect/types' | ||
import type { ReactElement } from 'react' | ||
|
||
import { Hints } from '../Hints' | ||
import SessionList from '../SessionList' | ||
import WcInput from '../WcInput' | ||
import InfoIcon from '@/public/images/notifications/info.svg' | ||
import { WalletConnectHeader } from '../SessionManager/Header' | ||
|
||
import css from './styles.module.css' | ||
|
||
const WC_HINTS_KEY = 'wcHints' | ||
|
||
export const ConnectionForm = ({ | ||
sessions, | ||
onDisconnect, | ||
}: { | ||
sessions: SessionTypes.Struct[] | ||
onDisconnect: (session: SessionTypes.Struct) => Promise<void> | ||
}): ReactElement => { | ||
const [hideHints = false, setHideHints] = useLocalStorage<boolean>(WC_HINTS_KEY) | ||
|
||
return ( | ||
<Grid className={css.container}> | ||
<Grid item textAlign="center"> | ||
{hideHints && ( | ||
<Tooltip title="How does WalletConnect work?" placement="top"> | ||
<span> | ||
<IconButton onClick={() => setHideHints(false)} className={css.infoIcon}> | ||
<SvgIcon component={InfoIcon} inheritViewBox color="border" /> | ||
</IconButton> | ||
</span> | ||
</Tooltip> | ||
)} | ||
|
||
<WalletConnectHeader /> | ||
|
||
<Typography variant="body2" color="text.secondary" mb={3}> | ||
Connnect your Safe to any dApp via WalletConnect and trigger transactions | ||
</Typography> | ||
|
||
<WcInput /> | ||
</Grid> | ||
|
||
<Divider flexItem className={css.divider} /> | ||
|
||
<Grid item> | ||
<SessionList sessions={sessions} onDisconnect={onDisconnect} /> | ||
</Grid> | ||
|
||
{!hideHints && ( | ||
<> | ||
<Divider flexItem className={css.divider} /> | ||
|
||
<Grid item> | ||
<Hints /> | ||
|
||
<FormControlLabel | ||
control={<Checkbox checked={hideHints} onChange={(_, checked) => setHideHints(checked)} />} | ||
label="Don't show this anymore" | ||
sx={{ mt: 1 }} | ||
/> | ||
</Grid> | ||
</> | ||
)} | ||
</Grid> | ||
) | ||
} |
21 changes: 21 additions & 0 deletions
21
src/components/walletconnect/ConnectionForm/styles.module.css
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,21 @@ | ||
.container :global .MuiGrid-item { | ||
padding: var(--space-3) 0; | ||
} | ||
|
||
.container :global .MuiGrid-item:first-of-type { | ||
padding: 0 0 var(--space-3) 0; | ||
} | ||
|
||
.container :global .MuiGrid-item:last-of-type { | ||
padding: var(--space-3) 0 0 0; | ||
} | ||
|
||
.infoIcon { | ||
position: absolute; | ||
top: var(--space-3); | ||
right: var(--space-3); | ||
} | ||
|
||
.divider { | ||
margin: 0 calc(-1 * var(--space-4)); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import ExpandMoreIcon from '@mui/icons-material/ExpandMore' | ||
import { Accordion, AccordionSummary, Typography, AccordionDetails, SvgIcon } from '@mui/material' | ||
import type { TypographyProps } from '@mui/material' | ||
import type { ReactElement } from 'react' | ||
|
||
import Question from '@/public/images/common/question.svg' | ||
|
||
const AccordionTitle = ({ children }: { children: TypographyProps['children'] }): ReactElement => { | ||
return ( | ||
<Typography sx={{ display: 'flex', alignItems: 'center', justifyContent: 'center' }}> | ||
<SvgIcon | ||
component={Question} | ||
inheritViewBox | ||
sx={{ color: 'currentColor', verticalAlign: 'middle', mr: 1 }} | ||
fontSize="inherit" | ||
/> | ||
{children} | ||
</Typography> | ||
) | ||
} | ||
|
||
// TODO: Add content to the hints | ||
export const Hints = (): ReactElement => { | ||
return ( | ||
<> | ||
<Accordion sx={{ mb: 1 }}> | ||
<AccordionSummary expandIcon={<ExpandMoreIcon />}> | ||
<AccordionTitle>How do I connect to a dApp?</AccordionTitle> | ||
</AccordionSummary> | ||
|
||
<AccordionDetails> | ||
<Typography> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse malesuada lacus ex, sit amet blandit | ||
leo lobortis eget. | ||
</Typography> | ||
</AccordionDetails> | ||
</Accordion> | ||
|
||
<Accordion> | ||
<AccordionSummary expandIcon={<ExpandMoreIcon />}> | ||
<AccordionTitle>How do I interact with a dApp?</AccordionTitle> | ||
</AccordionSummary> | ||
|
||
<AccordionDetails> | ||
<Typography> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse malesuada lacus ex, sit amet blandit | ||
leo lobortis eget. | ||
</Typography> | ||
</AccordionDetails> | ||
</Accordion> | ||
</> | ||
) | ||
} |
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
27 changes: 27 additions & 0 deletions
27
src/components/walletconnect/ProposalForm/UnsupportedChain.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,27 @@ | ||
import { Alert, AlertTitle, Typography } from '@mui/material' | ||
import type { ReactElement } from 'react' | ||
|
||
import ChainIndicator from '@/components/common/ChainIndicator' | ||
|
||
import css from './styles.module.css' | ||
|
||
export const UnsupportedChain = ({ chainIds }: { chainIds: Array<string> }): ReactElement => { | ||
return ( | ||
<> | ||
<Alert severity="info" className={css.alert}> | ||
<AlertTitle>dApp does not support Safe network</AlertTitle> | ||
If you want to interact with this dApp, please switch to a Safe on a supported network. | ||
</Alert> | ||
|
||
<Typography mt={3} mb={1}> | ||
Supported chains | ||
</Typography> | ||
|
||
<div> | ||
{chainIds.map((chainId) => ( | ||
<ChainIndicator inline chainId={chainId} key={chainId} className={css.chain} /> | ||
))} | ||
</div> | ||
</> | ||
) | ||
} |
Oops, something went wrong.