Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: minor improvement #1218

Merged
merged 1 commit into from
Aug 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/assets/networks/cronos-network-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed src/assets/networks/cronos-network.png
Binary file not shown.
4 changes: 4 additions & 0 deletions src/assets/networks/cronos-network.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 12 additions & 2 deletions src/components/NetworkModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { useActiveWeb3React } from 'hooks'
import { useActiveNetwork } from 'hooks/useActiveNetwork'
import { ApplicationModal } from 'state/application/actions'
import { useModalOpen, useNetworkModalToggle } from 'state/application/hooks'
import { useIsDarkMode } from 'state/user/hooks'

import { MAINNET_NETWORKS, NETWORKS_INFO, SUPPORTED_NETWORKS } from '../../constants/networks'

Expand Down Expand Up @@ -81,6 +82,7 @@ export default function NetworkModal(): JSX.Element | null {
const networkModalOpen = useModalOpen(ApplicationModal.NETWORK)
const toggleNetworkModal = useNetworkModalToggle()
const { changeNetwork } = useActiveNetwork()
const isDarkMode = useIsDarkMode()

return (
<Modal isOpen={networkModalOpen} onDismiss={toggleNetworkModal} maxWidth={624}>
Expand All @@ -101,7 +103,11 @@ export default function NetworkModal(): JSX.Element | null {
<SelectNetworkButton key={i} padding="0">
<ListItem selected>
<img
src={NETWORKS_INFO[key].icon}
src={
isDarkMode && !!NETWORKS_INFO[key].iconDark
? NETWORKS_INFO[key].iconDark
: NETWORKS_INFO[key].icon
}
alt="Switch Network"
style={{ width: '24px', marginRight: '8px' }}
/>
Expand All @@ -122,7 +128,11 @@ export default function NetworkModal(): JSX.Element | null {
>
<ListItem>
<img
src={NETWORKS_INFO[key].icon}
src={
isDarkMode && !!NETWORKS_INFO[key].iconDark
? NETWORKS_INFO[key].iconDark
: NETWORKS_INFO[key].icon
}
alt="Switch Network"
style={{ width: '24px', marginRight: '8px' }}
/>
Expand Down
10 changes: 8 additions & 2 deletions src/components/Web3Network/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ChainId, CurrencyAmount } from '@kyberswap/ks-sdk-core'
import React, { useMemo } from 'react'
import { useMemo } from 'react'
viet-nv marked this conversation as resolved.
Show resolved Hide resolved
import styled from 'styled-components'

import { ReactComponent as DropdownSvg } from 'assets/svg/down.svg'
Expand All @@ -8,6 +8,7 @@ import Row from 'components/Row'
import { nativeOnChain } from 'constants/tokens'
import { useActiveWeb3React } from 'hooks'
import { ApplicationModal } from 'state/application/actions'
import { useIsDarkMode } from 'state/user/hooks'
import { useETHBalances } from 'state/wallet/hooks'

import { NETWORKS_INFO } from '../../constants/networks'
Expand Down Expand Up @@ -65,6 +66,7 @@ const DropdownIcon = styled(DropdownSvg)<{ open: boolean }>`
function Web3Network(): JSX.Element | null {
const { chainId, account } = useActiveWeb3React()
const networkModalOpen = useModalOpen(ApplicationModal.NETWORK)
const isDarkMode = useIsDarkMode()
const toggleNetworkModal = useNetworkModalToggle()
const userEthBalance = useETHBalances(account ? [account] : [])?.[account ?? '']
const labelContent = useMemo(() => {
Expand All @@ -86,7 +88,11 @@ function Web3Network(): JSX.Element | null {
<NetworkSwitchContainer>
<Row>
<img
src={NETWORKS_INFO[chainId].icon}
src={
isDarkMode && NETWORKS_INFO[chainId].iconDark
? NETWORKS_INFO[chainId].iconDark
: NETWORKS_INFO[chainId].icon
}
alt="Switch Network"
style={{ width: 20, height: 20, marginRight: '12px' }}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Web3Status/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Trans, t } from '@lingui/macro'
import { AbstractConnector } from '@web3-react/abstract-connector'
import { UnsupportedChainIdError, useWeb3React } from '@web3-react/core'
import { darken, lighten } from 'polished'
import React, { useMemo } from 'react'
import { useMemo } from 'react'
import { Activity } from 'react-feather'
import { useMedia } from 'react-use'
import styled from 'styled-components'
Expand Down
4 changes: 2 additions & 2 deletions src/components/YieldPools/FarmGuide.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ function FarmGuide({ farmType }: { farmType: VERSION }) {
{farmType === VERSION.ELASTIC ? (
<>
<Trans>
Deposit your liquidity from the Elastic Pools here, and then stake it to earn even more attractive
farming rewards.
Deposit your liquidity position (NFT token) from the Elastic Pools here, and then stake it to earn even
more attractive farming rewards.
</Trans>

{(!upToMedium || !show) && (
Expand Down
44 changes: 29 additions & 15 deletions src/components/YieldPools/ProMMFarmGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import Withdraw from 'components/Icons/Withdraw'
import InfoHelper from 'components/InfoHelper'
import Loader from 'components/Loader'
import Modal from 'components/Modal'
import { MouseoverTooltip } from 'components/Tooltip'
import { MouseoverTooltip, MouseoverTooltipDesktopOnly } from 'components/Tooltip'
import { ELASTIC_BASE_FEE_UNIT, ZERO_ADDRESS } from 'constants/index'
import { VERSION } from 'constants/v2'
import { useActiveWeb3React } from 'hooks'
Expand Down Expand Up @@ -667,8 +667,13 @@ function ProMMFarmGroup({
<Flex flexDirection="column">
<Text fontSize="12px" color={theme.subText}>
<Trans>Deposited Liquidity</Trans>
<InfoHelper
text={t`Dollar value of NFT tokens you've deposited. NFT tokens represent your liquidity position`}
></InfoHelper>
</Text>

<HoverDropdown
style={{ padding: '8px 0' }}
content={formatDollarAmount(depositedUsd)}
dropdownContent={
Object.values(userDepositedTokenAmounts).some(amount => amount.greaterThan(0)) ? (
Expand Down Expand Up @@ -712,24 +717,32 @@ function ProMMFarmGroup({
)
) : (
<Flex sx={{ gap: '12px' }} alignItems="center">
<BtnLight onClick={() => onOpenModal('deposit')} disabled={tab === 'ended'}>
<Deposit width={20} height={20} />
{above768 && (
<Text fontSize="14px" marginLeft="4px">
<Trans>Deposit</Trans>
</Text>
)}
</BtnLight>

{canWithdraw ? (
<ButtonOutlined padding="8px 12px" onClick={() => onOpenModal('withdraw')}>
<Withdraw width={20} height={20} />
<MouseoverTooltipDesktopOnly
text={t`Deposit your liquidity (the NFT tokens that represent your liquidity position)`}
>
<BtnLight onClick={() => onOpenModal('deposit')} disabled={tab === 'ended'}>
<Deposit width={20} height={20} />
{above768 && (
<Text fontSize="14px" marginLeft="4px">
<Trans>Withdraw</Trans>
<Trans>Deposit</Trans>
</Text>
)}
</ButtonOutlined>
</BtnLight>
</MouseoverTooltipDesktopOnly>

{canWithdraw ? (
<MouseoverTooltipDesktopOnly
text={t`Withdraw your liquidity (the NFT tokens that represent your liquidity position)`}
>
<ButtonOutlined padding="8px 12px" onClick={() => onOpenModal('withdraw')}>
<Withdraw width={20} height={20} />
{above768 && (
<Text fontSize="14px" marginLeft="4px">
<Trans>Withdraw</Trans>
</Text>
)}
</ButtonOutlined>
</MouseoverTooltipDesktopOnly>
) : (
<BtnPrimary disabled width="fit-content" padding="8px 12px">
<Withdraw width={20} height={20} />
Expand Down Expand Up @@ -763,6 +776,7 @@ function ProMMFarmGroup({
</Text>

<HoverDropdown
style={{ padding: '8px 0' }}
content={formatDollarAmount(totalUserReward.totalUsdValue)}
dropdownContent={
totalUserReward.amounts.length ? (
Expand Down
6 changes: 3 additions & 3 deletions src/components/YieldPools/ProMMFarmModals/DepositModal.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Position } from '@kyberswap/ks-sdk-elastic'
import { Trans } from '@lingui/macro'
import { BigNumber } from 'ethers'
import React, { useEffect, useMemo, useRef, useState } from 'react'
import { useEffect, useMemo, useRef, useState } from 'react'
import { Info, X } from 'react-feather'
import { useMedia } from 'react-use'
import { Flex, Text } from 'rebass'
Expand Down Expand Up @@ -257,8 +257,8 @@ function ProMMDepositNFTModal({

<Text fontSize="12px" marginTop="20px" color={theme.subText}>
<Trans>
Deposit your liquidity first to enable farming. Only your in range liquidity positions will earn you farming
rewards
Deposit your liquidity positions (NFT tokens) first to enable farming. Only your in range liquidity
positions (NFT tokens) will earn you farming rewards
</Trans>
</Text>

Expand Down
20 changes: 12 additions & 8 deletions src/components/YieldPools/ProMMFarmModals/StakeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -271,13 +271,13 @@ function StakeModal({
<Text fontSize="12px" marginTop="20px" color={theme.subText}>
{type === 'stake' ? (
<Trans>
Stake your liquidity positions into the farms to start earning rewards. Only your in-range positions will
earn rewards
Stake your deposited liquidity positions (NFT tokens) into the farms to start earning rewards. Only your
in-range positions will earn rewards
</Trans>
) : (
<Trans>
Unstake your liquidity positions from the farm. You will no longer earn rewards on these positions once
unstaked
Unstake your liquidity positions (NFT tokens) from the farm. You will no longer earn rewards on these
positions once unstaked
</Trans>
)}
</Text>
Expand All @@ -292,11 +292,15 @@ function StakeModal({
marginTop="20px"
>
<Info size="48px" />
<Text marginTop="16px" textAlign="center" maxWidth="480px" lineHeight={1.5}>
<Text marginTop="16px" textAlign="center" lineHeight={1.5}>
<Trans>
You dont have any relevant liquidity positions yet.
<br /> Add liquidity to the farming pools first. Check out our{' '}
<StyledInternalLink to="/pools">Pools.</StyledInternalLink>
You haven&apos;t deposited any liquidity positions (NFT tokens) for this farming pair yet.
<br />
<br />
Add liquidity to this pool first in our <StyledInternalLink to="/pools">
Pools
</StyledInternalLink>{' '}
page. If you&apos;ve done that, deposit your liquidity position (NFT tokens) before you stake
</Trans>
</Text>
</Flex>
Expand Down
5 changes: 4 additions & 1 deletion src/components/YieldPools/ProMMFarmModals/WithdrawModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,10 @@ function WithdrawModal({ selectedFarmAddress, onDismiss }: { onDismiss: () => vo
</Flex>

<Text fontSize="12px" marginTop="20px" color={theme.subText}>
<Trans>You will need to unstake your liquidity first before withdrawing it back to your wallet</Trans>
<Trans>
You will need to unstake your liquidity positions (NFT tokens) first before withdrawing it back to your
wallet
</Trans>
</Text>

{!above768 && filterComponent}
Expand Down
4 changes: 3 additions & 1 deletion src/constants/networks/cronos-testnet.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ChainId } from '@kyberswap/ks-sdk-core'

import CRONOS from 'assets/networks/cronos-network.png'
import CRONOS_DARK from 'assets/networks/cronos-network-dark.svg'
import CRONOS from 'assets/networks/cronos-network.svg'
import CronosLogo from 'assets/svg/cronos-token-logo.svg'
import { createClient } from 'utils/client'

Expand All @@ -15,6 +16,7 @@ const cronosTestnetInfo: NetworkInfo = {
route: 'cronos-testnet',
name: 'Cronos Testnet',
icon: CRONOS,
iconDark: CRONOS_DARK,
classicClient: createClient(
'https://testnet-cronos-subgraph.knstats.com/subgraphs/name/dynamic-amm/dmm-exchange-cronos-testnet',
),
Expand Down
4 changes: 3 additions & 1 deletion src/constants/networks/cronos.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ChainId } from '@kyberswap/ks-sdk-core'

import CRONOS from 'assets/networks/cronos-network.png'
import CRONOS_DARK from 'assets/networks/cronos-network-dark.svg'
import CRONOS from 'assets/networks/cronos-network.svg'
import CronosLogo from 'assets/svg/cronos-token-logo.svg'
import { createClient } from 'utils/client'

Expand All @@ -15,6 +16,7 @@ const cronosInfo: NetworkInfo = {
route: 'cronos',
name: 'Cronos',
icon: CRONOS,
iconDark: CRONOS_DARK,
classicClient: createClient(
'https://cronos-graph.kyberengineering.io/subgraphs/name/kybernetwork/kyberswap-exchange-cronos',
),
Expand Down
1 change: 1 addition & 0 deletions src/constants/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export type NetworkInfo = {
readonly route: string
readonly name: string
readonly icon: string
readonly iconDark?: string
readonly classicClient: ApolloClient<NormalizedCacheObject>
readonly elasticClient: ApolloClient<NormalizedCacheObject>
readonly blockClient: ApolloClient<NormalizedCacheObject>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Campaign/CampaignButtonWithOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export default function CampaignButtonWithOptions({
{isClaimingThisCampaignRewards && <Dots />}
<ChevronDown style={{ position: 'absolute', top: '50%', right: '12px', transform: 'translateY(-50%)' }} />
{isShowNetworks && (
<OptionsContainer style={{ margin: '0 12px', width: 'calc(100% - 24px)' }}>
<OptionsContainer>
{chainIds.map(chainId => {
return (
<Flex
Expand Down
1 change: 0 additions & 1 deletion src/pages/Campaign/EnterNowOrClaimButton.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react'
import { useSelector } from 'react-redux'

import { BIG_INT_ZERO } from 'constants/index'
Expand Down
11 changes: 5 additions & 6 deletions src/pages/SwapV2/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,10 @@ export default function Swap({ history }: RouteComponentProps) {
</StyledActionButtonSwapForm>
}
/>
<MobileTokenInfo currencies={currencies} onClick={() => setActiveTab(TAB.INFO)} />
<MobileTokenInfo
currencies={currencies}
onClick={() => setActiveTab(prev => (prev === TAB.INFO ? TAB.SWAP : TAB.INFO))}
/>
<ShareButtonWithModal
url={shareUrl}
onShared={() => {
Expand All @@ -745,11 +748,7 @@ export default function Swap({ history }: RouteComponentProps) {
/>
<StyledActionButtonSwapForm
active={activeTab === TAB.SETTINGS}
onClick={() => {
if (activeTab === TAB.SETTINGS) {
setActiveTab(TAB.SWAP)
} else setActiveTab(TAB.SETTINGS)
}}
onClick={() => setActiveTab(prev => (prev === TAB.SETTINGS ? TAB.SWAP : TAB.SETTINGS))}
aria-label="Swap Settings"
>
<MouseoverTooltip
Expand Down
14 changes: 8 additions & 6 deletions src/pages/TrueSight/styled.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { rgba } from 'polished'
import { Flex, Text } from 'rebass'
import { Text } from 'rebass'
import styled from 'styled-components'

import { ButtonEmpty, ButtonPrimary } from 'components/Button'
Expand Down Expand Up @@ -67,19 +67,21 @@ export const TrueSightFilterBarLayoutMobile = styled.div`
position: relative;
`

export const OptionsContainer = styled(Flex)`
export const OptionsContainer = styled.div`
display: flex;
position: absolute;
bottom: -4px;
bottom: -6px;
right: 0;
border-radius: 20px;
border-radius: 16px;
flex-direction: column;
background: ${({ theme }) => theme.tableHeader};
overflow: hidden;
z-index: 9999;
width: 100%;
box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
transform: translate(0, 100%);
min-width: max-content !important;
left: 50%;
transform: translate(-50%, 100%);
min-width: max-content;

& > * {
cursor: pointer;
Expand Down