feat: NavBar I18N (#4507)

* wrap tabs and searchbar

* wrap chain switcher and fix right align bug

* undo translate chains

* replace t with i18n

* revert i18n

Co-authored-by: Charlie <charlie@uniswap.org>
This commit is contained in:
Charles Bachmeier 2022-08-26 09:22:05 -07:00 committed by GitHub
parent 65566faf17
commit 28a6ea7e1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 49 additions and 24 deletions

@ -79,7 +79,7 @@ export const ChainSwitcher = ({ leftAlign }: ChainSwitcherProps) => {
const isSupported = !!info const isSupported = !!info
const dropdown = ( const dropdown = (
<NavDropdown top="56" left="0"> <NavDropdown top="56" left={leftAlign ? '0' : 'auto'} right={leftAlign ? 'auto' : '0'}>
<Column marginX="8"> <Column marginX="8">
{NETWORK_SELECTOR_CHAINS.map((chainId: SupportedChainId) => ( {NETWORK_SELECTOR_CHAINS.map((chainId: SupportedChainId) => (
<ChainRow <ChainRow

@ -1,3 +1,4 @@
import { Trans } from '@lingui/macro'
import FeatureFlagModal from 'components/FeatureFlagModal/FeatureFlagModal' import FeatureFlagModal from 'components/FeatureFlagModal/FeatureFlagModal'
import { PrivacyPolicyModal } from 'components/PrivacyPolicy' import { PrivacyPolicyModal } from 'components/PrivacyPolicy'
import { NftVariant, useNftFlag } from 'featureFlags/flags/nft' import { NftVariant, useNftFlag } from 'featureFlags/flags/nft'
@ -137,20 +138,26 @@ export const MenuDropdown = () => {
<Icon> <Icon>
<ThinTagIcon width={24} height={24} /> <ThinTagIcon width={24} height={24} />
</Icon> </Icon>
<PrimaryMenuRow.Text>Sell NFTs</PrimaryMenuRow.Text> <PrimaryMenuRow.Text>
<Trans>Sell NFTs</Trans>
</PrimaryMenuRow.Text>
</PrimaryMenuRow> </PrimaryMenuRow>
)} )}
<PrimaryMenuRow to="/vote" close={toggleOpen}> <PrimaryMenuRow to="/vote" close={toggleOpen}>
<Icon> <Icon>
<GovernanceIcon width={24} height={24} /> <GovernanceIcon width={24} height={24} />
</Icon> </Icon>
<PrimaryMenuRow.Text>Vote in governance</PrimaryMenuRow.Text> <PrimaryMenuRow.Text>
<Trans>Vote in governance</Trans>
</PrimaryMenuRow.Text>
</PrimaryMenuRow> </PrimaryMenuRow>
<PrimaryMenuRow href="https://info.uniswap.org/#/"> <PrimaryMenuRow href="https://info.uniswap.org/#/">
<Icon> <Icon>
<BarChartIcon width={24} height={24} /> <BarChartIcon width={24} height={24} />
</Icon> </Icon>
<PrimaryMenuRow.Text>View token analytics</PrimaryMenuRow.Text> <PrimaryMenuRow.Text>
<Trans>View token analytics</Trans>
</PrimaryMenuRow.Text>
</PrimaryMenuRow> </PrimaryMenuRow>
</Column> </Column>
<Separator /> <Separator />
@ -161,16 +168,24 @@ export const MenuDropdown = () => {
alignItems={{ sm: 'center', md: 'flex-start' }} alignItems={{ sm: 'center', md: 'flex-start' }}
paddingX="8" paddingX="8"
> >
<SecondaryLinkedText href="https://help.uniswap.org/en/">Help center </SecondaryLinkedText> <SecondaryLinkedText href="https://help.uniswap.org/en/">
<SecondaryLinkedText href="https://docs.uniswap.org/">Documentation </SecondaryLinkedText> <Trans>Help center</Trans>
</SecondaryLinkedText>
<SecondaryLinkedText href="https://docs.uniswap.org/">
<Trans>Documentation</Trans>
</SecondaryLinkedText>
<SecondaryLinkedText <SecondaryLinkedText
onClick={() => { onClick={() => {
toggleOpen() toggleOpen()
togglePrivacyPolicy() togglePrivacyPolicy()
}} }}
>{`Legal & Privacy ↗`}</SecondaryLinkedText> >
<Trans>Legal & Privacy</Trans>
</SecondaryLinkedText>
{(isDevelopmentEnv() || isStagingEnv()) && ( {(isDevelopmentEnv() || isStagingEnv()) && (
<SecondaryLinkedText onClick={openFeatureFlagsModal}>{`Feature Flags`}</SecondaryLinkedText> <SecondaryLinkedText onClick={openFeatureFlagsModal}>
<Trans>Feature Flags</Trans>
</SecondaryLinkedText>
)} )}
</Box> </Box>
<IconRow> <IconRow>

@ -1,3 +1,4 @@
import { Trans } from '@lingui/macro'
import Web3Status from 'components/Web3Status' import Web3Status from 'components/Web3Status'
import { NftVariant, useNftFlag } from 'featureFlags/flags/nft' import { NftVariant, useNftFlag } from 'featureFlags/flags/nft'
import { ReactNode } from 'react' import { ReactNode } from 'react'
@ -45,18 +46,18 @@ const PageTabs = () => {
return ( return (
<> <>
<MenuItem href="/swap" isActive={pathname.startsWith('/swap')}> <MenuItem href="/swap" isActive={pathname.startsWith('/swap')}>
Swap <Trans>Swap</Trans>
</MenuItem> </MenuItem>
<MenuItem href="/tokens" isActive={pathname.startsWith('/tokens')}> <MenuItem href="/tokens" isActive={pathname.startsWith('/tokens')}>
Tokens <Trans>Tokens</Trans>
</MenuItem> </MenuItem>
{nftFlag === NftVariant.Enabled && ( {nftFlag === NftVariant.Enabled && (
<MenuItem href="/nfts" isActive={pathname.startsWith('/nfts')}> <MenuItem href="/nfts" isActive={pathname.startsWith('/nfts')}>
NFTs <Trans>NFTs</Trans>
</MenuItem> </MenuItem>
)} )}
<MenuItem href="/pool" id={'pool-nav-link'} isActive={isPoolActive}> <MenuItem href="/pool" id={'pool-nav-link'} isActive={isPoolActive}>
Pool <Trans>Pool</Trans>
</MenuItem> </MenuItem>
</> </>
) )

@ -1,3 +1,5 @@
// eslint-disable-next-line no-restricted-imports
import { t, Trans } from '@lingui/macro'
import clsx from 'clsx' import clsx from 'clsx'
import { NftVariant, useNftFlag } from 'featureFlags/flags/nft' import { NftVariant, useNftFlag } from 'featureFlags/flags/nft'
import useDebounce from 'hooks/useDebounce' import useDebounce from 'hooks/useDebounce'
@ -31,7 +33,7 @@ import { CollectionRow, SkeletonRow, TokenRow } from './SuggestionRow'
interface SearchBarDropdownSectionProps { interface SearchBarDropdownSectionProps {
toggleOpen: () => void toggleOpen: () => void
suggestions: (GenieCollection | FungibleToken)[] suggestions: (GenieCollection | FungibleToken)[]
header: string header: JSX.Element
headerIcon?: JSX.Element headerIcon?: JSX.Element
hoveredIndex: number | undefined hoveredIndex: number | undefined
startingIndex: number startingIndex: number
@ -105,10 +107,12 @@ export const SearchBarDropdown = ({ toggleOpen, tokens, collections, hasInput }:
setHoveredIndex={setHoveredIndex} setHoveredIndex={setHoveredIndex}
toggleOpen={toggleOpen} toggleOpen={toggleOpen}
suggestions={tokens} suggestions={tokens}
header={'Tokens'} header={<Trans>Tokens</Trans>}
/> />
) : ( ) : (
<Box className={styles.notFoundContainer}>No tokens found.</Box> <Box className={styles.notFoundContainer}>
<Trans>No tokens found.</Trans>
</Box>
) )
const collectionSearchResults = const collectionSearchResults =
@ -120,7 +124,7 @@ export const SearchBarDropdown = ({ toggleOpen, tokens, collections, hasInput }:
setHoveredIndex={setHoveredIndex} setHoveredIndex={setHoveredIndex}
toggleOpen={toggleOpen} toggleOpen={toggleOpen}
suggestions={collections} suggestions={collections}
header={'NFT Collections'} header={<Trans>NFT Collections</Trans>}
/> />
) : ( ) : (
<Box className={styles.notFoundContainer}>No NFT collections found.</Box> <Box className={styles.notFoundContainer}>No NFT collections found.</Box>
@ -223,7 +227,7 @@ export const SearchBarDropdown = ({ toggleOpen, tokens, collections, hasInput }:
setHoveredIndex={setHoveredIndex} setHoveredIndex={setHoveredIndex}
toggleOpen={toggleOpen} toggleOpen={toggleOpen}
suggestions={searchHistory} suggestions={searchHistory}
header={'Recent searches'} header={<Trans>Recent searches</Trans>}
headerIcon={<ClockIcon />} headerIcon={<ClockIcon />}
/> />
)} )}
@ -234,7 +238,7 @@ export const SearchBarDropdown = ({ toggleOpen, tokens, collections, hasInput }:
setHoveredIndex={setHoveredIndex} setHoveredIndex={setHoveredIndex}
toggleOpen={toggleOpen} toggleOpen={toggleOpen}
suggestions={trendingTokens ?? []} suggestions={trendingTokens ?? []}
header={'Popular tokens'} header={<Trans>Popular tokens</Trans>}
headerIcon={<TrendingArrow />} headerIcon={<TrendingArrow />}
/> />
)} )}
@ -245,7 +249,7 @@ export const SearchBarDropdown = ({ toggleOpen, tokens, collections, hasInput }:
setHoveredIndex={setHoveredIndex} setHoveredIndex={setHoveredIndex}
toggleOpen={toggleOpen} toggleOpen={toggleOpen}
suggestions={trendingCollections as unknown as GenieCollection[]} suggestions={trendingCollections as unknown as GenieCollection[]}
header={'Popular NFT collections'} header={<Trans>Popular NFT collections</Trans>}
headerIcon={<TrendingArrow />} headerIcon={<TrendingArrow />}
/> />
)} )}
@ -316,6 +320,8 @@ export const SearchBar = () => {
setSearchValue('') setSearchValue('')
}, [pathname]) }, [pathname])
const placeholderText = phase1Flag === NftVariant.Enabled ? t`Search tokens and NFT collections` : t`Search tokens`
return ( return (
<> <>
<Box <Box
@ -345,7 +351,7 @@ export const SearchBar = () => {
</Box> </Box>
<Box <Box
as="input" as="input"
placeholder={`Search tokens${phase1Flag === NftVariant.Enabled ? ' and NFT collections' : ''}`} placeholder={placeholderText}
width={isOpen || phase1Flag === NftVariant.Enabled ? 'full' : '120'} width={isOpen || phase1Flag === NftVariant.Enabled ? 'full' : '120'}
onChange={(event: ChangeEvent<HTMLInputElement>) => { onChange={(event: ChangeEvent<HTMLInputElement>) => {
!isOpen && toggleOpen() !isOpen && toggleOpen()

@ -18,8 +18,12 @@ import styled, { css } from 'styled-components/macro'
import { useOnClickOutside } from '../../hooks/useOnClickOutside' import { useOnClickOutside } from '../../hooks/useOnClickOutside'
import { useHasSocks } from '../../hooks/useSocksBalance' import { useHasSocks } from '../../hooks/useSocksBalance'
import { useModalIsOpen, useToggleWalletDropdown, useToggleWalletModal } from '../../state/application/hooks' import {
import { useCloseModal } from '../../state/application/hooks' useCloseModal,
useModalIsOpen,
useToggleWalletDropdown,
useToggleWalletModal,
} from '../../state/application/hooks'
import { ApplicationModal } from '../../state/application/reducer' import { ApplicationModal } from '../../state/application/reducer'
import { isTransactionRecent, useAllTransactions } from '../../state/transactions/hooks' import { isTransactionRecent, useAllTransactions } from '../../state/transactions/hooks'
import { TransactionDetails } from '../../state/transactions/types' import { TransactionDetails } from '../../state/transactions/types'

@ -2,8 +2,7 @@ import celoCircleLogoUrl from 'assets/images/celoCircle.png'
import ethereumLogoUrl from 'assets/images/ethereum-logo.png' import ethereumLogoUrl from 'assets/images/ethereum-logo.png'
import optimismCircleLogoUrl from 'assets/images/optimismCircle.png' import optimismCircleLogoUrl from 'assets/images/optimismCircle.png'
import polygonCircleLogoUrl from 'assets/images/polygonCircle.png' import polygonCircleLogoUrl from 'assets/images/polygonCircle.png'
import arbitrumLogoUrl from 'assets/svg/arbitrum_logo.svg' import { default as arbitrumCircleLogoUrl, default as arbitrumLogoUrl } from 'assets/svg/arbitrum_logo.svg'
import arbitrumCircleLogoUrl from 'assets/svg/arbitrum_logo.svg'
import celoLogo from 'assets/svg/celo_logo.svg' import celoLogo from 'assets/svg/celo_logo.svg'
import optimismLogoUrl from 'assets/svg/optimistic_ethereum.svg' import optimismLogoUrl from 'assets/svg/optimistic_ethereum.svg'
import polygonMaticLogo from 'assets/svg/polygon-matic-logo.svg' import polygonMaticLogo from 'assets/svg/polygon-matic-logo.svg'