From b4f35556005978f3c2cd574a91a42b52562294ee Mon Sep 17 00:00:00 2001 From: Jack Short Date: Wed, 8 Nov 2023 12:31:45 -0500 Subject: [PATCH] chore: add appropriate padding and update chain selector to styled (#7549) * chore: add appropriate padding and update chain selector to styled * light gray on hover remove * Update src/components/NavBar/ChainSelector.tsx Co-authored-by: Charles Bachmeier --------- Co-authored-by: Charles Bachmeier --- src/components/NavBar/ChainSelector.css.ts | 16 -------- src/components/NavBar/ChainSelector.tsx | 48 +++++++++++++--------- src/nft/css/common.css.ts | 13 +----- 3 files changed, 29 insertions(+), 48 deletions(-) delete mode 100644 src/components/NavBar/ChainSelector.css.ts diff --git a/src/components/NavBar/ChainSelector.css.ts b/src/components/NavBar/ChainSelector.css.ts deleted file mode 100644 index eed1b6c46a..0000000000 --- a/src/components/NavBar/ChainSelector.css.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { style } from '@vanilla-extract/css' -import { lightGrayOverlayOnHover } from 'nft/css/common.css' - -import { sprinkles } from '../../nft/css/sprinkles.css' - -export const ChainSelector = style([ - lightGrayOverlayOnHover, - sprinkles({ - borderRadius: '20', - height: '36', - cursor: 'pointer', - border: 'none', - color: 'neutral1', - background: 'none', - }), -]) diff --git a/src/components/NavBar/ChainSelector.tsx b/src/components/NavBar/ChainSelector.tsx index 59b9c9963c..0a88739e1f 100644 --- a/src/components/NavBar/ChainSelector.tsx +++ b/src/components/NavBar/ChainSelector.tsx @@ -2,6 +2,7 @@ import { t } from '@lingui/macro' import { ChainId } from '@uniswap/sdk-core' import { useWeb3React } from '@web3-react/core' import { showTestnetsAtom } from 'components/AccountDrawer/TestnetsToggle' +import { BaseButton } from 'components/Button' import { ChainLogo } from 'components/Logo/ChainLogo' import { MouseoverTooltip } from 'components/Tooltip' import { getConnection } from 'connection' @@ -13,24 +14,38 @@ import { useOnClickOutside } from 'hooks/useOnClickOutside' import useSelectChain from 'hooks/useSelectChain' import useSyncChainQuery from 'hooks/useSyncChainQuery' import { useAtomValue } from 'jotai/utils' -import { Box } from 'nft/components/Box' import { Portal } from 'nft/components/common/Portal' -import { Column, Row } from 'nft/components/Flex' +import { Column } from 'nft/components/Flex' import { useIsMobile } from 'nft/hooks' import { useCallback, useMemo, useRef, useState } from 'react' import { AlertTriangle, ChevronDown, ChevronUp } from 'react-feather' -import { useTheme } from 'styled-components' +import styled, { useTheme } from 'styled-components' import { getSupportedChainIdsFromWalletConnectSession } from 'utils/getSupportedChainIdsFromWalletConnectSession' -import * as styles from './ChainSelector.css' import ChainSelectorRow from './ChainSelectorRow' import { NavDropdown } from './NavDropdown' const NETWORK_SELECTOR_CHAINS = [...L1_CHAIN_IDS, ...L2_CHAIN_IDS] -interface ChainSelectorProps { - leftAlign?: boolean -} +const ChainSelectorWrapper = styled.div` + position: relative; +` + +const ChainSelectorButton = styled(BaseButton)<{ isOpen: boolean }>` + display: flex; + background: ${({ theme, isOpen }) => (isOpen ? theme.accent2 : 'none')}; + padding: 10px 8px; + gap: 4px; + border-radius: 12px; + height: 40px; + color: ${({ theme }) => theme.neutral1}; + transition: ${({ theme }) => + `${theme.transition.duration.medium} ${theme.transition.timing.ease} background-color, ${theme.transition.duration.medium} ${theme.transition.timing.ease} margin`}; + + &:hover { + background-color: ${({ theme }) => theme.deprecated_stateOverlayHover}; + } +` function useWalletSupportedChains(): ChainId[] { const { connector } = useWeb3React() @@ -45,7 +60,7 @@ function useWalletSupportedChains(): ChainId[] { } } -export const ChainSelector = ({ leftAlign }: ChainSelectorProps) => { +export const ChainSelector = ({ leftAlign }: { leftAlign?: boolean }) => { const { chainId } = useWeb3React() const [isOpen, setIsOpen] = useState(false) const isMobile = useIsMobile() @@ -133,25 +148,18 @@ export const ChainSelector = ({ leftAlign }: ChainSelectorProps) => { } return ( - + - setIsOpen(!isOpen)} - > + setIsOpen(!isOpen)} isOpen={isOpen}> {!isSupported ? ( ) : ( - + )} {isOpen ? : } - + {isOpen && (isMobile ? {dropdown} : <>{dropdown})} - + ) } diff --git a/src/nft/css/common.css.ts b/src/nft/css/common.css.ts index 94014b12e6..0b5868d1ca 100644 --- a/src/nft/css/common.css.ts +++ b/src/nft/css/common.css.ts @@ -1,6 +1,6 @@ import { style } from '@vanilla-extract/css' -import { sprinkles, vars } from './sprinkles.css' +import { sprinkles } from './sprinkles.css' export const center = sprinkles({ display: 'flex', @@ -58,14 +58,3 @@ export const magicalGradientOnHover = style([ }, }, ]) - -export const lightGrayOverlayOnHover = style([ - sprinkles({ - transition: '250', - }), - { - ':hover': { - background: vars.color.lightGrayOverlay, - }, - }, -])