diff --git a/src/components/Banners/YatBanner.tsx b/src/components/Banners/YatBanner.tsx index d3134f53917..4e261a376da 100644 --- a/src/components/Banners/YatBanner.tsx +++ b/src/components/Banners/YatBanner.tsx @@ -1,7 +1,7 @@ import type { LinkProps } from '@chakra-ui/react' import { Flex, Link, Tooltip, useMediaQuery } from '@chakra-ui/react' import { ethChainId, fromAccountId } from '@shapeshiftoss/caip' -import { useMemo } from 'react' +import { memo, useMemo } from 'react' import { useTranslate } from 'react-polyglot' import { YatIcon } from 'components/Icons/YatIcon' import { Text } from 'components/Text' @@ -14,7 +14,9 @@ type YatBannerProps = { isCompact?: boolean } & LinkProps -export const YatBanner: React.FC = ({ isCompact, ...rest }) => { +const hoverProp = { boxShadow: '0 0 0 2px var(--chakra-colors-chakra-body-text) inset' } + +export const YatBanner: React.FC = memo(({ isCompact, ...rest }) => { const [isLargerThan2xl] = useMediaQuery(`(min-width: ${breakpoints['2xl']})`, { ssr: false }) const translate = useTranslate() const { isDemoWallet } = useWallet().state @@ -52,11 +54,9 @@ export const YatBanner: React.FC = ({ isCompact, ...rest }) => { isExternal display='block' aria-label={translate('features.yat.banner.title')} - _hover={{ boxShadow: '0 0 0 2px var(--chakra-colors-chakra-body-text) inset' }} + _hover={hoverProp} borderRadius='xl' - backgroundImage={ - 'radial-gradient(circle at bottom left, #00C1C165 0%, transparent 30%), radial-gradient(circle at top right, #7B61FF70 0%, transparent 50%)' - } + backgroundImage='radial-gradient(circle at bottom left, #00C1C165 0%, transparent 30%), radial-gradient(circle at top right, #7B61FF70 0%, transparent 50%)' {...rest} > = ({ isCompact, ...rest }) => { ) -} +}) diff --git a/src/components/Layout/Header/AppLoadingIcon.tsx b/src/components/Layout/Header/AppLoadingIcon.tsx index f4faf364ef5..50a8725ad2a 100644 --- a/src/components/Layout/Header/AppLoadingIcon.tsx +++ b/src/components/Layout/Header/AppLoadingIcon.tsx @@ -1,16 +1,17 @@ import { Center } from '@chakra-ui/react' import { AnimatePresence } from 'framer-motion' +import { memo } from 'react' import { Link } from 'react-router-dom' import { CircularProgress } from 'components/CircularProgress/CircularProgress' import { FoxIcon } from 'components/Icons/FoxIcon' import { SlideTransitionY } from 'components/SlideTransitionY' import { useIsAnyApiFetching } from 'hooks/useIsAnyApiFetching/useIsAnyApiFetching' -export const AppLoadingIcon: React.FC = () => { +export const AppLoadingIcon: React.FC = memo(() => { const isLoading = useIsAnyApiFetching() return ( - + {isLoading ? (
@@ -25,4 +26,4 @@ export const AppLoadingIcon: React.FC = () => { ) -} +}) diff --git a/src/components/Layout/Header/DegradedStateBanner.tsx b/src/components/Layout/Header/DegradedStateBanner.tsx index 7b4ab226e1a..9558f0f0734 100644 --- a/src/components/Layout/Header/DegradedStateBanner.tsx +++ b/src/components/Layout/Header/DegradedStateBanner.tsx @@ -15,7 +15,7 @@ import { } from '@chakra-ui/react' import type { AccountId } from '@shapeshiftoss/caip' import { entries, isEmpty, uniq } from 'lodash' -import { useCallback, useMemo } from 'react' +import { memo, useCallback, useMemo } from 'react' import { IoMdRefresh } from 'react-icons/io' import { useTranslate } from 'react-polyglot' import { useSelector } from 'react-redux' @@ -26,7 +26,7 @@ import { accountIdToFeeAssetId } from 'state/slices/portfolioSlice/utils' import { selectAssets, selectPortfolioLoadingStatusGranular } from 'state/slices/selectors' import { useAppDispatch } from 'state/store' -export const DegradedStateBanner = () => { +export const DegradedStateBanner = memo(() => { const dispatch = useAppDispatch() const translate = useTranslate() const footerBg = useColorModeValue('blackAlpha.100', 'whiteAlpha.100') @@ -131,4 +131,4 @@ export const DegradedStateBanner = () => { ) -} +}) diff --git a/src/components/Layout/Header/GlobalSearch/GlobalSearchButton.tsx b/src/components/Layout/Header/GlobalSearch/GlobalSearchButton.tsx index 3e5cd0fac73..8fc9c7ac227 100644 --- a/src/components/Layout/Header/GlobalSearch/GlobalSearchButton.tsx +++ b/src/components/Layout/Header/GlobalSearch/GlobalSearchButton.tsx @@ -17,7 +17,7 @@ import { import { fromAssetId } from '@shapeshiftoss/caip' import { isEvmChainId } from '@shapeshiftoss/chain-adapters' import { DefiAction } from 'features/defi/contexts/DefiManagerProvider/DefiCommon' -import { useCallback, useEffect, useMemo, useRef, useState } from 'react' +import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react' import MultiRef from 'react-multi-ref' import { useTranslate } from 'react-polyglot' import { generatePath, useHistory, useLocation } from 'react-router' @@ -48,7 +48,15 @@ import { StakingResults } from './StakingResults/StakingResults' import { TxResults } from './TxResults/TxResults' import { makeOpportunityRouteDetails } from './utils' -export const GlobalSeachButton = () => { +const mrProp = { base: 0, md: 'auto' } +const widthProp = { base: 'auto', md: 'full' } +const displayProp1 = { base: 'flex', md: 'none' } +const displayProp2 = { base: 'none', md: 'flex' } +const inputGroupProps = { size: 'xl' } +const sxProp1 = { svg: { width: '18px', height: '18px' } } +const sxProp2 = { p: 0 } + +export const GlobalSeachButton = memo(() => { const { isOpen, onClose, onOpen, onToggle } = useDisclosure() const [sendResults, setSendResults] = useState([]) const [activeIndex, setActiveIndex] = useState(0) @@ -301,9 +309,9 @@ export const GlobalSeachButton = () => { return ( <> - + } aria-label='Search' onClick={onOpen} @@ -316,8 +324,8 @@ export const GlobalSeachButton = () => { fontSize='md' alignItems='center' color='text.subtle' - display={{ base: 'none', md: 'flex' }} - sx={{ svg: { width: '18px', height: '18px' } }} + display={displayProp2} + sx={sxProp1} > {translate('common.search')} {!isMobileApp && ( // Mobile app users are unlikely to have access to a keyboard for the shortcut. @@ -333,7 +341,7 @@ export const GlobalSeachButton = () => { @@ -341,7 +349,7 @@ export const GlobalSeachButton = () => { searchQuery={searchQuery} setSearchQuery={setSearchQuery} onKeyDown={onKeyDown} - inputGroupProps={{ size: 'xl' }} + inputGroupProps={inputGroupProps} borderBottomRadius={0} borderWidth={0} /> @@ -353,4 +361,4 @@ export const GlobalSeachButton = () => { ) -} +}) diff --git a/src/components/Layout/Header/Header.tsx b/src/components/Layout/Header/Header.tsx index bb6c912e5a0..6ba834b1113 100644 --- a/src/components/Layout/Header/Header.tsx +++ b/src/components/Layout/Header/Header.tsx @@ -8,6 +8,7 @@ import { HStack, IconButton, useDisclosure, + useMediaQuery, usePrevious, useToast, } from '@chakra-ui/react' @@ -34,6 +35,7 @@ import { selectWalletId, } from 'state/slices/selectors' import { useAppDispatch } from 'state/store' +import { breakpoints } from 'theme/theme' import { AppLoadingIcon } from './AppLoadingIcon' import { DegradedStateBanner } from './DegradedStateBanner' @@ -45,6 +47,14 @@ import { UserMenu } from './NavBar/UserMenu' import { SideNavContent } from './SideNavContent' import { TxWindow } from './TxWindow/TxWindow' +const paddingBottomProp = { base: '0.5rem', md: 0 } +const fontSizeProp = { base: 'sm', md: 'md' } +const paddingTopProp1 = { base: 'calc(0.5rem + env(safe-area-inset-top))', md: 0 } +const pxProp = { base: 0, xl: 4 } +const displayProp = { base: 'block', md: 'none' } +const displayProp2 = { base: 'none', md: 'block' } +const widthProp = { base: 'auto', md: 'full' } + export const Header = memo(() => { const { onToggle, isOpen, onClose } = useDisclosure() const isDegradedState = useSelector(selectPortfolioLoadingStatus) === 'error' @@ -52,6 +62,7 @@ export const Header = memo(() => { const isSnapInstalled = useIsSnapInstalled() const previousSnapInstall = usePrevious(isSnapInstalled) const showSnapModal = useSelector(selectShowSnapsModal) + const [isLargerThanMd] = useMediaQuery(`(min-width: ${breakpoints['md']})`, { ssr: false }) const history = useHistory() const { @@ -149,16 +160,21 @@ export const Header = memo(() => { walletAccountIds, ]) + const paddingTopProp2 = useMemo( + () => ({ base: isDemoWallet ? 0 : 'env(safe-area-inset-top)', md: 0 }), + [isDemoWallet], + ) + return ( <> {isDemoWallet && ( @@ -186,39 +202,41 @@ export const Header = memo(() => { transitionProperty='all' transitionTimingFunction='cubic-bezier(0.4, 0, 0.2, 1)' top={0} - paddingTop={{ base: isDemoWallet ? 0 : 'env(safe-area-inset-top)', md: 0 }} + paddingTop={paddingTopProp2} > - - + + } /> - + - {isDegradedState && } - {isWalletConnectToDappsV2Enabled && ( - + {isLargerThanMd && isDegradedState && } + {isLargerThanMd && isWalletConnectToDappsV2Enabled && ( + )} - + {isLargerThanMd && } - - - + {isLargerThanMd && ( + + + + )} diff --git a/src/components/Layout/Header/NavBar/ChainMenu.tsx b/src/components/Layout/Header/NavBar/ChainMenu.tsx index 5c2de4ffa5c..30c12a66e4c 100644 --- a/src/components/Layout/Header/NavBar/ChainMenu.tsx +++ b/src/components/Layout/Header/NavBar/ChainMenu.tsx @@ -19,7 +19,7 @@ import type { EvmBaseAdapter, EvmChainId } from '@shapeshiftoss/chain-adapters' import type { ETHWallet } from '@shapeshiftoss/hdwallet-core' import { supportsEthSwitchChain } from '@shapeshiftoss/hdwallet-core' import { utils } from 'ethers' -import { useCallback, useMemo } from 'react' +import { memo, useCallback, useMemo } from 'react' import { useTranslate } from 'react-polyglot' import { AssetIcon } from 'components/AssetIcon' import { CircleIcon } from 'components/Icons/Circle' @@ -42,14 +42,19 @@ const ChainMenuItem: React.FC<{ const connectedIconColor = useColorModeValue('green.500', 'green.200') const connectedChainBgColor = useColorModeValue('blackAlpha.100', 'whiteAlpha.50') + const assetIcon = useMemo( + () => , + [nativeAssetId], + ) + const handleClick = useCallback(() => onClick(ethNetwork), [ethNetwork, onClick]) if (!nativeAsset) return null return ( } + icon={assetIcon} backgroundColor={isConnected ? connectedChainBgColor : undefined} - onClick={() => onClick(ethNetwork)} + onClick={handleClick} borderRadius='lg' > @@ -62,7 +67,7 @@ const ChainMenuItem: React.FC<{ type ChainMenuProps = BoxProps -export const ChainMenu = (props: ChainMenuProps) => { +export const ChainMenu = memo((props: ChainMenuProps) => { const { state, load } = useWallet() const { connectedEvmChainId, @@ -177,4 +182,4 @@ export const ChainMenu = (props: ChainMenuProps) => { ) -} +}) diff --git a/src/components/Layout/Header/NavBar/MainNavLink.tsx b/src/components/Layout/Header/NavBar/MainNavLink.tsx index d7ddd47142c..2c1f027f8bc 100644 --- a/src/components/Layout/Header/NavBar/MainNavLink.tsx +++ b/src/components/Layout/Header/NavBar/MainNavLink.tsx @@ -1,6 +1,6 @@ import type { ButtonProps } from '@chakra-ui/react' import { Box, Button, Tag, Tooltip, useMediaQuery } from '@chakra-ui/react' -import { memo, useCallback } from 'react' +import { memo, useCallback, useMemo } from 'react' import { useTranslate } from 'react-polyglot' import type { NavLinkProps } from 'react-router-dom' import { CircleIcon } from 'components/Icons/Circle' @@ -16,6 +16,14 @@ type SidebarLinkProps = { isActive?: boolean } & ButtonProps +const styleProp = { width: '0.5em', height: '0.5em', color: 'var(--chakra-colors-pink-200)' } +const hoverProp = { bg: 'background.button.secondary.base' } +const activeProp = { + bg: 'transparent', + color: 'text.base', + fontWeight: 'bold', +} + export const MainNavLink = memo( ({ isCompact, onClick, isNew, label, isActive, ...rest }: SidebarLinkProps) => { const [isLargerThan2xl] = useMediaQuery(`(min-width: ${breakpoints['2xl']})`, { ssr: false }) @@ -25,11 +33,31 @@ export const MainNavLink = memo( [isActive, onClick], ) + const justifyContentProp = useMemo( + () => ({ base: isCompact ? 'center' : 'flex-start', '2xl': 'flex-start' }), + [isCompact], + ) + + const displayProp1 = useMemo( + () => ({ base: isCompact ? 'none' : 'inline-flex', '2xl': 'inline-flex' }), + [isCompact], + ) + + const displayProp2 = useMemo( + () => ({ base: isCompact ? 'none' : 'flex', '2xl': 'block' }), + [isCompact], + ) + + const displayProp3 = useMemo( + () => ({ base: isCompact ? 'block' : 'none', '2xl': 'none' }), + [isCompact], + ) + return ( ) -} +}) diff --git a/src/components/Layout/Header/NavBar/NavBar.tsx b/src/components/Layout/Header/NavBar/NavBar.tsx index 6ff61c16eb1..349236a46ec 100644 --- a/src/components/Layout/Header/NavBar/NavBar.tsx +++ b/src/components/Layout/Header/NavBar/NavBar.tsx @@ -45,6 +45,11 @@ export const NavBar = ({ isCompact, onClick, ...rest }: NavBarProps) => { return Array.from(groups.entries()) }, [isLargerThanMd, pluginRoutes]) + const displayProp = useMemo( + () => ({ base: isCompact ? 'none' : 'block', '2xl': 'block' }), + [isCompact], + ) + const renderNavGroups = useMemo(() => { return navItemGroups.map((group, id) => { const [name, values] = group @@ -58,7 +63,7 @@ export const NavBar = ({ isCompact, onClick, ...rest }: NavBarProps) => { textTransform='uppercase' fontWeight='bold' letterSpacing='wider' - display={{ base: isCompact ? 'none' : 'block', '2xl': 'block' }} + display={displayProp} translation={`navBar.${name}`} /> )} @@ -88,16 +93,12 @@ export const NavBar = ({ isCompact, onClick, ...rest }: NavBarProps) => { ) }) - }, [groupColor, isCompact, navItemGroups, onClick, pathname, translate]) + }, [displayProp, groupColor, isCompact, navItemGroups, onClick, pathname, translate]) + + const divider = useMemo(() => , [dividerColor]) return ( - } - {...rest} - > + {renderNavGroups} {isYatFeatureEnabled && } diff --git a/src/components/Layout/Header/NavBar/Notifications.tsx b/src/components/Layout/Header/NavBar/Notifications.tsx index 5833edfb8bd..f7fdc3a3e44 100644 --- a/src/components/Layout/Header/NavBar/Notifications.tsx +++ b/src/components/Layout/Header/NavBar/Notifications.tsx @@ -10,7 +10,7 @@ import { } from '@wherever/react-notification-feed' import { getConfig } from 'config' import { utils } from 'ethers' -import { useCallback, useEffect, useMemo, useState } from 'react' +import { memo, useCallback, useEffect, useMemo, useState } from 'react' import { KeyManager } from 'context/WalletProvider/KeyManager' import { useFeatureFlag } from 'hooks/useFeatureFlag/useFeatureFlag' import { useWallet } from 'hooks/useWallet/useWallet' @@ -18,7 +18,7 @@ import { breakpoints, theme } from 'theme/theme' const eip712SupportedWallets = [KeyManager.KeepKey, KeyManager.Native, KeyManager.Mobile] -export const Notifications = () => { +export const Notifications = memo(() => { const isWhereverEnabled = useFeatureFlag('Wherever') const { colorMode } = useColorMode() const { @@ -107,6 +107,16 @@ export const Notifications = () => { [wallet, addressNList], ) + const customSignerProp = useMemo( + () => ({ + address: ethAddress, + chainId: 1, + signMessage, + signTypedData, + }), + [ethAddress, signMessage, signTypedData], + ) + if ( !isWhereverEnabled || !ethAddress || @@ -119,17 +129,12 @@ export const Notifications = () => { return ( - + @@ -137,4 +142,4 @@ export const Notifications = () => { ) -} +}) diff --git a/src/components/Layout/Header/NavBar/UserMenu.tsx b/src/components/Layout/Header/NavBar/UserMenu.tsx index bce884bb241..dba53558f00 100644 --- a/src/components/Layout/Header/NavBar/UserMenu.tsx +++ b/src/components/Layout/Header/NavBar/UserMenu.tsx @@ -12,7 +12,7 @@ import { useColorModeValue, } from '@chakra-ui/react' import type { FC } from 'react' -import { useCallback, useEffect, useState } from 'react' +import { memo, useCallback, useEffect, useMemo, useState } from 'react' import { FaWallet } from 'react-icons/fa' import { useTranslate } from 'react-polyglot' import { MemoryRouter } from 'react-router-dom' @@ -29,6 +29,10 @@ import { viemEthMainnetClient } from 'lib/viem-client' export const entries = [WalletConnectedRoutes.Connected] +const maxWidthProp = { base: 'full', md: 'xs' } +const minWidthProp = { base: 0, md: 'xs' } +const widthProp = { base: '100%', lg: 'auto' } + const NoWallet = ({ onClick }: { onClick: () => void }) => { const translate = useTranslate() return ( @@ -106,20 +110,25 @@ const WalletButton: FC = ({ return setWalletLabel(walletInfo?.meta?.address ?? '') }, [ensName, walletInfo]) + const rightIcon = useMemo(() => , []) + const leftIcon = useMemo( + () => ( + + {!(isConnected || isDemoWallet) && } + + + ), + [isConnected, isDemoWallet, walletInfo], + ) + const connectIcon = useMemo(() => , []) + return Boolean(walletInfo?.deviceId) || isLoadingLocalWallet ? ( } - leftIcon={ - - {!(isConnected || isDemoWallet) && ( - - )} - - - } + rightIcon={rightIcon} + leftIcon={leftIcon} > {walletLabel ? ( @@ -139,13 +148,13 @@ const WalletButton: FC = ({ ) : ( - ) } -export const UserMenu: React.FC<{ onClick?: () => void }> = ({ onClick }) => { +export const UserMenu: React.FC<{ onClick?: () => void }> = memo(({ onClick }) => { const { state, dispatch, disconnect } = useWallet() const { isConnected, isDemoWallet, walletInfo, connectedType, isLocked, isLoadingLocalWallet } = state @@ -168,8 +177,8 @@ export const UserMenu: React.FC<{ onClick?: () => void }> = ({ onClick }) => { data-test='navigation-wallet-dropdown-button' /> void }> = ({ onClick }) => { ) -} +}) diff --git a/src/components/Layout/Header/SideNav.tsx b/src/components/Layout/Header/SideNav.tsx index 75255ec8882..bbd84378f84 100644 --- a/src/components/Layout/Header/SideNav.tsx +++ b/src/components/Layout/Header/SideNav.tsx @@ -4,31 +4,35 @@ import { memo } from 'react' import { AppLoadingIcon } from './AppLoadingIcon' import { SideNavContent } from './SideNavContent' +const justifyContentProp = { base: 'center', md: 'flex-start' } +const widthProp = { base: 'auto', '2xl': 'xs' } +const displayProp = { base: 'none', md: 'flex' } + export const SideNav = memo(() => { const bgColor = useColorModeValue('white', 'blackAlpha.300') const shadow = useColorModeValue('lg', 'none') return ( - + - + ) }) diff --git a/src/components/Layout/Header/SideNavContent.tsx b/src/components/Layout/Header/SideNavContent.tsx index 4bf7279f374..c3d6da1521d 100644 --- a/src/components/Layout/Header/SideNavContent.tsx +++ b/src/components/Layout/Header/SideNavContent.tsx @@ -2,7 +2,7 @@ import { ChatIcon, CloseIcon, SettingsIcon } from '@chakra-ui/icons' import type { FlexProps } from '@chakra-ui/react' import { Box, Flex, IconButton, Stack, useMediaQuery } from '@chakra-ui/react' import { WalletConnectToDappsHeaderButton } from 'plugins/walletConnectToDapps/components/header/WalletConnectToDappsHeaderButton' -import { memo, useCallback } from 'react' +import { memo, useCallback, useMemo } from 'react' import { useTranslate } from 'react-polyglot' import { useFeatureFlag } from 'hooks/useFeatureFlag/useFeatureFlag' import { useModal } from 'hooks/useModal/useModal' @@ -35,6 +35,10 @@ export const SideNavContent = memo(({ isCompact, onClose }: HeaderContentProps) onClose && onClose() }, [onClose, feedbackSupport]) + const closeIcon = useMemo(() => , []) + const settingsIcon = useMemo(() => , []) + const chatIcon = useMemo(() => , []) + return ( {!isLargerThanMd && ( @@ -54,7 +58,7 @@ export const SideNavContent = memo(({ isCompact, onClose }: HeaderContentProps) ml='auto' aria-label='Close Nav' variant='ghost' - icon={} + icon={closeIcon} onClick={onClose} /> @@ -78,7 +82,7 @@ export const SideNavContent = memo(({ isCompact, onClose }: HeaderContentProps) size='sm' onClick={handleClickSettings} label={translate('common.settings')} - leftIcon={} + leftIcon={settingsIcon} data-test='navigation-settings-button' /> } + leftIcon={chatIcon} /> diff --git a/src/components/Layout/Header/TxWindow/TxWindow.tsx b/src/components/Layout/Header/TxWindow/TxWindow.tsx index 2765af7bd7b..ba0576f1db7 100644 --- a/src/components/Layout/Header/TxWindow/TxWindow.tsx +++ b/src/components/Layout/Header/TxWindow/TxWindow.tsx @@ -17,7 +17,7 @@ import { Tabs, } from '@chakra-ui/react' import { TxStatus } from '@shapeshiftoss/unchained-client' -import React, { useMemo, useState } from 'react' +import React, { memo, useCallback, useMemo, useState } from 'react' import { useTranslate } from 'react-polyglot' import { CircularProgress } from 'components/CircularProgress/CircularProgress' import { TxHistoryIcon } from 'components/Icons/TxHistory' @@ -26,7 +26,9 @@ import { TransactionsGroupByDate } from 'components/TransactionHistory/Transacti import { selectTxIdsByFilter } from 'state/slices/selectors' import { useAppSelector } from 'state/store' -const padding = { base: 4, md: 6 } +const paddingProp = { base: 4, md: 6 } +const selectedProp = { color: 'text.base' } +const hoverProp = { cursor: 'pointer' } const CustomTab: React.FC = props => ( = props => ( fontWeight='medium' color='text.subtle' cursor='pointer' - _selected={{ color: 'text.base' }} - _hover={{ cursor: 'pointer' }} + _selected={selectedProp} + _hover={hoverProp} {...props} /> ) @@ -53,7 +55,7 @@ const TxsByStatus: React.FC = ({ txStatus, limit }) => { if (limitTxIds.length === 0) { return ( - + {translate('transactionRow.emptyMessage', { status: txStatus })} ) @@ -61,20 +63,26 @@ const TxsByStatus: React.FC = ({ txStatus, limit }) => { return } -export const TxWindow = () => { +export const TxWindow = memo(() => { const [isOpen, setIsOpen] = useState(false) const [limit, setLimit] = useState('25') const translate = useTranslate() const filter = useMemo(() => ({ txStatus: TxStatus.Pending }), []) const pendingTxIds = useAppSelector(state => selectTxIdsByFilter(state, filter)) const hasPendingTxs = useMemo(() => pendingTxIds.length > 0, [pendingTxIds]) + const handleToggleIsOpen = useCallback(() => setIsOpen(previousIsOpen => !previousIsOpen), []) + const handleClose = useCallback(() => setIsOpen(false), []) + const handleSetLimit = useCallback( + (e: React.ChangeEvent) => setLimit(e.target.value), + [], + ) return ( <> : } - onClick={() => setIsOpen(!isOpen)} + onClick={handleToggleIsOpen} /> { {pendingTxIds.length} - setIsOpen(false)} size='sm'> + - - + + {translate('navBar.transactions')} @@ -109,7 +117,7 @@ export const TxWindow = () => { { size='sm' variant='filled' value={limit} - onChange={e => setLimit(e.target.value)} + onChange={handleSetLimit} borderRadius='lg' fontWeight='medium' > @@ -155,4 +163,4 @@ export const TxWindow = () => { ) -} +}) diff --git a/src/plugins/walletConnectToDapps/components/header/WalletConnectToDappsHeaderButton.tsx b/src/plugins/walletConnectToDapps/components/header/WalletConnectToDappsHeaderButton.tsx index ca5723b7151..33c27f1076e 100644 --- a/src/plugins/walletConnectToDapps/components/header/WalletConnectToDappsHeaderButton.tsx +++ b/src/plugins/walletConnectToDapps/components/header/WalletConnectToDappsHeaderButton.tsx @@ -3,7 +3,7 @@ import { AvatarGroup, Button, Menu, MenuButton, MenuList } from '@chakra-ui/reac import type { SessionTypes } from '@walletconnect/types' import { DappHeaderMenuSummary } from 'plugins/walletConnectToDapps/components/header/DappHeaderMenuSummary' import { useWalletConnectV2 } from 'plugins/walletConnectToDapps/WalletConnectV2Provider' -import { type FC, useMemo } from 'react' +import { type FC, memo, useMemo } from 'react' import { useTranslate } from 'react-polyglot' import { RawText } from 'components/Text' import { useFeatureFlag } from 'hooks/useFeatureFlag/useFeatureFlag' @@ -38,7 +38,7 @@ const WalletConnectV2ConnectedButtonText = ({ ) } -const WalletConnectV2ConnectedButton = () => { +const WalletConnectV2ConnectedButton = memo(() => { const { sessionsByTopic } = useWalletConnectV2() const translate = useTranslate() const sessions = useMemo(() => Object.values(sessionsByTopic).filter(isSome), [sessionsByTopic]) @@ -50,27 +50,33 @@ const WalletConnectV2ConnectedButton = () => { }, undefined), [sessions], ) + const rightIcon = useMemo(() => , []) + const leftIcon = useMemo( + () => ( + + {sessions.map(session => { + return ( + + ) + })} + + ), + [sessions], + ) + return ( - {sessions.map(session => { - return ( - - ) - })} - - } - rightIcon={} + leftIcon={leftIcon} + rightIcon={rightIcon} width={widthProp} textAlign='left' flexShrink='none' @@ -104,9 +110,9 @@ const WalletConnectV2ConnectedButton = () => { ) -} +}) -export const WalletConnectToDappsHeaderButton: FC = () => { +export const WalletConnectToDappsHeaderButton: FC = memo(() => { const walletConnectV2 = useWalletConnectV2() const isWalletConnectToDappsV2Enabled = useFeatureFlag('WalletConnectToDappsV2') @@ -126,4 +132,4 @@ export const WalletConnectToDappsHeaderButton: FC = () => { default: return } -} +})