Commit 09e6d38f authored by Jordan Frankfurt's avatar Jordan Frankfurt Committed by GitHub

feat: bnb network notif badge in search (#6210)

* feat: bnb network notif badge in search

* add chainname check
parent 236a4dc1
...@@ -2,11 +2,14 @@ import { Trans } from '@lingui/macro' ...@@ -2,11 +2,14 @@ import { Trans } from '@lingui/macro'
import { useTrace } from '@uniswap/analytics' import { useTrace } from '@uniswap/analytics'
import { InterfaceSectionName, NavBarSearchTypes } from '@uniswap/analytics-events' import { InterfaceSectionName, NavBarSearchTypes } from '@uniswap/analytics-events'
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import Badge from 'components/Badge'
import { SupportedChainId } from 'constants/chains'
import { useNftGraphqlEnabled } from 'featureFlags/flags/nftlGraphql' import { useNftGraphqlEnabled } from 'featureFlags/flags/nftlGraphql'
import { HistoryDuration, SafetyLevel } from 'graphql/data/__generated__/types-and-hooks' import { HistoryDuration, SafetyLevel } from 'graphql/data/__generated__/types-and-hooks'
import { useTrendingCollections } from 'graphql/data/nft/TrendingCollections' import { useTrendingCollections } from 'graphql/data/nft/TrendingCollections'
import { SearchToken } from 'graphql/data/SearchTokens' import { SearchToken } from 'graphql/data/SearchTokens'
import useTrendingTokens from 'graphql/data/TrendingTokens' import useTrendingTokens from 'graphql/data/TrendingTokens'
import { CHAIN_ID_TO_BACKEND_NAME } from 'graphql/data/util'
import { useIsNftPage } from 'hooks/useIsNftPage' import { useIsNftPage } from 'hooks/useIsNftPage'
import { Box } from 'nft/components/Box' import { Box } from 'nft/components/Box'
import { Column, Row } from 'nft/components/Flex' import { Column, Row } from 'nft/components/Flex'
...@@ -17,7 +20,10 @@ import { formatEthPrice } from 'nft/utils/currency' ...@@ -17,7 +20,10 @@ import { formatEthPrice } from 'nft/utils/currency'
import { ReactNode, useEffect, useMemo, useState } from 'react' import { ReactNode, useEffect, useMemo, useState } from 'react'
import { useQuery } from 'react-query' import { useQuery } from 'react-query'
import { useLocation } from 'react-router-dom' import { useLocation } from 'react-router-dom'
import styled from 'styled-components/macro'
import { ThemedText } from 'theme'
import BnbLogoURI from '../../assets/svg/bnb-logo.svg'
import { ClockIcon, TrendingArrow } from '../../nft/components/icons' import { ClockIcon, TrendingArrow } from '../../nft/components/icons'
import { useRecentlySearchedAssets } from './RecentlySearchedAssets' import { useRecentlySearchedAssets } from './RecentlySearchedAssets'
import * as styles from './SearchBar.css' import * as styles from './SearchBar.css'
...@@ -101,6 +107,24 @@ function isKnownToken(token: SearchToken) { ...@@ -101,6 +107,24 @@ function isKnownToken(token: SearchToken) {
return token.project?.safetyLevel == SafetyLevel.Verified || token.project?.safetyLevel == SafetyLevel.MediumWarning return token.project?.safetyLevel == SafetyLevel.Verified || token.project?.safetyLevel == SafetyLevel.MediumWarning
} }
const BNBLogo = styled.img`
height: 20px;
width: 20px;
margin-right: 8px;
`
const BNBComingSoonBadge = styled(Badge)`
align-items: center;
background-color: ${({ theme }) => theme.backgroundModule};
color: ${({ theme }) => theme.textSecondary};
display: flex;
flex-direction: row;
justify-content: flex-start;
opacity: 1;
padding: 8px;
margin: 16px 16px 4px;
width: calc(100% - 32px);
`
interface SearchBarDropdownProps { interface SearchBarDropdownProps {
toggleOpen: () => void toggleOpen: () => void
tokens: SearchToken[] tokens: SearchToken[]
...@@ -124,6 +148,7 @@ export const SearchBarDropdown = ({ ...@@ -124,6 +148,7 @@ export const SearchBarDropdown = ({
const shortenedHistory = useMemo(() => searchHistory?.slice(0, 2) ?? [...Array<SearchToken>(2)], [searchHistory]) const shortenedHistory = useMemo(() => searchHistory?.slice(0, 2) ?? [...Array<SearchToken>(2)], [searchHistory])
const { pathname } = useLocation() const { pathname } = useLocation()
const { chainId } = useWeb3React()
const isNFTPage = useIsNftPage() const isNFTPage = useIsNftPage()
const isNftGraphqlEnabled = useNftGraphqlEnabled() const isNftGraphqlEnabled = useNftGraphqlEnabled()
const isTokenPage = pathname.includes('/tokens') const isTokenPage = pathname.includes('/tokens')
...@@ -336,10 +361,22 @@ export const SearchBarDropdown = ({ ...@@ -336,10 +361,22 @@ export const SearchBarDropdown = ({
searchHistory, searchHistory,
]) ])
const showBNBComingSoonBadge = Boolean(
chainId !== undefined && chainId === SupportedChainId.BNB && !isLoading && !CHAIN_ID_TO_BACKEND_NAME[chainId]
)
return ( return (
<Box className={styles.searchBarDropdownNft}> <Box className={styles.searchBarDropdownNft}>
<Box opacity={isLoading ? '0.3' : '1'} transition="125"> <Box opacity={isLoading ? '0.3' : '1'} transition="125">
{resultsState} {resultsState}
{showBNBComingSoonBadge && (
<BNBComingSoonBadge>
<BNBLogo src={BnbLogoURI} />
<ThemedText.BodySmall color="textSecondary" fontSize="14px" fontWeight="400" lineHeight="20px">
<Trans>Coming soon: search and explore tokens on BNB Chain</Trans>
</ThemedText.BodySmall>
</BNBComingSoonBadge>
)}
</Box> </Box>
</Box> </Box>
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment