From 868f0acef8f1b6c1624a558029a93bd52eb318c4 Mon Sep 17 00:00:00 2001 From: Aaron Cook Date: Thu, 12 Oct 2023 11:56:58 +0200 Subject: [PATCH] fix: populate help section (#2619) * fix: populate help section * refactor: extract constants + debounce hints --- .../walletconnect/ConnectionForm/index.tsx | 26 +++-- src/components/walletconnect/Hints/index.tsx | 105 +++++++++++------- .../walletconnect/Hints/styles.module.css | 30 +++++ 3 files changed, 111 insertions(+), 50 deletions(-) create mode 100644 src/components/walletconnect/Hints/styles.module.css diff --git a/src/components/walletconnect/ConnectionForm/index.tsx b/src/components/walletconnect/ConnectionForm/index.tsx index 5cda73deb3..f45a12b685 100644 --- a/src/components/walletconnect/ConnectionForm/index.tsx +++ b/src/components/walletconnect/ConnectionForm/index.tsx @@ -8,6 +8,7 @@ import SessionList from '../SessionList' import WcInput from '../WcInput' import InfoIcon from '@/public/images/notifications/info.svg' import { WalletConnectHeader } from '../SessionManager/Header' +import useDebounce from '@/hooks/useDebounce' import css from './styles.module.css' @@ -21,19 +22,24 @@ export const ConnectionForm = ({ onDisconnect: (session: SessionTypes.Struct) => Promise }): ReactElement => { const [hideHints = false, setHideHints] = useLocalStorage(WC_HINTS_KEY) + const debouncedHideHints = useDebounce(hideHints, 300) return ( - {hideHints && ( - - - setHideHints(false)} className={css.infoIcon}> - - - - - )} + @@ -50,7 +56,7 @@ export const ConnectionForm = ({ - {!hideHints && ( + {!debouncedHideHints && ( <> diff --git a/src/components/walletconnect/Hints/index.tsx b/src/components/walletconnect/Hints/index.tsx index 3dd1bd195c..8640e83237 100644 --- a/src/components/walletconnect/Hints/index.tsx +++ b/src/components/walletconnect/Hints/index.tsx @@ -1,53 +1,78 @@ 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 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 }): ReactElement => { return ( - - - {children} - + + }> + + + {title} + + + + + + {items.map((item, i) => ( + + + {i + 1} + + + + ))} + + + ) } -// TODO: Add content to the hints +const ConnectionTitle = 'How do I connect to a dApp?' +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', +] + +const InteractionTitle = 'How do I interact with a dApp?' +const InteractionSteps = [ + 'Connect a dApp by following the above steps', + `Ensure the dApp is connected to %%chain%%`, + 'Initiate a transaction/signature request via the dApp', + 'Transact/sign as normal via the Safe', +] + export const Hints = (): ReactElement => { + const chain = useCurrentChain() + + if (chain?.chainName) { + InteractionSteps[1] = InteractionSteps[1].replace(/%%chain%%/, chain?.chainName) + } + return ( - <> - - }> - How do I connect to a dApp? - - - - - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse malesuada lacus ex, sit amet blandit - leo lobortis eget. - - - - - - }> - How do I interact with a dApp? - - - - - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse malesuada lacus ex, sit amet blandit - leo lobortis eget. - - - - + + + + ) } diff --git a/src/components/walletconnect/Hints/styles.module.css b/src/components/walletconnect/Hints/styles.module.css new file mode 100644 index 0000000000..ee3635b0ce --- /dev/null +++ b/src/components/walletconnect/Hints/styles.module.css @@ -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; +}