diff --git a/src/components/NavBar/ChainSwitcher.css.ts b/src/components/NavBar/ChainSwitcher.css.ts index 8c8ebec6bc..2d9b3c4b24 100644 --- a/src/components/NavBar/ChainSwitcher.css.ts +++ b/src/components/NavBar/ChainSwitcher.css.ts @@ -1,7 +1,7 @@ import { style } from '@vanilla-extract/css' import { lightGrayOverlayOnHover } from 'nft/css/common.css' -import { sprinkles } from '../../nft/css/sprinkles.css' +import { breakpoints, sprinkles } from '../../nft/css/sprinkles.css' export const ChainSwitcher = style([ lightGrayOverlayOnHover, @@ -26,10 +26,15 @@ export const ChainSwitcherRow = style([ cursor: 'pointer', color: 'blackBlue', borderRadius: '12', + width: { sm: 'full' }, }), { lineHeight: '24px', - width: '204px', + '@media': { + [`screen and (min-width: ${breakpoints.sm}px)`]: { + width: '204px', + }, + }, }, ]) diff --git a/src/components/NavBar/ChainSwitcher.tsx b/src/components/NavBar/ChainSwitcher.tsx index 2e93b5a9be..14c3003f9a 100644 --- a/src/components/NavBar/ChainSwitcher.tsx +++ b/src/components/NavBar/ChainSwitcher.tsx @@ -5,10 +5,12 @@ import { useOnClickOutside } from 'hooks/useOnClickOutside' import useSelectChain from 'hooks/useSelectChain' import useSyncChainQuery from 'hooks/useSyncChainQuery' import { Box } from 'nft/components/Box' +import { Portal } from 'nft/components/common/Portal' import { Column, Row } from 'nft/components/Flex' import { CheckMarkIcon, NewChevronDownIcon, NewChevronUpIcon, TokenWarningRedIcon } from 'nft/components/icons' import { subhead } from 'nft/css/common.css' import { themeVars, vars } from 'nft/css/sprinkles.css' +import { useIsMobile } from 'nft/hooks' import { ReactNode, useReducer, useRef } from 'react' import { isChainAllowed } from 'utils/switchChain' @@ -55,12 +57,13 @@ const NETWORK_SELECTOR_CHAINS = [ ] interface ChainSwitcherProps { - isMobile?: boolean + leftAlign?: boolean } -export const ChainSwitcher = ({ isMobile }: ChainSwitcherProps) => { +export const ChainSwitcher = ({ leftAlign }: ChainSwitcherProps) => { const { chainId } = useWeb3React() const [isOpen, toggleOpen] = useReducer((s) => !s, false) + const isMobile = useIsMobile() const ref = useRef(null) useOnClickOutside(ref, isOpen ? toggleOpen : undefined) @@ -76,6 +79,25 @@ export const ChainSwitcher = ({ isMobile }: ChainSwitcherProps) => { const isSupported = isChainAllowed(chainId) + const dropdown = ( + + + {NETWORK_SELECTOR_CHAINS.map((chainId: SupportedChainId) => + isSupported ? ( + { + await selectChain(targetChainId) + toggleOpen() + }} + targetChain={chainId} + key={chainId} + /> + ) : null + )} + + + ) + return ( { {!isSupported ? ( <> - + {info?.label ?? 'Unsupported'} ) : ( <> {info.label} - + {info.label} @@ -106,24 +128,7 @@ export const ChainSwitcher = ({ isMobile }: ChainSwitcherProps) => { )} - {isOpen && ( - - - {NETWORK_SELECTOR_CHAINS.map((chainId: SupportedChainId) => - isSupported ? ( - { - await selectChain(targetChainId) - toggleOpen() - }} - targetChain={chainId} - key={chainId} - /> - ) : null - )} - - - )} + {isOpen && (isMobile ? {dropdown} : <>{dropdown})} ) } diff --git a/src/components/NavBar/NavDropdown.css.ts b/src/components/NavBar/NavDropdown.css.ts index a86a4739b1..4b84b26485 100644 --- a/src/components/NavBar/NavDropdown.css.ts +++ b/src/components/NavBar/NavDropdown.css.ts @@ -1,18 +1,25 @@ import { style } from '@vanilla-extract/css' -import { sprinkles } from '../../nft/css/sprinkles.css' +import { breakpoints, sprinkles } from '../../nft/css/sprinkles.css' export const NavDropdown = style([ sprinkles({ - position: 'absolute', + position: { sm: 'fixed', md: 'absolute' }, background: 'lightGray', borderRadius: '12', borderStyle: 'solid', borderColor: 'medGray', borderWidth: '1px', + bottom: { sm: '56', md: 'unset' }, }), { boxShadow: '0px 4px 12px 0px #00000026', zIndex: 10, + '@media': { + [`screen and (max-width: ${breakpoints.sm}px)`]: { + borderBottomLeftRadius: '0', + borderBottomRightRadius: '0', + }, + }, }, ]) diff --git a/src/components/NavBar/NavDropdown.tsx b/src/components/NavBar/NavDropdown.tsx index 7a97b8f462..ff4139ce58 100644 --- a/src/components/NavBar/NavDropdown.tsx +++ b/src/components/NavBar/NavDropdown.tsx @@ -1,4 +1,5 @@ import { Box } from 'nft/components/Box' +import { useIsMobile } from 'nft/hooks' import { ReactNode } from 'react' import * as styles from './NavDropdown.css' @@ -23,13 +24,14 @@ export const NavDropdown = ({ paddingTop, children, }: NavDropdownProps) => { + const isMobile = useIsMobile() return ( { - + diff --git a/src/components/NavBar/SuggestionRow.tsx b/src/components/NavBar/SuggestionRow.tsx index e5ae01c3e4..f2abb59143 100644 --- a/src/components/NavBar/SuggestionRow.tsx +++ b/src/components/NavBar/SuggestionRow.tsx @@ -4,7 +4,6 @@ import { Box } from 'nft/components/Box' import { Column, Row } from 'nft/components/Flex' import { vars } from 'nft/css/sprinkles.css' import { useSearchHistory } from 'nft/hooks' -// import { fetchSearchCollections, fetchTrendingCollections } from 'nft/queries' import { FungibleToken, GenieCollection } from 'nft/types' import { ethNumberStandardFormatter } from 'nft/utils/currency' import { putCommas } from 'nft/utils/putCommas' diff --git a/src/nft/css/sprinkles.css.ts b/src/nft/css/sprinkles.css.ts index 56e75ab8cc..dbeae6440a 100644 --- a/src/nft/css/sprinkles.css.ts +++ b/src/nft/css/sprinkles.css.ts @@ -112,6 +112,7 @@ const spacing = { '48': '48px', '50': '50px', '52': '52px', + '56': '56px', '60': '60px', '64': '64px', '82': '82px',