Commit b50e5511 authored by Zach Pomerantz's avatar Zach Pomerantz Committed by GitHub

chore: update loading colors (#3438)

* chore: update loading colors

* fix: loading opacity of 0.6
parent 1efe5e9c
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
stroke="none" stroke="none"
/> />
<circle <circle
id="track"
cx="12" cx="12"
cy="12" cy="12"
r="10" r="10"
......
import { useLingui } from '@lingui/react' import { useLingui } from '@lingui/react'
import { Currency, CurrencyAmount } from '@uniswap/sdk-core' import { Currency, CurrencyAmount } from '@uniswap/sdk-core'
import { useUSDCValue } from 'hooks/useUSDCPrice' import { useUSDCValue } from 'hooks/useUSDCPrice'
import { loadingOpacityCss } from 'lib/css/loading' import { loadingTransitionCss } from 'lib/css/loading'
import { import {
useIsSwapFieldIndependent, useIsSwapFieldIndependent,
useSwapAmount, useSwapAmount,
...@@ -23,7 +23,7 @@ import TokenImg from '../TokenImg' ...@@ -23,7 +23,7 @@ import TokenImg from '../TokenImg'
import TokenInput from './TokenInput' import TokenInput from './TokenInput'
export const USDC = styled(Row)` export const USDC = styled(Row)`
${loadingOpacityCss}; ${loadingTransitionCss};
` `
export const Balance = styled(ThemedText.Body2)<{ focused: boolean }>` export const Balance = styled(ThemedText.Body2)<{ focused: boolean }>`
...@@ -122,7 +122,7 @@ export default function Input({ disabled, focused }: InputProps) { ...@@ -122,7 +122,7 @@ export default function Input({ disabled, focused }: InputProps) {
> >
<ThemedText.Body2 color="secondary" userSelect> <ThemedText.Body2 color="secondary" userSelect>
<Row> <Row>
<USDC $loading={isLoading}>{inputUSDC ? `$${inputUSDC.toFixed(2)}` : '-'}</USDC> <USDC isLoading={isRouteLoading}>{inputUSDC ? `$${inputUSDC.toFixed(2)}` : '-'}</USDC>
{balance && ( {balance && (
<Balance color={balanceColor} focused={focused}> <Balance color={balanceColor} focused={focused}>
Balance: <span>{formatCurrencyAmount(balance, 4, i18n.locale)}</span> Balance: <span>{formatCurrencyAmount(balance, 4, i18n.locale)}</span>
......
...@@ -102,7 +102,7 @@ export default function Output({ disabled, focused, children }: PropsWithChildre ...@@ -102,7 +102,7 @@ export default function Output({ disabled, focused, children }: PropsWithChildre
> >
<ThemedText.Body2 color="secondary" userSelect> <ThemedText.Body2 color="secondary" userSelect>
<Row> <Row>
<USDC gap={0.5} $loading={isLoading}> <USDC gap={0.5} isLoading={isRouteLoading}>
{outputUSDC ? `$${outputUSDC.toFixed(2)}` : '-'} {priceImpact} {outputUSDC ? `$${outputUSDC.toFixed(2)}` : '-'} {priceImpact}
</USDC> </USDC>
{balance && ( {balance && (
......
...@@ -2,7 +2,7 @@ import 'setimmediate' ...@@ -2,7 +2,7 @@ import 'setimmediate'
import { Trans } from '@lingui/macro' import { Trans } from '@lingui/macro'
import { Currency } from '@uniswap/sdk-core' import { Currency } from '@uniswap/sdk-core'
import { loadingOpacityCss } from 'lib/css/loading' import { loadingTransitionCss } from 'lib/css/loading'
import styled, { keyframes, ThemedText } from 'lib/theme' import styled, { keyframes, ThemedText } from 'lib/theme'
import { ReactNode, useCallback, useEffect, useMemo, useRef, useState } from 'react' import { ReactNode, useCallback, useEffect, useMemo, useRef, useState } from 'react'
...@@ -16,7 +16,7 @@ const TokenInputRow = styled(Row)` ...@@ -16,7 +16,7 @@ const TokenInputRow = styled(Row)`
grid-template-columns: 1fr; grid-template-columns: 1fr;
` `
const ValueInput = styled(DecimalInput)<{ $loading: boolean }>` const ValueInput = styled(DecimalInput)`
color: ${({ theme }) => theme.primary}; color: ${({ theme }) => theme.primary};
height: 1em; height: 1em;
...@@ -28,7 +28,7 @@ const ValueInput = styled(DecimalInput)<{ $loading: boolean }>` ...@@ -28,7 +28,7 @@ const ValueInput = styled(DecimalInput)<{ $loading: boolean }>`
color: ${({ theme }) => theme.onHover(theme.secondary)}; color: ${({ theme }) => theme.onHover(theme.secondary)};
} }
${loadingOpacityCss} ${loadingTransitionCss}
` `
const delayedFadeIn = keyframes` const delayedFadeIn = keyframes`
...@@ -108,7 +108,7 @@ export default function TokenInput({ ...@@ -108,7 +108,7 @@ export default function TokenInput({
onFocus={() => setShowMax(hasMax)} onFocus={() => setShowMax(hasMax)}
onChange={onChangeInput} onChange={onChangeInput}
disabled={disabled || !currency} disabled={disabled || !currency}
$loading={Boolean(loading)} isLoading={Boolean(loading)}
ref={input} ref={input}
></ValueInput> ></ValueInput>
</ThemedText.H2> </ThemedText.H2>
......
...@@ -2,9 +2,10 @@ import { Trans } from '@lingui/macro' ...@@ -2,9 +2,10 @@ import { Trans } from '@lingui/macro'
import { Currency, TradeType } from '@uniswap/sdk-core' import { Currency, TradeType } from '@uniswap/sdk-core'
import useUSDCPrice from 'hooks/useUSDCPrice' import useUSDCPrice from 'hooks/useUSDCPrice'
import Tooltip from 'lib/components/Tooltip' import Tooltip from 'lib/components/Tooltip'
import { loadingCss } from 'lib/css/loading'
import { WrapType } from 'lib/hooks/swap/useWrapCallback' import { WrapType } from 'lib/hooks/swap/useWrapCallback'
import { AlertTriangle, Icon, Info, InlineSpinner } from 'lib/icons' import { AlertTriangle, Icon, Info, InlineSpinner } from 'lib/icons'
import { ThemedText } from 'lib/theme' import styled, { ThemedText } from 'lib/theme'
import { ReactNode, useCallback, useMemo, useState } from 'react' import { ReactNode, useCallback, useMemo, useState } from 'react'
import { InterfaceTrade } from 'state/routing/types' import { InterfaceTrade } from 'state/routing/types'
...@@ -12,6 +13,11 @@ import { TextButton } from '../../Button' ...@@ -12,6 +13,11 @@ import { TextButton } from '../../Button'
import Row from '../../Row' import Row from '../../Row'
import RoutingDiagram from '../RoutingDiagram' import RoutingDiagram from '../RoutingDiagram'
const Loading = styled.span`
color: ${({ theme }) => theme.secondary};
${loadingCss};
`
interface CaptionProps { interface CaptionProps {
icon?: Icon icon?: Icon
caption: ReactNode caption: ReactNode
...@@ -47,7 +53,16 @@ export function Empty() { ...@@ -47,7 +53,16 @@ export function Empty() {
} }
export function LoadingTrade() { export function LoadingTrade() {
return <Caption icon={InlineSpinner} caption={<Trans>Fetching best price…</Trans>} /> return (
<Caption
icon={InlineSpinner}
caption={
<Loading>
<Trans>Fetching best price…</Trans>
</Loading>
}
/>
)
} }
export function WrapCurrency({ loading, wrapType }: { loading: boolean; wrapType: WrapType.UNWRAP | WrapType.WRAP }) { export function WrapCurrency({ loading, wrapType }: { loading: boolean; wrapType: WrapType.UNWRAP | WrapType.WRAP }) {
......
import { css } from 'lib/theme' import { css } from 'lib/theme'
// need to use $loading as `loading` is a reserved prop export const loadingOpacity = 0.6
export const loadingOpacityCss = css<{ $loading: boolean }>`
filter: ${({ $loading }) => ($loading ? 'grayscale(1)' : 'none')}; export const loadingCss = css`
opacity: ${({ $loading }) => ($loading ? '0.4' : '1')}; filter: grayscale(1);
opacity: ${loadingOpacity};
`
// need to use isLoading as `loading` is a reserved prop
export const loadingTransitionCss = css<{ isLoading: boolean }>`
${({ isLoading }) => isLoading && loadingCss};
transition: opacity 0.2s ease-in-out; transition: opacity 0.2s ease-in-out;
` `
...@@ -6,6 +6,7 @@ import { ReactComponent as InlineSpinnerIcon } from 'lib/assets/svg/inline_spinn ...@@ -6,6 +6,7 @@ import { ReactComponent as InlineSpinnerIcon } from 'lib/assets/svg/inline_spinn
import { ReactComponent as LogoIcon } from 'lib/assets/svg/logo.svg' import { ReactComponent as LogoIcon } from 'lib/assets/svg/logo.svg'
import { ReactComponent as SpinnerIcon } from 'lib/assets/svg/spinner.svg' import { ReactComponent as SpinnerIcon } from 'lib/assets/svg/spinner.svg'
import { ReactComponent as WalletIcon } from 'lib/assets/svg/wallet.svg' import { ReactComponent as WalletIcon } from 'lib/assets/svg/wallet.svg'
import { loadingCss } from 'lib/css/loading'
import styled, { Color, css, keyframes } from 'lib/theme' import styled, { Color, css, keyframes } from 'lib/theme'
import { FunctionComponent, SVGProps } from 'react' import { FunctionComponent, SVGProps } from 'react'
/* eslint-disable no-restricted-imports */ /* eslint-disable no-restricted-imports */
...@@ -146,7 +147,10 @@ export const Spinner = styled(icon(SpinnerIcon))<{ color?: Color }>` ...@@ -146,7 +147,10 @@ export const Spinner = styled(icon(SpinnerIcon))<{ color?: Color }>`
export const InlineSpinner = styled(icon(InlineSpinnerIcon))<{ color?: Color }>` export const InlineSpinner = styled(icon(InlineSpinnerIcon))<{ color?: Color }>`
animation: ${rotate} 1s cubic-bezier(0.83, 0, 0.17, 1) infinite; animation: ${rotate} 1s cubic-bezier(0.83, 0, 0.17, 1) infinite;
color: ${({ color = 'active', theme }) => theme[color]}; color: ${({ color = 'active', theme }) => theme[color]};
fill: ${({ theme }) => theme.outline}; fill: ${({ color = 'active', theme }) => theme[color]};
stroke: ${({ theme }) => theme.outline};
stroke-linecap: round; #track {
stroke: ${({ theme }) => theme.secondary};
${loadingCss};
}
` `
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment