|
1 | 1 | import React, { useState } from 'react' |
2 | 2 | import { useWeb3React } from '@web3-react/core' |
3 | | -import { fbt } from 'fbt-runtime' |
4 | 3 |
|
5 | 4 | import Dropdown from 'components/Dropdown' |
6 | 5 | import GetOUSD from 'components/GetOUSD' |
7 | | -import { |
8 | | - isCorrectNetwork, |
9 | | - truncateAddress, |
10 | | - switchEthereumChain, |
11 | | - shortenAddress, |
12 | | -} from 'utils/web3' |
| 6 | +import { isCorrectNetwork, switchEthereumChain } from 'utils/web3' |
13 | 7 |
|
14 | 8 | import withWalletSelectModal from 'hoc/withWalletSelectModal' |
15 | 9 | import analytics from 'utils/analytics' |
16 | 10 |
|
17 | 11 | import Content from './_AccountStatusContent' |
| 12 | +import AccountStatusIndicator from './_AccountStatusIndicator' |
18 | 13 |
|
19 | 14 | const AccountStatusDropdown = ({ className, showLogin, dapp }) => { |
20 | 15 | const { active, account, chainId } = useWeb3React() |
@@ -58,22 +53,13 @@ const AccountStatusDropdown = ({ className, showLogin, dapp }) => { |
58 | 53 | trackSource="Account dropdown" |
59 | 54 | /> |
60 | 55 | )} |
61 | | - {/* What causes !active && account? */} |
62 | | - {dapp && !active && account && <div className="dot" />} |
63 | | - {active && !correctNetwork && ( |
64 | | - <> |
65 | | - <div className="dot yellow" /> |
66 | | - <div className="address"> |
67 | | - {fbt('Wrong network', 'Wrong network')} |
68 | | - </div> |
69 | | - </> |
70 | | - )} |
71 | | - {dapp && active && correctNetwork && ( |
72 | | - <> |
73 | | - <div className="dot green" /> |
74 | | - <div className="address">{shortenAddress(account)}</div> |
75 | | - </> |
76 | | - )} |
| 56 | + <AccountStatusIndicator |
| 57 | + active={active} |
| 58 | + correctNetwork={correctNetwork} |
| 59 | + account={account} |
| 60 | + dapp={dapp} |
| 61 | + withAddress |
| 62 | + /> |
77 | 63 | </a> |
78 | 64 | </Dropdown> |
79 | 65 | <style jsx>{` |
@@ -139,34 +125,6 @@ const AccountStatusDropdown = ({ className, showLogin, dapp }) => { |
139 | 125 | color: inherit; |
140 | 126 | text-decoration: none; |
141 | 127 | } |
142 | | -
|
143 | | - .dot { |
144 | | - width: 10px; |
145 | | - height: 10px; |
146 | | - margin-left: 10px; |
147 | | - border-radius: 5px; |
148 | | - background-color: #ed2a28; |
149 | | - } |
150 | | -
|
151 | | - .dot.green { |
152 | | - background-color: #00d592; |
153 | | - } |
154 | | -
|
155 | | - .dot.green.yellow { |
156 | | - background-color: #ffce45; |
157 | | - } |
158 | | -
|
159 | | - .dot.big { |
160 | | - width: 16px; |
161 | | - height: 16px; |
162 | | - border-radius: 8px; |
163 | | - margin-right: 12px; |
164 | | - } |
165 | | -
|
166 | | - .dot.yellow.big, |
167 | | - .dot.green.big { |
168 | | - margin-left: 0px; |
169 | | - } |
170 | 128 | `}</style> |
171 | 129 | </> |
172 | 130 | ) |
|
0 commit comments