Commit 1d96961f authored by lynn's avatar lynn Committed by GitHub

feat: token selector design update (#4333)

* init

* selected base currency button

* add check icon

* theme background module change

* hover changes

* theme none

* additional padding

* hover default color from phil + feature flag

* checkmark style fixes
parent b38241c6
...@@ -6,6 +6,7 @@ import { AutoColumn } from 'components/Column' ...@@ -6,6 +6,7 @@ import { AutoColumn } from 'components/Column'
import CurrencyLogo from 'components/CurrencyLogo' import CurrencyLogo from 'components/CurrencyLogo'
import { AutoRow } from 'components/Row' import { AutoRow } from 'components/Row'
import { COMMON_BASES } from 'constants/routing' import { COMMON_BASES } from 'constants/routing'
import { Phase0Variant, usePhase0Flag } from 'featureFlags/flags/phase0'
import { useTokenInfoFromActiveList } from 'hooks/useTokenInfoFromActiveList' import { useTokenInfoFromActiveList } from 'hooks/useTokenInfoFromActiveList'
import { Text } from 'rebass' import { Text } from 'rebass'
import styled from 'styled-components/macro' import styled from 'styled-components/macro'
...@@ -17,21 +18,32 @@ const MobileWrapper = styled(AutoColumn)` ...@@ -17,21 +18,32 @@ const MobileWrapper = styled(AutoColumn)`
`}; `};
` `
const BaseWrapper = styled.div<{ disable?: boolean }>` const BaseWrapper = styled.div<{ disable?: boolean; phase0Flag?: boolean }>`
border: 1px solid ${({ theme, disable }) => (disable ? 'transparent' : theme.deprecated_bg3)}; border: 1px solid
border-radius: 10px; ${({ theme, disable, phase0Flag }) =>
disable
? phase0Flag
? theme.accentAction
: theme.none
: phase0Flag
? theme.backgroundOutline
: theme.deprecated_bg3};
border-radius: ${({ phase0Flag }) => (phase0Flag ? '16px' : '10px')};
display: flex; display: flex;
padding: 6px; padding: 6px;
padding-right: 12px;
align-items: center; align-items: center;
:hover { :hover {
cursor: ${({ disable }) => !disable && 'pointer'}; cursor: ${({ disable }) => !disable && 'pointer'};
background-color: ${({ theme, disable }) => !disable && theme.deprecated_bg2}; background-color: ${({ theme, disable, phase0Flag }) =>
(phase0Flag && theme.hoverDefault) || (!disable && theme.deprecated_bg2)};
} }
color: ${({ theme, disable }) => disable && theme.deprecated_text3}; color: ${({ theme, disable, phase0Flag }) => disable && (phase0Flag ? theme.accentAction : theme.deprecated_text3)};
background-color: ${({ theme, disable }) => disable && theme.deprecated_bg3}; background-color: ${({ theme, disable, phase0Flag }) =>
filter: ${({ disable }) => disable && 'grayscale(1)'}; disable && (phase0Flag ? theme.accentActionSoft : theme.deprecated_bg3)};
filter: ${({ disable, phase0Flag }) => disable && !phase0Flag && 'grayscale(1)'};
` `
const formatAnalyticsEventProperties = (currency: Currency, searchQuery: string, isAddressSearch: string | false) => ({ const formatAnalyticsEventProperties = (currency: Currency, searchQuery: string, isAddressSearch: string | false) => ({
...@@ -60,6 +72,8 @@ export default function CommonBases({ ...@@ -60,6 +72,8 @@ export default function CommonBases({
isAddressSearch: string | false isAddressSearch: string | false
}) { }) {
const bases = typeof chainId !== 'undefined' ? COMMON_BASES[chainId] ?? [] : [] const bases = typeof chainId !== 'undefined' ? COMMON_BASES[chainId] ?? [] : []
const phase0Flag = usePhase0Flag()
const phase0FlagEnabled = phase0Flag === Phase0Variant.Enabled
return bases.length > 0 ? ( return bases.length > 0 ? (
<MobileWrapper gap="md"> <MobileWrapper gap="md">
...@@ -80,6 +94,7 @@ export default function CommonBases({ ...@@ -80,6 +94,7 @@ export default function CommonBases({
onKeyPress={(e) => !isSelected && e.key === 'Enter' && onSelect(currency)} onKeyPress={(e) => !isSelected && e.key === 'Enter' && onSelect(currency)}
onClick={() => !isSelected && onSelect(currency)} onClick={() => !isSelected && onSelect(currency)}
disable={isSelected} disable={isSelected}
phase0Flag={phase0FlagEnabled}
key={currencyId(currency)} key={currencyId(currency)}
> >
<CurrencyLogoFromList currency={currency} /> <CurrencyLogoFromList currency={currency} />
......
...@@ -10,6 +10,7 @@ import { checkWarning } from 'constants/tokenSafety' ...@@ -10,6 +10,7 @@ import { checkWarning } from 'constants/tokenSafety'
import { Phase0Variant, usePhase0Flag } from 'featureFlags/flags/phase0' import { Phase0Variant, usePhase0Flag } from 'featureFlags/flags/phase0'
import useTheme from 'hooks/useTheme' import useTheme from 'hooks/useTheme'
import { CSSProperties, MutableRefObject, useCallback, useMemo } from 'react' import { CSSProperties, MutableRefObject, useCallback, useMemo } from 'react'
import { Check } from 'react-feather'
import { FixedSizeList } from 'react-window' import { FixedSizeList } from 'react-window'
import { Text } from 'rebass' import { Text } from 'rebass'
import styled from 'styled-components/macro' import styled from 'styled-components/macro'
...@@ -33,6 +34,13 @@ function currencyKey(currency: Currency): string { ...@@ -33,6 +34,13 @@ function currencyKey(currency: Currency): string {
return currency.isToken ? currency.address : 'ETHER' return currency.isToken ? currency.address : 'ETHER'
} }
const CheckIcon = styled(Check)`
height: 20px;
width: 20px;
margin-left: 4px;
color: ${({ theme }) => theme.accentAction};
`
const StyledBalanceText = styled(Text)` const StyledBalanceText = styled(Text)`
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
...@@ -135,6 +143,7 @@ function CurrencyRow({ ...@@ -135,6 +143,7 @@ function CurrencyRow({
const balance = useCurrencyBalance(account ?? undefined, currency) const balance = useCurrencyBalance(account ?? undefined, currency)
const warning = currency.isNative ? null : checkWarning(currency.address) const warning = currency.isNative ? null : checkWarning(currency.address)
const phase0Flag = usePhase0Flag() const phase0Flag = usePhase0Flag()
const phase0FlagEnabled = phase0Flag === Phase0Variant.Enabled
// only show add or remove buttons if not on selected list // only show add or remove buttons if not on selected list
return ( return (
...@@ -146,6 +155,7 @@ function CurrencyRow({ ...@@ -146,6 +155,7 @@ function CurrencyRow({
> >
<MenuItem <MenuItem
tabIndex={0} tabIndex={0}
phase0Flag={phase0FlagEnabled}
style={style} style={style}
className={`token-item-${key}`} className={`token-item-${key}`}
onKeyPress={(e) => (!isSelected && e.key === 'Enter' ? onSelect() : null)} onKeyPress={(e) => (!isSelected && e.key === 'Enter' ? onSelect() : null)}
...@@ -160,7 +170,7 @@ function CurrencyRow({ ...@@ -160,7 +170,7 @@ function CurrencyRow({
<Row> <Row>
<CurrencyName title={currency.name}>{currency.name}</CurrencyName> <CurrencyName title={currency.name}>{currency.name}</CurrencyName>
{phase0Flag === Phase0Variant.Enabled && <TokenSafetyIcon warning={warning} />} {phase0FlagEnabled && <TokenSafetyIcon warning={warning} />}
</Row> </Row>
<ThemedText.DeprecatedDarkGray ml="0px" fontSize={'12px'} fontWeight={300}> <ThemedText.DeprecatedDarkGray ml="0px" fontSize={'12px'} fontWeight={300}>
{!currency.isNative && !isOnSelectedList && customAdded ? ( {!currency.isNative && !isOnSelectedList && customAdded ? (
...@@ -175,10 +185,18 @@ function CurrencyRow({ ...@@ -175,10 +185,18 @@ function CurrencyRow({
<TokenTags currency={currency} /> <TokenTags currency={currency} />
</RowFixed> </RowFixed>
</Column> </Column>
{showCurrencyAmount && ( {showCurrencyAmount ? (
<RowFixed style={{ justifySelf: 'flex-end' }}> <RowFixed style={{ justifySelf: 'flex-end' }}>
{balance ? <Balance balance={balance} /> : account ? <Loader /> : null} {balance ? <Balance balance={balance} /> : account ? <Loader /> : null}
{phase0FlagEnabled && isSelected && <CheckIcon />}
</RowFixed> </RowFixed>
) : (
phase0FlagEnabled &&
isSelected && (
<RowFixed style={{ justifySelf: 'flex-end' }}>
<CheckIcon />
</RowFixed>
)
)} )}
</MenuItem> </MenuItem>
</TraceEvent> </TraceEvent>
......
...@@ -5,6 +5,7 @@ import { useWeb3React } from '@web3-react/core' ...@@ -5,6 +5,7 @@ import { useWeb3React } from '@web3-react/core'
import { EventName, ModalName } from 'components/AmplitudeAnalytics/constants' import { EventName, ModalName } from 'components/AmplitudeAnalytics/constants'
import { Trace } from 'components/AmplitudeAnalytics/Trace' import { Trace } from 'components/AmplitudeAnalytics/Trace'
import { sendEvent } from 'components/analytics' import { sendEvent } from 'components/analytics'
import { Phase0Variant, usePhase0Flag } from 'featureFlags/flags/phase0'
import useDebounce from 'hooks/useDebounce' import useDebounce from 'hooks/useDebounce'
import { useOnClickOutside } from 'hooks/useOnClickOutside' import { useOnClickOutside } from 'hooks/useOnClickOutside'
import useTheme from 'hooks/useTheme' import useTheme from 'hooks/useTheme'
...@@ -30,7 +31,8 @@ import CurrencyList from './CurrencyList' ...@@ -30,7 +31,8 @@ import CurrencyList from './CurrencyList'
import ImportRow from './ImportRow' import ImportRow from './ImportRow'
import { PaddedColumn, SearchInput, Separator } from './styleds' import { PaddedColumn, SearchInput, Separator } from './styleds'
const ContentWrapper = styled(Column)` const ContentWrapper = styled(Column)<{ phase0Flag?: boolean }>`
background-color: ${({ theme, phase0Flag }) => phase0Flag && theme.backgroundSurface};
width: 100%; width: 100%;
flex: 1 1; flex: 1 1;
position: relative; position: relative;
...@@ -73,6 +75,9 @@ export function CurrencySearch({ ...@@ -73,6 +75,9 @@ export function CurrencySearch({
showImportView, showImportView,
setImportToken, setImportToken,
}: CurrencySearchProps) { }: CurrencySearchProps) {
const phase0Flag = usePhase0Flag()
const phase0FlagEnabled = phase0Flag === Phase0Variant.Enabled
const { chainId } = useWeb3React() const { chainId } = useWeb3React()
const theme = useTheme() const theme = useTheme()
...@@ -191,7 +196,7 @@ export function CurrencySearch({ ...@@ -191,7 +196,7 @@ export function CurrencySearch({
}, []) }, [])
return ( return (
<ContentWrapper> <ContentWrapper phase0Flag={phase0FlagEnabled}>
<Trace name={EventName.TOKEN_SELECTOR_OPENED} modal={ModalName.TOKEN_SELECTOR} shouldLogImpression> <Trace name={EventName.TOKEN_SELECTOR_OPENED} modal={ModalName.TOKEN_SELECTOR} shouldLogImpression>
<PaddedColumn gap="16px"> <PaddedColumn gap="16px">
<RowBetween> <RowBetween>
...@@ -206,6 +211,7 @@ export function CurrencySearch({ ...@@ -206,6 +211,7 @@ export function CurrencySearch({
id="token-search-input" id="token-search-input"
placeholder={t`Search name or paste address`} placeholder={t`Search name or paste address`}
autoComplete="off" autoComplete="off"
phase0Flag={phase0FlagEnabled}
value={searchQuery} value={searchQuery}
ref={inputRef as RefObject<HTMLInputElement>} ref={inputRef as RefObject<HTMLInputElement>}
onChange={handleInput} onChange={handleInput}
...@@ -222,7 +228,7 @@ export function CurrencySearch({ ...@@ -222,7 +228,7 @@ export function CurrencySearch({
/> />
)} )}
</PaddedColumn> </PaddedColumn>
<Separator /> <Separator phase0Flag={phase0FlagEnabled} />
{searchToken && !searchTokenIsAdded ? ( {searchToken && !searchTokenIsAdded ? (
<Column style={{ padding: '20px 0', height: '100%' }}> <Column style={{ padding: '20px 0', height: '100%' }}>
<ImportRow token={searchToken} showImportView={showImportView} setImportToken={setImportToken} /> <ImportRow token={searchToken} showImportView={showImportView} setImportToken={setImportToken} />
...@@ -256,9 +262,14 @@ export function CurrencySearch({ ...@@ -256,9 +262,14 @@ export function CurrencySearch({
</ThemedText.DeprecatedMain> </ThemedText.DeprecatedMain>
</Column> </Column>
)} )}
{!phase0FlagEnabled && (
<Footer> <Footer>
<Row justify="center"> <Row justify="center">
<ButtonText onClick={showManageView} color={theme.deprecated_primary1} className="list-token-manage-button"> <ButtonText
onClick={showManageView}
color={theme.deprecated_primary1}
className="list-token-manage-button"
>
<RowFixed> <RowFixed>
<IconWrapper size="16px" marginRight="6px" stroke={theme.deprecated_primaryText1}> <IconWrapper size="16px" marginRight="6px" stroke={theme.deprecated_primaryText1}>
<Edit /> <Edit />
...@@ -270,6 +281,7 @@ export function CurrencySearch({ ...@@ -270,6 +281,7 @@ export function CurrencySearch({
</ButtonText> </ButtonText>
</Row> </Row>
</Footer> </Footer>
)}
</Trace> </Trace>
</ContentWrapper> </ContentWrapper>
) )
......
...@@ -21,7 +21,7 @@ export const PaddedColumn = styled(AutoColumn)` ...@@ -21,7 +21,7 @@ export const PaddedColumn = styled(AutoColumn)`
padding: 20px; padding: 20px;
` `
export const MenuItem = styled(RowBetween)` export const MenuItem = styled(RowBetween)<{ phase0Flag?: boolean }>`
padding: 4px 20px; padding: 4px 20px;
height: 56px; height: 56px;
display: grid; display: grid;
...@@ -30,42 +30,47 @@ export const MenuItem = styled(RowBetween)` ...@@ -30,42 +30,47 @@ export const MenuItem = styled(RowBetween)`
cursor: ${({ disabled }) => !disabled && 'pointer'}; cursor: ${({ disabled }) => !disabled && 'pointer'};
pointer-events: ${({ disabled }) => disabled && 'none'}; pointer-events: ${({ disabled }) => disabled && 'none'};
:hover { :hover {
background-color: ${({ theme, disabled }) => !disabled && theme.deprecated_bg2}; background-color: ${({ theme, disabled, phase0Flag }) =>
(phase0Flag && theme.hoverDefault) || (!disabled && theme.deprecated_bg2)};
} }
opacity: ${({ disabled, selected }) => (disabled || selected ? 0.5 : 1)}; opacity: ${({ disabled, selected }) => (disabled || selected ? 0.5 : 1)};
` `
export const SearchInput = styled.input` export const SearchInput = styled.input<{ phase0Flag?: boolean }>`
position: relative; position: relative;
display: flex; display: flex;
padding: 16px; padding: 16px;
height: ${({ phase0Flag }) => phase0Flag && '40px'};
align-items: center; align-items: center;
width: 100%; width: 100%;
white-space: nowrap; white-space: nowrap;
background: none; background: none;
background-color: ${({ theme, phase0Flag }) => phase0Flag && theme.backgroundModule};
border: none; border: none;
outline: none; outline: none;
border-radius: 20px; border-radius: ${({ phase0Flag }) => (phase0Flag ? '12px' : '20px')};
color: ${({ theme }) => theme.deprecated_text1}; color: ${({ theme }) => theme.deprecated_text1};
border-style: solid; border-style: solid;
border: 1px solid ${({ theme }) => theme.deprecated_bg3}; border: 1px solid ${({ theme, phase0Flag }) => (phase0Flag ? theme.backgroundOutline : theme.deprecated_bg3)};
-webkit-appearance: none; -webkit-appearance: none;
font-size: 18px; font-size: ${({ phase0Flag }) => (phase0Flag ? '16px' : '18px')};
::placeholder { ::placeholder {
color: ${({ theme }) => theme.deprecated_text3}; color: ${({ theme, phase0Flag }) => (phase0Flag ? theme.textTertiary : theme.deprecated_text3)};
font-size: ${({ phase0Flag }) => phase0Flag && '16px'};
} }
transition: border 100ms; transition: border 100ms;
:focus { :focus {
border: 1px solid ${({ theme }) => theme.deprecated_primary1}; border: 1px solid ${({ theme, phase0Flag }) => (phase0Flag ? 'transparent' : theme.deprecated_primary1)};
background-color: ${({ theme, phase0Flag }) => phase0Flag && theme.accentActionSoft};
outline: none; outline: none;
} }
` `
export const Separator = styled.div` export const Separator = styled.div<{ phase0Flag?: boolean }>`
width: 100%; width: 100%;
height: 1px; height: 1px;
background-color: ${({ theme }) => theme.deprecated_bg2}; background-color: ${({ theme, phase0Flag }) => (phase0Flag ? theme.backgroundOutline : theme.deprecated_bg2)};
` `
export const SeparatorDark = styled.div` export const SeparatorDark = styled.div`
......
...@@ -113,6 +113,7 @@ function uniswapThemeColors(darkMode: boolean): ThemeColors { ...@@ -113,6 +113,7 @@ function uniswapThemeColors(darkMode: boolean): ThemeColors {
flyoutDropShadow: flyoutDropShadow:
'0px 24px 32px rgba(0, 0, 0, 0.04), 0px 16px 24px rgba(0, 0, 0, 0.04), 0px 4px 8px rgba(0, 0, 0, 0.04), 0px 0px 1px rgba(0, 0, 0, 0.12)', '0px 24px 32px rgba(0, 0, 0, 0.04), 0px 16px 24px rgba(0, 0, 0, 0.04), 0px 4px 8px rgba(0, 0, 0, 0.04), 0px 0px 1px rgba(0, 0, 0, 0.12)',
hoverState: opacify(24, ColorsPalette.blue200), hoverState: opacify(24, ColorsPalette.blue200),
hoverDefault: opacify(8, ColorsPalette.gray200),
} }
} }
......
...@@ -54,6 +54,7 @@ export interface ThemeColors { ...@@ -54,6 +54,7 @@ export interface ThemeColors {
blue200: Color blue200: Color
flyoutDropShadow: Color flyoutDropShadow: Color
hoverState: Color hoverState: Color
hoverDefault: Color
} }
export interface Colors { export interface Colors {
......
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