Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
interface
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LuckySwap
interface
Commits
9f8355ed
Unverified
Commit
9f8355ed
authored
Nov 09, 2022
by
vignesh mohankumar
Committed by
GitHub
Nov 09, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: useIsNftPage hooks (#5142)
parent
c5bed1c6
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
15 deletions
+29
-15
index.tsx
src/components/NavBar/index.tsx
+5
-3
useIsNftPage.ts
src/hooks/useIsNftPage.ts
+16
-0
Bag.tsx
src/nft/components/bag/Bag.tsx
+4
-6
EmptyContent.tsx
src/nft/components/bag/EmptyContent.tsx
+2
-3
RadialGradientByChainUpdater.ts
src/theme/RadialGradientByChainUpdater.ts
+2
-3
No files found.
src/components/NavBar/index.tsx
View file @
9f8355ed
...
@@ -3,6 +3,7 @@ import { useWeb3React } from '@web3-react/core'
...
@@ -3,6 +3,7 @@ import { useWeb3React } from '@web3-react/core'
import
Web3Status
from
'
components/Web3Status
'
import
Web3Status
from
'
components/Web3Status
'
import
{
NftVariant
,
useNftFlag
}
from
'
featureFlags/flags/nft
'
import
{
NftVariant
,
useNftFlag
}
from
'
featureFlags/flags/nft
'
import
{
chainIdToBackendName
}
from
'
graphql/data/util
'
import
{
chainIdToBackendName
}
from
'
graphql/data/util
'
import
{
useIsNftPage
}
from
'
hooks/useIsNftPage
'
import
{
Box
}
from
'
nft/components/Box
'
import
{
Box
}
from
'
nft/components/Box
'
import
{
Row
}
from
'
nft/components/Flex
'
import
{
Row
}
from
'
nft/components/Flex
'
import
{
UniIcon
}
from
'
nft/components/icons
'
import
{
UniIcon
}
from
'
nft/components/icons
'
...
@@ -48,6 +49,8 @@ const PageTabs = () => {
...
@@ -48,6 +49,8 @@ const PageTabs = () => {
pathname
.
startsWith
(
'
/increase
'
)
||
pathname
.
startsWith
(
'
/increase
'
)
||
pathname
.
startsWith
(
'
/find
'
)
pathname
.
startsWith
(
'
/find
'
)
const
isNftPage
=
useIsNftPage
()
return
(
return
(
<>
<>
<
MenuItem
href=
"/swap"
isActive=
{
pathname
.
startsWith
(
'
/swap
'
)
}
>
<
MenuItem
href=
"/swap"
isActive=
{
pathname
.
startsWith
(
'
/swap
'
)
}
>
...
@@ -57,7 +60,7 @@ const PageTabs = () => {
...
@@ -57,7 +60,7 @@ const PageTabs = () => {
<
Trans
>
Tokens
</
Trans
>
<
Trans
>
Tokens
</
Trans
>
</
MenuItem
>
</
MenuItem
>
{
nftFlag
===
NftVariant
.
Enabled
&&
(
{
nftFlag
===
NftVariant
.
Enabled
&&
(
<
MenuItem
href=
"/nfts"
isActive=
{
pathname
.
startsWith
(
'
/nfts
'
)
}
>
<
MenuItem
href=
"/nfts"
isActive=
{
isNftPage
}
>
<
Trans
>
NFTs
</
Trans
>
<
Trans
>
NFTs
</
Trans
>
</
MenuItem
>
</
MenuItem
>
)
}
)
}
...
@@ -69,8 +72,7 @@ const PageTabs = () => {
...
@@ -69,8 +72,7 @@ const PageTabs = () => {
}
}
const
Navbar
=
()
=>
{
const
Navbar
=
()
=>
{
const
{
pathname
}
=
useLocation
()
const
isNftPage
=
useIsNftPage
()
const
isNftPage
=
pathname
.
startsWith
(
'
/nfts
'
)
return
(
return
(
<>
<>
...
...
src/hooks/useIsNftPage.ts
0 → 100644
View file @
9f8355ed
import
{
useLocation
}
from
'
react-router-dom
'
export
function
useIsNftPage
()
{
const
{
pathname
}
=
useLocation
()
return
pathname
.
startsWith
(
'
/nfts
'
)
}
export
function
useIsNftProfilePage
()
{
const
{
pathname
}
=
useLocation
()
return
pathname
.
startsWith
(
'
/nfts/profile
'
)
}
export
function
useIsNftDetailsPage
()
{
const
{
pathname
}
=
useLocation
()
return
pathname
.
startsWith
(
'
/nfts/asset
'
)
}
src/nft/components/bag/Bag.tsx
View file @
9f8355ed
import
{
BigNumber
}
from
'
@ethersproject/bignumber
'
import
{
BigNumber
}
from
'
@ethersproject/bignumber
'
import
{
formatEther
}
from
'
@ethersproject/units
'
import
{
formatEther
}
from
'
@ethersproject/units
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
useIsNftDetailsPage
,
useIsNftPage
,
useIsNftProfilePage
}
from
'
hooks/useIsNftPage
'
import
{
BagFooter
}
from
'
nft/components/bag/BagFooter
'
import
{
BagFooter
}
from
'
nft/components/bag/BagFooter
'
import
ListingModal
from
'
nft/components/bag/profile/ListingModal
'
import
ListingModal
from
'
nft/components/bag/profile/ListingModal
'
import
{
Box
}
from
'
nft/components/Box
'
import
{
Box
}
from
'
nft/components/Box
'
...
@@ -28,7 +29,6 @@ import {
...
@@ -28,7 +29,6 @@ import {
import
{
combineBuyItemsWithTxRoute
}
from
'
nft/utils/txRoute/combineItemsWithTxRoute
'
import
{
combineBuyItemsWithTxRoute
}
from
'
nft/utils/txRoute/combineItemsWithTxRoute
'
import
{
useCallback
,
useEffect
,
useMemo
,
useRef
,
useState
}
from
'
react
'
import
{
useCallback
,
useEffect
,
useMemo
,
useRef
,
useState
}
from
'
react
'
import
{
useQuery
,
useQueryClient
}
from
'
react-query
'
import
{
useQuery
,
useQueryClient
}
from
'
react-query
'
import
{
useLocation
}
from
'
react-router-dom
'
import
styled
from
'
styled-components/macro
'
import
styled
from
'
styled-components/macro
'
import
shallow
from
'
zustand/shallow
'
import
shallow
from
'
zustand/shallow
'
...
@@ -100,13 +100,11 @@ const Bag = () => {
...
@@ -100,13 +100,11 @@ const Bag = () => {
}
=
useBag
((
state
)
=>
({
...
state
,
bagIsLocked
:
state
.
isLocked
,
uncheckedItemsInBag
:
state
.
itemsInBag
}),
shallow
)
}
=
useBag
((
state
)
=>
({
...
state
,
bagIsLocked
:
state
.
isLocked
,
uncheckedItemsInBag
:
state
.
itemsInBag
}),
shallow
)
const
{
uncheckedItemsInBag
}
=
useBag
(({
itemsInBag
})
=>
({
uncheckedItemsInBag
:
itemsInBag
}))
const
{
uncheckedItemsInBag
}
=
useBag
(({
itemsInBag
})
=>
({
uncheckedItemsInBag
:
itemsInBag
}))
const
{
pathname
}
=
useLocation
()
const
isProfilePage
=
useIsNftProfilePage
()
const
is
ProfilePage
=
pathname
.
startsWith
(
'
/nfts/profile
'
)
const
is
DetailsPage
=
useIsNftDetailsPage
(
)
const
isNFTPage
=
pathname
.
startsWith
(
'
/nfts
'
)
const
isNFTPage
=
useIsNftPage
(
)
const
isMobile
=
useIsMobile
()
const
isMobile
=
useIsMobile
()
const
isDetailsPage
=
pathname
.
includes
(
'
/nfts/asset/
'
)
const
sendTransaction
=
useSendTransaction
((
state
)
=>
state
.
sendTransaction
)
const
sendTransaction
=
useSendTransaction
((
state
)
=>
state
.
sendTransaction
)
const
transactionState
=
useSendTransaction
((
state
)
=>
state
.
state
)
const
transactionState
=
useSendTransaction
((
state
)
=>
state
.
state
)
const
setTransactionState
=
useSendTransaction
((
state
)
=>
state
.
setState
)
const
setTransactionState
=
useSendTransaction
((
state
)
=>
state
.
setState
)
...
...
src/nft/components/bag/EmptyContent.tsx
View file @
9f8355ed
import
{
useIsNftProfilePage
}
from
'
hooks/useIsNftPage
'
import
{
Center
,
Column
}
from
'
nft/components/Flex
'
import
{
Center
,
Column
}
from
'
nft/components/Flex
'
import
{
LargeBagIcon
,
LargeTagIcon
}
from
'
nft/components/icons
'
import
{
LargeBagIcon
,
LargeTagIcon
}
from
'
nft/components/icons
'
import
{
subhead
}
from
'
nft/css/common.css
'
import
{
subhead
}
from
'
nft/css/common.css
'
import
{
themeVars
}
from
'
nft/css/sprinkles.css
'
import
{
themeVars
}
from
'
nft/css/sprinkles.css
'
import
{
useLocation
}
from
'
react-router-dom
'
import
styled
from
'
styled-components/macro
'
import
styled
from
'
styled-components/macro
'
const
StyledColumn
=
styled
(
Column
)
<
{
isProfilePage
?:
boolean
}
>
`
const
StyledColumn
=
styled
(
Column
)
<
{
isProfilePage
?:
boolean
}
>
`
...
@@ -14,8 +14,7 @@ const StyledColumn = styled(Column)<{ isProfilePage?: boolean }>`
...
@@ -14,8 +14,7 @@ const StyledColumn = styled(Column)<{ isProfilePage?: boolean }>`
`
`
const
EmptyState
=
()
=>
{
const
EmptyState
=
()
=>
{
const
{
pathname
}
=
useLocation
()
const
isProfilePage
=
useIsNftProfilePage
()
const
isProfilePage
=
pathname
.
startsWith
(
'
/nfts/profile
'
)
return
(
return
(
<
StyledColumn
isProfilePage=
{
isProfilePage
}
>
<
StyledColumn
isProfilePage=
{
isProfilePage
}
>
...
...
src/theme/RadialGradientByChainUpdater.ts
View file @
9f8355ed
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
useIsNftPage
}
from
'
hooks/useIsNftPage
'
import
{
useEffect
}
from
'
react
'
import
{
useEffect
}
from
'
react
'
import
{
useLocation
}
from
'
react-router-dom
'
import
{
useDarkModeManager
}
from
'
state/user/hooks
'
import
{
useDarkModeManager
}
from
'
state/user/hooks
'
import
{
SupportedChainId
}
from
'
../constants/chains
'
import
{
SupportedChainId
}
from
'
../constants/chains
'
...
@@ -29,8 +29,7 @@ const setBackground = (newValues: TargetBackgroundStyles) =>
...
@@ -29,8 +29,7 @@ const setBackground = (newValues: TargetBackgroundStyles) =>
export
default
function
RadialGradientByChainUpdater
():
null
{
export
default
function
RadialGradientByChainUpdater
():
null
{
const
{
chainId
}
=
useWeb3React
()
const
{
chainId
}
=
useWeb3React
()
const
[
darkMode
]
=
useDarkModeManager
()
const
[
darkMode
]
=
useDarkModeManager
()
const
{
pathname
}
=
useLocation
()
const
isNftPage
=
useIsNftPage
()
const
isNftPage
=
pathname
.
startsWith
(
'
/nfts
'
)
// manage background color
// manage background color
useEffect
(()
=>
{
useEffect
(()
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment