diff --git a/packages/ui/src/components/WalletConnect/WalletConnectSession.tsx b/packages/ui/src/components/WalletConnect/WalletConnectSession.tsx index 3437f3126..cc63f74b9 100644 --- a/packages/ui/src/components/WalletConnect/WalletConnectSession.tsx +++ b/packages/ui/src/components/WalletConnect/WalletConnectSession.tsx @@ -1,6 +1,6 @@ import { Alert, CircularProgress, Grid, styled } from '@mui/material' import { Button, TextFieldStyled } from '../library' -import { useCallback, useMemo, useState } from 'react' +import React, { useCallback, useMemo, useState } from 'react' import { useWalletConnect } from '../../contexts/WalletConnectContext' import { useMultiProxy } from '../../contexts/MultiProxyContext' diff --git a/packages/ui/src/components/select/AccountSelection.tsx b/packages/ui/src/components/select/AccountSelection.tsx index d1e8fcc74..2022d025e 100644 --- a/packages/ui/src/components/select/AccountSelection.tsx +++ b/packages/ui/src/components/select/AccountSelection.tsx @@ -18,6 +18,8 @@ interface Props { addAccount?: (address: string) => void value?: string label?: string + actionButtonLabel?: string + actionButtonVariant?: 'primary' | 'secondary' currentSelection?: string[] withName?: boolean withAddButton?: boolean @@ -31,6 +33,8 @@ const AccountSelection = ({ nameDisabled = false, value, label = 'Address', + actionButtonLabel = 'Add', + actionButtonVariant = 'secondary', currentSelection = [], withName = false, withAddButton = false, @@ -179,11 +183,11 @@ const AccountSelection = ({ {withAddButton && ( - Watch + {actionButtonLabel} )} diff --git a/packages/ui/src/pages/Settings/Settings.tsx b/packages/ui/src/pages/Settings/Settings.tsx index 459b7c156..df3a4112b 100644 --- a/packages/ui/src/pages/Settings/Settings.tsx +++ b/packages/ui/src/pages/Settings/Settings.tsx @@ -5,24 +5,32 @@ import { WalletConnectSession } from '../../components/WalletConnect/WalletConne import { WalletConnectActiveSessions } from '../../components/WalletConnect/WalletConnectActiveSessions' import { HiOutlineChevronDown as ExpandMoreIcon, HiOutlineEye } from 'react-icons/hi2' import { theme } from '../../styles/theme' -import { SyntheticEvent, useEffect, useState } from 'react' +import { SyntheticEvent, useCallback, useEffect, useState } from 'react' import { useLocation } from 'react-router-dom' +const ACCORDION_WATCHED_ACCOUNTS = 'panel-watched-accounts' +const ACCORDION_WALLET_CONNECT = 'panel-wallet-connect' + +type AccordionNames = typeof ACCORDION_WATCHED_ACCOUNTS | typeof ACCORDION_WALLET_CONNECT + const Settings = () => { - const location = useLocation() - const [expanded, setExpanded] = useState(false) - const handleChange = (panel: string) => (event: SyntheticEvent | null, isExpanded: boolean) => { - console.log('handleChange', panel) - setExpanded(isExpanded ? panel : false) - } + const { hash } = useLocation() + const [expanded, setExpanded] = useState(false) + + const handleChange = useCallback( + (panel: AccordionNames) => (_event: SyntheticEvent | null, isExpanded: boolean) => { + setExpanded(isExpanded ? panel : false) + }, + [] + ) useEffect(() => { - if (location.hash === '#watched-acccounts') { + if (hash === '#watched-acccounts') { handleChange('panel-watched-accounts')(null, true) - } else if (location.hash === '#wallet-connect') { + } else if (hash === '#wallet-connect') { handleChange('panel-wallet-connect')(null, true) } - }, [location.hash]) + }, [handleChange, hash]) return ( <> @@ -66,11 +74,11 @@ const SettingsHeaderStyled = styled('h1')` const AccordionStyled = styled(Accordion)` max-width: 42.5625rem; box-shadow: none; - border-bottom: 1px solid #e5e5e5; + border-bottom: 1px solid ${({ theme }) => theme.custom.neutral[200]}; &.Mui-expanded { margin: 0; - background: #fafafa; + background: ${({ theme }) => theme.custom.neutral[50]}; .MuiAccordionSummary-root { margin: 0; diff --git a/packages/ui/src/pages/Settings/WatchedAccounts.tsx b/packages/ui/src/pages/Settings/WatchedAccounts.tsx index 209b65335..eb9d20520 100644 --- a/packages/ui/src/pages/Settings/WatchedAccounts.tsx +++ b/packages/ui/src/pages/Settings/WatchedAccounts.tsx @@ -4,36 +4,34 @@ import { useWatchedAddresses } from '../../contexts/WatchedAddressesContext' import AccountDisplay from '../../components/AccountDisplay' import { HiOutlineXMark } from 'react-icons/hi2' import AccountSelection from '../../components/select/AccountSelection' +import { useCallback } from 'react' -interface Props { - className?: string -} - -const WatchedAccounts = ({ className }: Props) => { +const WatchedAccounts = () => { const { watchedAddresses, removeWatchedAccount, addWatchedAccount } = useWatchedAddresses() + const hasWatchedAddresses = useCallback(() => watchedAddresses.length > 0, [watchedAddresses]) return ( <> - Currently watched accounts: + {hasWatchedAddresses() && ( + Currently watched accounts: + )} - {watchedAddresses.length > 0 && ( + {hasWatchedAddresses() && ( - {watchedAddresses.map((address, index) => { + {watchedAddresses.map((address) => { return ( - {index + 1} { xs={12} md={8} > - Watch an account