Skip to content

Commit

Permalink
perf: render components on first frame (Uniswap#2404)
Browse files Browse the repository at this point in the history
* fix(nav): render Vote link while awaiting connection

Minimizes layout shift in the normal case.

* perf: inline logo svg

* perf: display connect button for web3 initial state
  • Loading branch information
zzmp authored Sep 20, 2021
1 parent 1a73f51 commit e242fac
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
12 changes: 8 additions & 4 deletions src/components/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { useUserHasSubmittedClaim } from 'state/transactions/hooks'
import { useDarkModeManager } from 'state/user/hooks'
import { useETHBalances } from 'state/wallet/hooks'
import styled from 'styled-components/macro'
import Logo from '../../assets/svg/logo.svg'
import LogoDark from '../../assets/svg/logo_white.svg'
import { ReactComponent as Logo } from '../../assets/svg/logo.svg'
import { ReactComponent as LogoDark } from '../../assets/svg/logo_white.svg'
import { useActiveWeb3React } from '../../hooks/web3'
import { ExternalLink, TYPE } from '../../theme'
import ClaimModal from '../claim/ClaimModal'
Expand Down Expand Up @@ -264,7 +264,11 @@ export default function Header() {
</Modal>
<Title href=".">
<UniIcon>
<img width={'24px'} src={darkMode ? LogoDark : Logo} alt="logo" />
{darkMode ? (
<LogoDark width="24px" height="100%" title="logo" />
) : (
<Logo width="24px" height="100%" title="logo" />
)}
</UniIcon>
</Title>
<HeaderLinks>
Expand All @@ -284,7 +288,7 @@ export default function Header() {
>
<Trans>Pool</Trans>
</StyledNavLink>
{chainId && chainId === SupportedChainId.MAINNET && (
{(!chainId || chainId === SupportedChainId.MAINNET) && (
<StyledNavLink id={`vote-nav-link`} to={'/vote'}>
<Trans>Vote</Trans>
</StyledNavLink>
Expand Down
8 changes: 3 additions & 5 deletions src/components/Web3Status/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,12 @@ export default function Web3Status() {
const pending = sortedRecentTransactions.filter((tx) => !tx.receipt).map((tx) => tx.hash)
const confirmed = sortedRecentTransactions.filter((tx) => tx.receipt).map((tx) => tx.hash)

if (!contextNetwork.active && !active) {
return null
}

return (
<>
<Web3StatusInner />
<WalletModal ENSName={ENSName ?? undefined} pendingTransactions={pending} confirmedTransactions={confirmed} />
{(contextNetwork.active || active) && (
<WalletModal ENSName={ENSName ?? undefined} pendingTransactions={pending} confirmedTransactions={confirmed} />
)}
</>
)
}

0 comments on commit e242fac

Please sign in to comment.