fix(token-details): make breakpoints more consistent and use only theme.breakpoint values (#4836)
* fix(token-details): make breakpoints more consistent and use only theme.breakpoint values * feat(token-details): design patch for mobile swap button footer * render mobile balance footer w/ only swap button when user is disconnected * don't render BalanceSummary if no balances are provided * full width swap button footer until breakpoints.lg
This commit is contained in:
parent
c9ead63ff6
commit
54f831ede4
@ -91,6 +91,7 @@ export default function BalanceSummary({ tokenAmount, nativeCurrencyAmount, isNa
|
|||||||
tokenAmount.currency.address.toLowerCase() === nativeCurrencyAmount.currency.wrapped.address.toLowerCase()
|
tokenAmount.currency.address.toLowerCase() === nativeCurrencyAmount.currency.wrapped.address.toLowerCase()
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
(!tokenAmount && !nativeCurrencyAmount) ||
|
||||||
(!tokenAmount && !tokenIsWrappedNative && !isNative) ||
|
(!tokenAmount && !tokenIsWrappedNative && !isNative) ||
|
||||||
(!isNative && !tokenIsWrappedNative && tokenAmount?.equalTo(0)) ||
|
(!isNative && !tokenIsWrappedNative && tokenAmount?.equalTo(0)) ||
|
||||||
(isNative && tokenAmount?.equalTo(0) && nativeCurrencyAmount?.equalTo(0))
|
(isNative && tokenAmount?.equalTo(0) && nativeCurrencyAmount?.equalTo(0))
|
||||||
@ -130,8 +131,8 @@ export default function BalanceSummary({ tokenAmount, nativeCurrencyAmount, isNa
|
|||||||
<BalancesCard>
|
<BalancesCard>
|
||||||
<TotalBalanceSection>
|
<TotalBalanceSection>
|
||||||
<Trans>Your balance</Trans>
|
<Trans>Your balance</Trans>
|
||||||
{currencies.map((props) => (
|
{currencies.map((props, i) => (
|
||||||
<BalanceRow {...props} key={props.currency.wrapped.address} />
|
<BalanceRow {...props} key={props.currency.wrapped.address + i} />
|
||||||
))}
|
))}
|
||||||
</TotalBalanceSection>
|
</TotalBalanceSection>
|
||||||
</BalancesCard>
|
</BalancesCard>
|
||||||
|
@ -1,85 +1,81 @@
|
|||||||
import { Trans } from '@lingui/macro'
|
import { Trans } from '@lingui/macro'
|
||||||
import { formatToDecimal } from 'analytics/utils'
|
import { formatToDecimal } from 'analytics/utils'
|
||||||
import { useStablecoinValue } from 'hooks/useStablecoinPrice'
|
import { useStablecoinValue } from 'hooks/useStablecoinPrice'
|
||||||
import { Link } from 'react-router-dom'
|
|
||||||
import styled from 'styled-components/macro'
|
import styled from 'styled-components/macro'
|
||||||
|
import { StyledInternalLink } from 'theme'
|
||||||
import { currencyAmountToPreciseFloat, formatDollar } from 'utils/formatDollarAmt'
|
import { currencyAmountToPreciseFloat, formatDollar } from 'utils/formatDollarAmt'
|
||||||
|
|
||||||
import { SMALLEST_MOBILE_MEDIA_BREAKPOINT } from '../constants'
|
|
||||||
import { BalanceSummaryProps } from './BalanceSummary'
|
import { BalanceSummaryProps } from './BalanceSummary'
|
||||||
|
|
||||||
const Wrapper = styled.div`
|
const Wrapper = styled.div`
|
||||||
height: fit-content;
|
align-content: center;
|
||||||
|
align-items: center;
|
||||||
border: 1px solid ${({ theme }) => theme.backgroundOutline};
|
border: 1px solid ${({ theme }) => theme.backgroundOutline};
|
||||||
background-color: ${({ theme }) => theme.backgroundSurface};
|
background-color: ${({ theme }) => theme.backgroundSurface};
|
||||||
border-radius: 20px 20px 0px 0px;
|
border-radius: 20px 20px 0px 0px;
|
||||||
|
bottom: 56px;
|
||||||
|
color: ${({ theme }) => theme.textSecondary};
|
||||||
display: flex;
|
display: flex;
|
||||||
padding: 12px 16px;
|
flex-direction: row;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
line-height: 20px;
|
height: fit-content;
|
||||||
width: 100%;
|
justify-content: space-between;
|
||||||
color: ${({ theme }) => theme.textSecondary};
|
|
||||||
position: fixed;
|
|
||||||
left: 0;
|
left: 0;
|
||||||
bottom: 56px;
|
line-height: 20px;
|
||||||
display: flex;
|
padding: 12px 16px;
|
||||||
flex-direction: column;
|
position: fixed;
|
||||||
align-content: center;
|
width: 100%;
|
||||||
|
|
||||||
// 768 hardcoded to match NFT-redesign navbar breakpoints
|
@media screen and (min-width: ${({ theme }) => theme.breakpoint.md}px) {
|
||||||
// src/nft/css/sprinkles.css.ts
|
bottom: 0px;
|
||||||
// change to match theme breakpoints when this navbar is updated
|
}
|
||||||
@media screen and (min-width: 768px) {
|
@media screen and (min-width: ${({ theme }) => theme.breakpoint.lg}px) {
|
||||||
display: none !important;
|
display: none;
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
const BalanceValue = styled.div`
|
const BalanceValue = styled.div`
|
||||||
|
color: ${({ theme }) => theme.textPrimary};
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
line-height: 28px;
|
line-height: 28px;
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
`
|
`
|
||||||
const BalanceTotal = styled.div`
|
const BalanceTotal = styled.div`
|
||||||
|
align-items: center;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
color: ${({ theme }) => theme.textPrimary};
|
|
||||||
`
|
`
|
||||||
const BalanceInfo = styled.div`
|
const BalanceInfo = styled.div`
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: flex-start;
|
flex: 10 1 auto;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
justify-content: flex-start;
|
||||||
`
|
`
|
||||||
const FiatValue = styled.span`
|
const FiatValue = styled.span`
|
||||||
display: flex;
|
|
||||||
align-self: flex-end;
|
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
line-height: 24px;
|
line-height: 16px;
|
||||||
|
|
||||||
@media only screen and (max-width: ${SMALLEST_MOBILE_MEDIA_BREAKPOINT}) {
|
@media screen and (min-width: ${({ theme }) => theme.breakpoint.sm}px) {
|
||||||
line-height: 16px;
|
line-height: 24px;
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
const SwapButton = styled.button`
|
const SwapButton = styled(StyledInternalLink)`
|
||||||
background-color: ${({ theme }) => theme.accentAction};
|
background-color: ${({ theme }) => theme.accentAction};
|
||||||
border-radius: 12px;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
border: none;
|
border: none;
|
||||||
|
border-radius: 12px;
|
||||||
color: ${({ theme }) => theme.accentTextLightPrimary};
|
color: ${({ theme }) => theme.accentTextLightPrimary};
|
||||||
padding: 12px 16px;
|
|
||||||
width: 120px;
|
|
||||||
height: 44px;
|
|
||||||
font-size: 16px;
|
|
||||||
font-weight: 600;
|
|
||||||
justify-content: center;
|
|
||||||
`
|
|
||||||
const TotalBalancesSection = styled.div`
|
|
||||||
display: flex;
|
display: flex;
|
||||||
color: ${({ theme }) => theme.textSecondary};
|
flex: 1 1 auto;
|
||||||
justify-content: space-between;
|
padding: 12px 16px;
|
||||||
align-items: center;
|
font-size: 1em;
|
||||||
|
font-weight: 600;
|
||||||
|
height: 44px;
|
||||||
|
justify-content: center;
|
||||||
|
margin: auto;
|
||||||
|
max-width: 100vw;
|
||||||
`
|
`
|
||||||
|
|
||||||
export default function MobileBalanceSummaryFooter({
|
export default function MobileBalanceSummaryFooter({
|
||||||
@ -101,43 +97,35 @@ export default function MobileBalanceSummaryFooter({
|
|||||||
: undefined
|
: undefined
|
||||||
const nativeBalanceUsd = nativeBalanceUsdValue ? currencyAmountToPreciseFloat(nativeBalanceUsdValue) : undefined
|
const nativeBalanceUsd = nativeBalanceUsdValue ? currencyAmountToPreciseFloat(nativeBalanceUsdValue) : undefined
|
||||||
|
|
||||||
if ((!tokenAmount && !nativeCurrencyAmount) || (nativeCurrencyAmount?.equalTo(0) && tokenAmount?.equalTo(0))) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
const outputTokenAddress = tokenAmount?.currency.address ?? nativeCurrencyAmount?.wrapped.currency.address
|
const outputTokenAddress = tokenAmount?.currency.address ?? nativeCurrencyAmount?.wrapped.currency.address
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Wrapper>
|
<Wrapper>
|
||||||
<TotalBalancesSection>
|
{Boolean(formattedBalance !== undefined && !isNative && tokenAmount?.greaterThan(0)) && (
|
||||||
{Boolean(formattedBalance !== undefined && !isNative) && (
|
<BalanceInfo>
|
||||||
<BalanceInfo>
|
<Trans>Your {tokenAmount?.currency?.symbol} balance</Trans>
|
||||||
<Trans>Your {tokenAmount?.currency?.symbol} balance</Trans>
|
<BalanceTotal>
|
||||||
<BalanceTotal>
|
<BalanceValue>
|
||||||
<BalanceValue>
|
{formattedBalance} {tokenAmount?.currency?.symbol}
|
||||||
{formattedBalance} {tokenAmount?.currency?.symbol}
|
</BalanceValue>
|
||||||
</BalanceValue>
|
<FiatValue>{formatDollar(balanceUsd, true)}</FiatValue>
|
||||||
<FiatValue>{formatDollar(balanceUsd, true)}</FiatValue>
|
</BalanceTotal>
|
||||||
</BalanceTotal>
|
</BalanceInfo>
|
||||||
</BalanceInfo>
|
)}
|
||||||
)}
|
{Boolean(isNative && nativeCurrencyAmount?.greaterThan(0)) && (
|
||||||
{isNative && (
|
<BalanceInfo>
|
||||||
<BalanceInfo>
|
<Trans>Your {nativeCurrencyAmount?.currency?.symbol} balance</Trans>
|
||||||
<Trans>Your {nativeCurrencyAmount?.currency?.symbol} balance</Trans>
|
<BalanceTotal>
|
||||||
<BalanceTotal>
|
<BalanceValue>
|
||||||
<BalanceValue>
|
{formattedNativeBalance} {nativeCurrencyAmount?.currency?.symbol}
|
||||||
{formattedNativeBalance} {nativeCurrencyAmount?.currency?.symbol}
|
</BalanceValue>
|
||||||
</BalanceValue>
|
<FiatValue>{formatDollar(nativeBalanceUsd, true)}</FiatValue>
|
||||||
<FiatValue>{formatDollar(nativeBalanceUsd, true)}</FiatValue>
|
</BalanceTotal>
|
||||||
</BalanceTotal>
|
</BalanceInfo>
|
||||||
</BalanceInfo>
|
)}
|
||||||
)}
|
<SwapButton to={`/swap?outputCurrency=${outputTokenAddress}`}>
|
||||||
<Link to={`/swap?outputCurrency=${outputTokenAddress}`}>
|
<Trans>Swap</Trans>
|
||||||
<SwapButton>
|
</SwapButton>
|
||||||
<Trans>Swap</Trans>
|
|
||||||
</SwapButton>
|
|
||||||
</Link>
|
|
||||||
</TotalBalancesSection>
|
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,5 @@
|
|||||||
import { Token } from '@uniswap/sdk-core'
|
import { Token } from '@uniswap/sdk-core'
|
||||||
import { useWeb3React } from '@web3-react/core'
|
import { useWeb3React } from '@web3-react/core'
|
||||||
import {
|
|
||||||
LARGE_MEDIA_BREAKPOINT,
|
|
||||||
MAX_WIDTH_MEDIA_BREAKPOINT,
|
|
||||||
MOBILE_MEDIA_BREAKPOINT,
|
|
||||||
SMALL_MEDIA_BREAKPOINT,
|
|
||||||
} from 'components/Tokens/constants'
|
|
||||||
import { filterTimeAtom } from 'components/Tokens/state'
|
import { filterTimeAtom } from 'components/Tokens/state'
|
||||||
import { AboutSection } from 'components/Tokens/TokenDetails/About'
|
import { AboutSection } from 'components/Tokens/TokenDetails/About'
|
||||||
import AddressSection from 'components/Tokens/TokenDetails/AddressSection'
|
import AddressSection from 'components/Tokens/TokenDetails/AddressSection'
|
||||||
@ -39,36 +33,21 @@ const Hr = styled.hr`
|
|||||||
`
|
`
|
||||||
export const TokenDetailsLayout = styled.div`
|
export const TokenDetailsLayout = styled.div`
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 60px;
|
padding: 0 8px;
|
||||||
padding: 68px 20px;
|
|
||||||
width: 100%;
|
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
@media only screen and (max-width: ${MAX_WIDTH_MEDIA_BREAKPOINT}) {
|
@media screen and (min-width: ${({ theme }) => theme.breakpoint.sm}px) {
|
||||||
|
gap: 16px;
|
||||||
|
padding: 0 16px;
|
||||||
|
}
|
||||||
|
@media screen and (min-width: ${({ theme }) => theme.breakpoint.md}px) {
|
||||||
|
gap: 20px;
|
||||||
|
padding: 48px 20px;
|
||||||
|
}
|
||||||
|
@media screen and (min-width: ${({ theme }) => theme.breakpoint.xl}px) {
|
||||||
gap: 40px;
|
gap: 40px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media only screen and (max-width: ${({ theme }) => `${theme.breakpoint.md}px`}) {
|
|
||||||
padding-top: 48px;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media only screen and (max-width: ${({ theme }) => `${theme.breakpoint.sm}px`}) {
|
|
||||||
padding-top: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media only screen and (max-width: ${LARGE_MEDIA_BREAKPOINT}) {
|
|
||||||
gap: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media only screen and (max-width: ${SMALL_MEDIA_BREAKPOINT}) {
|
|
||||||
padding-left: 16px;
|
|
||||||
padding-right: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media only screen and (max-width: ${MOBILE_MEDIA_BREAKPOINT}) {
|
|
||||||
padding-left: 8px;
|
|
||||||
padding-right: 8px;
|
|
||||||
}
|
|
||||||
`
|
`
|
||||||
export const LeftPanel = styled.div`
|
export const LeftPanel = styled.div`
|
||||||
flex: 1;
|
flex: 1;
|
||||||
@ -76,13 +55,13 @@ export const LeftPanel = styled.div`
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
`
|
`
|
||||||
export const RightPanel = styled.div`
|
export const RightPanel = styled.div`
|
||||||
display: flex;
|
display: none;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 20px;
|
gap: 20px;
|
||||||
width: ${WIDGET_WIDTH}px;
|
width: ${WIDGET_WIDTH}px;
|
||||||
|
|
||||||
@media only screen and (max-width: ${LARGE_MEDIA_BREAKPOINT}) {
|
@media screen and (min-width: ${({ theme }) => theme.breakpoint.lg}px) {
|
||||||
display: none;
|
display: flex;
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user