Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: populate help section #2619

Merged
merged 3 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions src/components/walletconnect/ConnectionForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,19 @@ export const ConnectionForm = ({
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>
)}
<Tooltip
title="How does WalletConnect work?"
hidden={!hideHints}
placement="top"
arrow
className={css.infoIcon}
>
<span>
<IconButton onClick={() => setHideHints(false)}>
<SvgIcon component={InfoIcon} inheritViewBox color="border" />
</IconButton>
</span>
</Tooltip>

<WalletConnectHeader />

Expand Down
102 changes: 62 additions & 40 deletions src/components/walletconnect/Hints/index.tsx
Original file line number Diff line number Diff line change
@@ -1,53 +1,75 @@
import ExpandMoreIcon from '@mui/icons-material/ExpandMore'
import { Accordion, AccordionSummary, Typography, AccordionDetails, SvgIcon } from '@mui/material'
import type { TypographyProps } from '@mui/material'
import {
Accordion,
AccordionSummary,
Avatar,
Box,
Typography,
AccordionDetails,
SvgIcon,
List,
ListItem,
ListItemAvatar,
ListItemText,
} from '@mui/material'
import { useMemo } from 'react'
import type { ReactElement } from 'react'

import { useCurrentChain } from '@/hooks/useChains'
import Question from '@/public/images/common/question.svg'

const AccordionTitle = ({ children }: { children: TypographyProps['children'] }): ReactElement => {
import css from './styles.module.css'

const HintAccordion = ({ title, items }: { title: string; items: Array<string> }): 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>
<Accordion>
<AccordionSummary expandIcon={<ExpandMoreIcon />}>
<Typography className={css.title}>
<SvgIcon component={Question} inheritViewBox className={css.questionIcon} />
{title}
</Typography>
</AccordionSummary>

<AccordionDetails sx={{ p: 0 }}>
<List className={css.list}>
{items.map((item, i) => (
<ListItem key={i} sx={{ p: 0 }}>
<ListItemAvatar className={css.listItemAvatar}>
<Avatar className={css.avatar}>{i + 1}</Avatar>
</ListItemAvatar>
<ListItemText primary={item} sx={{ m: 0 }} primaryTypographyProps={{ variant: 'body2' }} />
</ListItem>
))}
</List>
</AccordionDetails>
</Accordion>
)
}

// TODO: Add content to the hints
const ConnectionSteps = [
'Open a WalletConnect supported dApp',
'Select WalletConnect as the connection method',
'Copy the pairing URI and paste it into the input field above',
'Approve the session',
'dApp is now connected to the Safe',
]

export const Hints = (): ReactElement => {
const chain = useCurrentChain()

const InteractionSteps = useMemo(() => {
return [
'Connect a dApp by following the above steps',
`Ensure the dApp is connected to ${chain?.chainName ?? 'this chain'}`,
'Initiate a transaction/signature request via the dApp',
'Transact/sign as normal via the Safe',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please exctract the hardcode to a const, you can use a replacement pattern for the chain name.

]
}, [chain?.chainName])

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>
</>
<Box display="flex" flexDirection="column" gap={1}>
<HintAccordion title="How do I connect to a dApp?" items={ConnectionSteps} />
<HintAccordion title="How do I interact with a dApp?" items={InteractionSteps} />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please extract the hardcoded titles.

</Box>
)
}
30 changes: 30 additions & 0 deletions src/components/walletconnect/Hints/styles.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.title {
display: flex;
align-items: center;
justify-content: center;
}

.questionIcon {
color: currentColor;
vertical-align: middle;
margin-right: var(--space-1);
font-size: inherit;
}

.list {
padding: var(--space-2);
display: flex;
flex-direction: column;
gap: var(--space-2);
}

.listItemAvatar {
min-width: unset;
margin-right: var(--space-2);
}

.avatar {
width: 16px;
height: 16px;
font-size: 11px;
}
Loading