Commit 2a92b299 authored by vignesh mohankumar's avatar vignesh mohankumar Committed by GitHub

fix: remove hover state for chevrons in nav (#4681)

* fix

* fix
parent e180153c
import { ChevronDown, ChevronUp } from 'react-feather'
import styled from 'styled-components/macro'
export const StyledChevronDown = styled(ChevronDown)<{ customColor?: string }>`
color: ${({ theme, customColor }) => customColor ?? theme.textSecondary};
height: 20px;
width: 20px;
&:hover {
color: ${({ theme }) => theme.accentActionSoft};
transition: ${({
theme: {
transition: { duration, timing },
},
}) => `${duration.fast} color ${timing.in}`};
}
`
export const StyledChevronUp = styled(ChevronUp)<{ customColor?: string }>`
color: ${({ theme, customColor }) => customColor ?? theme.textSecondary};
height: 20px;
width: 20px;
&:hover {
color: ${({ theme }) => theme.accentActionSoft};
transition: ${({
theme: {
transition: { duration, timing },
},
}) => `${duration.fast} color ${timing.in}`};
}
`
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import { StyledChevronDown, StyledChevronUp } from 'components/Icons'
import { getChainInfo } from 'constants/chainInfo' import { getChainInfo } from 'constants/chainInfo'
import { SupportedChainId } from 'constants/chains' import { SupportedChainId } from 'constants/chains'
import { useOnClickOutside } from 'hooks/useOnClickOutside' import { useOnClickOutside } from 'hooks/useOnClickOutside'
...@@ -13,6 +12,8 @@ import { subhead } from 'nft/css/common.css' ...@@ -13,6 +12,8 @@ import { subhead } from 'nft/css/common.css'
import { themeVars } from 'nft/css/sprinkles.css' import { themeVars } from 'nft/css/sprinkles.css'
import { useIsMobile } from 'nft/hooks' import { useIsMobile } from 'nft/hooks'
import { useCallback, useRef, useState } from 'react' import { useCallback, useRef, useState } from 'react'
import { ChevronDown, ChevronUp } from 'react-feather'
import { useTheme } from 'styled-components/macro'
import * as styles from './ChainSelector.css' import * as styles from './ChainSelector.css'
import ChainSelectorRow from './ChainSelectorRow' import ChainSelectorRow from './ChainSelectorRow'
...@@ -35,6 +36,8 @@ export const ChainSelector = ({ leftAlign }: ChainSelectorProps) => { ...@@ -35,6 +36,8 @@ export const ChainSelector = ({ leftAlign }: ChainSelectorProps) => {
const [isOpen, setIsOpen] = useState<boolean>(false) const [isOpen, setIsOpen] = useState<boolean>(false)
const isMobile = useIsMobile() const isMobile = useIsMobile()
const theme = useTheme()
const ref = useRef<HTMLDivElement>(null) const ref = useRef<HTMLDivElement>(null)
const modalRef = useRef<HTMLDivElement>(null) const modalRef = useRef<HTMLDivElement>(null)
useOnClickOutside(ref, () => setIsOpen(false), [modalRef]) useOnClickOutside(ref, () => setIsOpen(false), [modalRef])
...@@ -77,6 +80,12 @@ export const ChainSelector = ({ leftAlign }: ChainSelectorProps) => { ...@@ -77,6 +80,12 @@ export const ChainSelector = ({ leftAlign }: ChainSelectorProps) => {
</NavDropdown> </NavDropdown>
) )
const chevronProps = {
height: 20,
width: 20,
color: theme.textSecondary,
}
return ( return (
<Box position="relative" ref={ref}> <Box position="relative" ref={ref}>
<Row <Row
...@@ -101,7 +110,7 @@ export const ChainSelector = ({ leftAlign }: ChainSelectorProps) => { ...@@ -101,7 +110,7 @@ export const ChainSelector = ({ leftAlign }: ChainSelectorProps) => {
</Box> </Box>
</> </>
)} )}
{isOpen ? <StyledChevronUp /> : <StyledChevronDown />} {isOpen ? <ChevronUp {...chevronProps} /> : <ChevronDown {...chevronProps} />}
</Row> </Row>
{isOpen && (isMobile ? <Portal>{dropdown}</Portal> : <>{dropdown}</>)} {isOpen && (isMobile ? <Portal>{dropdown}</Portal> : <>{dropdown}</>)}
</Box> </Box>
......
...@@ -3,7 +3,6 @@ import { t, Trans } from '@lingui/macro' ...@@ -3,7 +3,6 @@ import { t, Trans } from '@lingui/macro'
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import { ElementName, Event, EventName } from 'analytics/constants' import { ElementName, Event, EventName } from 'analytics/constants'
import { TraceEvent } from 'analytics/TraceEvent' import { TraceEvent } from 'analytics/TraceEvent'
import { StyledChevronDown, StyledChevronUp } from 'components/Icons'
import WalletDropdown from 'components/WalletDropdown' import WalletDropdown from 'components/WalletDropdown'
import { getConnection } from 'connection/utils' import { getConnection } from 'connection/utils'
import { NavBarVariant, useNavBarFlag } from 'featureFlags/flags/navBar' import { NavBarVariant, useNavBarFlag } from 'featureFlags/flags/navBar'
...@@ -11,7 +10,7 @@ import { Portal } from 'nft/components/common/Portal' ...@@ -11,7 +10,7 @@ import { Portal } from 'nft/components/common/Portal'
import { getIsValidSwapQuote } from 'pages/Swap' import { getIsValidSwapQuote } from 'pages/Swap'
import { darken } from 'polished' import { darken } from 'polished'
import { useMemo, useRef } from 'react' import { useMemo, useRef } from 'react'
import { AlertTriangle } from 'react-feather' import { AlertTriangle, ChevronDown, ChevronUp } from 'react-feather'
import { useAppSelector } from 'state/hooks' import { useAppSelector } from 'state/hooks'
import { useDerivedSwapInfo } from 'state/swap/hooks' import { useDerivedSwapInfo } from 'state/swap/hooks'
import styled, { css, useTheme } from 'styled-components/macro' import styled, { css, useTheme } from 'styled-components/macro'
...@@ -178,6 +177,11 @@ const StyledConnect = styled.div` ...@@ -178,6 +177,11 @@ const StyledConnect = styled.div`
} }
` `
const CHEVRON_PROPS = {
height: 20,
width: 20,
}
function Web3StatusInner() { function Web3StatusInner() {
const { account, connector, chainId, ENSName } = useWeb3React() const { account, connector, chainId, ENSName } = useWeb3React()
const connectionType = getConnection(connector).type const connectionType = getConnection(connector).type
...@@ -219,6 +223,10 @@ function Web3StatusInner() { ...@@ -219,6 +223,10 @@ function Web3StatusInner() {
</Web3StatusError> </Web3StatusError>
) )
} else if (account) { } else if (account) {
const chevronProps = {
...CHEVRON_PROPS,
color: theme.textSecondary,
}
return ( return (
<Web3StatusConnected data-testid="web3-status-connected" onClick={toggleWallet} pending={hasPendingTransactions}> <Web3StatusConnected data-testid="web3-status-connected" onClick={toggleWallet} pending={hasPendingTransactions}>
{navbarFlagEnabled && !hasPendingTransactions && <StatusIcon size={24} connectionType={connectionType} />} {navbarFlagEnabled && !hasPendingTransactions && <StatusIcon size={24} connectionType={connectionType} />}
...@@ -235,9 +243,9 @@ function Web3StatusInner() { ...@@ -235,9 +243,9 @@ function Web3StatusInner() {
<Text>{ENSName || shortenAddress(account)}</Text> <Text>{ENSName || shortenAddress(account)}</Text>
{navbarFlagEnabled ? ( {navbarFlagEnabled ? (
walletIsOpen ? ( walletIsOpen ? (
<StyledChevronUp onClick={toggleWalletDropdown} /> <ChevronUp {...chevronProps} />
) : ( ) : (
<StyledChevronDown onClick={toggleWalletDropdown} /> <ChevronDown {...chevronProps} />
) )
) : null} ) : null}
</> </>
...@@ -246,6 +254,12 @@ function Web3StatusInner() { ...@@ -246,6 +254,12 @@ function Web3StatusInner() {
</Web3StatusConnected> </Web3StatusConnected>
) )
} else { } else {
const chevronProps = {
...CHEVRON_PROPS,
color: theme.accentAction,
'data-testid': 'navbar-wallet-dropdown',
onClick: toggleWalletDropdown,
}
return ( return (
<TraceEvent <TraceEvent
events={[Event.onClick]} events={[Event.onClick]}
...@@ -259,19 +273,7 @@ function Web3StatusInner() { ...@@ -259,19 +273,7 @@ function Web3StatusInner() {
<Trans>Connect</Trans> <Trans>Connect</Trans>
</StyledConnect> </StyledConnect>
<VerticalDivider /> <VerticalDivider />
{walletIsOpen ? ( {walletIsOpen ? <ChevronUp {...chevronProps} /> : <ChevronDown {...chevronProps} />}
<StyledChevronUp
data-testid="navbar-wallet-dropdown"
customColor={theme.accentAction}
onClick={toggleWalletDropdown}
/>
) : (
<StyledChevronDown
data-testid="navbar-wallet-dropdown"
customColor={theme.accentAction}
onClick={toggleWalletDropdown}
/>
)}
</Web3StatusConnectButton> </Web3StatusConnectButton>
) : ( ) : (
<Web3StatusConnect onClick={toggleWallet} faded={!account}> <Web3StatusConnect onClick={toggleWallet} faded={!account}>
......
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