|
| 1 | +import { ChainId, WETH } from '@uniswap/sdk' |
1 | 2 | import React from 'react'
|
| 3 | +import { isMobile } from 'react-device-detect' |
2 | 4 | import { Link as HistoryLink } from 'react-router-dom'
|
| 5 | +import { Text } from 'rebass' |
3 | 6 |
|
4 | 7 | import styled from 'styled-components'
|
5 |
| -import { useTokenBalanceTreatingWETHasETH } from '../../state/wallet/hooks' |
6 |
| - |
7 |
| -import Row from '../Row' |
8 |
| -import Menu from '../Menu' |
9 |
| -import Web3Status from '../Web3Status' |
10 |
| - |
11 |
| -import { ExternalLink, StyledInternalLink } from '../../theme' |
12 |
| -import { Text } from 'rebass' |
13 |
| -import { WETH, ChainId } from '@uniswap/sdk' |
14 |
| -import { isMobile } from 'react-device-detect' |
15 |
| -import { YellowCard } from '../Card' |
16 |
| -import { useActiveWeb3React } from '../../hooks' |
17 |
| -import { useDarkModeManager } from '../../state/user/hooks' |
18 | 8 |
|
19 | 9 | import Logo from '../../assets/svg/logo.svg'
|
20 |
| -import Wordmark from '../../assets/svg/wordmark.svg' |
21 | 10 | import LogoDark from '../../assets/svg/logo_white.svg'
|
| 11 | +import Wordmark from '../../assets/svg/wordmark.svg' |
22 | 12 | import WordmarkDark from '../../assets/svg/wordmark_white.svg'
|
| 13 | +import { useActiveWeb3React } from '../../hooks' |
| 14 | +import { useDarkModeManager } from '../../state/user/hooks' |
| 15 | +import { useTokenBalanceTreatingWETHasETH } from '../../state/wallet/hooks' |
| 16 | + |
| 17 | +import { ExternalLink, StyledInternalLink } from '../../theme' |
| 18 | +import { YellowCard } from '../Card' |
23 | 19 | import { AutoColumn } from '../Column'
|
24 |
| -import { RowBetween } from '../Row' |
| 20 | +import Menu from '../Menu' |
| 21 | + |
| 22 | +import Row, { RowBetween } from '../Row' |
| 23 | +import Web3Status from '../Web3Status' |
| 24 | +import { VersionSwitch } from './VersionSwitch' |
25 | 25 |
|
26 | 26 | const HeaderFrame = styled.div`
|
27 | 27 | display: flex;
|
@@ -122,33 +122,13 @@ const MigrateBanner = styled(AutoColumn)`
|
122 | 122 | `};
|
123 | 123 | `
|
124 | 124 |
|
125 |
| -const VersionLabel = styled.span<{ isV2?: boolean }>` |
126 |
| - padding: ${({ isV2 }) => (isV2 ? '0.15rem 0.5rem 0.16rem 0.45rem' : '0.15rem 0.5rem 0.16rem 0.35rem')}; |
127 |
| - border-radius: 14px; |
128 |
| - background: ${({ theme, isV2 }) => (isV2 ? theme.primary1 : 'none')}; |
129 |
| - color: ${({ theme, isV2 }) => (isV2 ? theme.white : theme.primary1)}; |
130 |
| - font-size: 0.825rem; |
131 |
| - font-weight: 400; |
132 |
| - :hover { |
133 |
| - user-select: ${({ isV2 }) => (isV2 ? 'none' : 'initial')}; |
134 |
| - background: ${({ theme, isV2 }) => (isV2 ? theme.primary1 : 'none')}; |
135 |
| - color: ${({ theme, isV2 }) => (isV2 ? theme.white : theme.primary3)}; |
136 |
| - } |
137 |
| -` |
138 |
| - |
139 |
| -const VersionToggle = styled.a` |
140 |
| - border-radius: 16px; |
141 |
| - background: ${({ theme }) => theme.primary5}; |
142 |
| - border: 1px solid ${({ theme }) => theme.primary4}; |
143 |
| - color: ${({ theme }) => theme.primary1}; |
144 |
| - display: flex; |
145 |
| - width: fit-content; |
146 |
| - cursor: pointer; |
147 |
| - text-decoration: none; |
148 |
| - :hover { |
149 |
| - text-decoration: none; |
150 |
| - } |
151 |
| -` |
| 125 | +const NETWORK_LABELS: { [chainId in ChainId]: string | null } = { |
| 126 | + [ChainId.MAINNET]: null, |
| 127 | + [ChainId.RINKEBY]: 'Rinkeby', |
| 128 | + [ChainId.ROPSTEN]: 'Ropsten', |
| 129 | + [ChainId.GÖRLI]: 'Görli', |
| 130 | + [ChainId.KOVAN]: 'Kovan' |
| 131 | +} |
152 | 132 |
|
153 | 133 | export default function Header() {
|
154 | 134 | const { account, chainId } = useActiveWeb3React()
|
@@ -187,21 +167,11 @@ export default function Header() {
|
187 | 167 | </TitleText>
|
188 | 168 | )}
|
189 | 169 | </Title>
|
190 |
| - <TestnetWrapper style={{ pointerEvents: 'auto' }}> |
191 |
| - {!isMobile && ( |
192 |
| - <VersionToggle target="_self" href="https://v1.uniswap.exchange"> |
193 |
| - <VersionLabel isV2={true}>V2</VersionLabel> |
194 |
| - <VersionLabel isV2={false}>V1</VersionLabel> |
195 |
| - </VersionToggle> |
196 |
| - )} |
197 |
| - </TestnetWrapper> |
| 170 | + <TestnetWrapper style={{ pointerEvents: 'auto' }}>{!isMobile && <VersionSwitch />}</TestnetWrapper> |
198 | 171 | </HeaderElement>
|
199 | 172 | <HeaderElement>
|
200 | 173 | <TestnetWrapper>
|
201 |
| - {!isMobile && chainId === ChainId.ROPSTEN && <NetworkCard>Ropsten</NetworkCard>} |
202 |
| - {!isMobile && chainId === ChainId.RINKEBY && <NetworkCard>Rinkeby</NetworkCard>} |
203 |
| - {!isMobile && chainId === ChainId.GÖRLI && <NetworkCard>Görli</NetworkCard>} |
204 |
| - {!isMobile && chainId === ChainId.KOVAN && <NetworkCard>Kovan</NetworkCard>} |
| 174 | + {!isMobile && NETWORK_LABELS[chainId] && <NetworkCard>{NETWORK_LABELS[chainId]}</NetworkCard>} |
205 | 175 | </TestnetWrapper>
|
206 | 176 | <AccountElement active={!!account} style={{ pointerEvents: 'auto' }}>
|
207 | 177 | {account && userEthBalance ? (
|
|
0 commit comments