Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
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
vicotor
frontend
Commits
9df90f58
Commit
9df90f58
authored
Oct 03, 2024
by
Max Alekseenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve nav item and add red dot
parent
82631ed6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
9 deletions
+35
-9
.env.eth_sepolia
configs/envs/.env.eth_sepolia
+1
-1
useNavItems.tsx
lib/hooks/useNavItems.tsx
+30
-4
navigation.ts
types/client/navigation.ts
+1
-1
NavLink.tsx
ui/snippets/navigation/vertical/NavLink.tsx
+3
-3
No files found.
configs/envs/.env.eth_sepolia
View file @
9df90f58
...
@@ -40,7 +40,7 @@ NEXT_PUBLIC_METADATA_SERVICE_API_HOST=https://metadata.services.blockscout.com
...
@@ -40,7 +40,7 @@ NEXT_PUBLIC_METADATA_SERVICE_API_HOST=https://metadata.services.blockscout.com
NEXT_PUBLIC_METASUITES_ENABLED=true
NEXT_PUBLIC_METASUITES_ENABLED=true
NEXT_PUBLIC_MULTICHAIN_BALANCE_PROVIDER_CONFIG={'name': 'zerion', 'dapp_id': 'zerion', 'url_template': 'https://app.zerion.io/{address}/overview?utm_source=blockscout&utm_medium=address', 'logo': 'https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/marketplace-logos/zerion.svg'}
NEXT_PUBLIC_MULTICHAIN_BALANCE_PROVIDER_CONFIG={'name': 'zerion', 'dapp_id': 'zerion', 'url_template': 'https://app.zerion.io/{address}/overview?utm_source=blockscout&utm_medium=address', 'logo': 'https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/marketplace-logos/zerion.svg'}
NEXT_PUBLIC_NAME_SERVICE_API_HOST=https://bens.services.blockscout.com
NEXT_PUBLIC_NAME_SERVICE_API_HOST=https://bens.services.blockscout.com
NEXT_PUBLIC_NAVIGATION_HIGHLIGHTED_ROUTES=['/apps']
NEXT_PUBLIC_NAVIGATION_HIGHLIGHTED_ROUTES=['/apps'
,'/account/rewards'
]
NEXT_PUBLIC_NETWORK_CURRENCY_DECIMALS=18
NEXT_PUBLIC_NETWORK_CURRENCY_DECIMALS=18
NEXT_PUBLIC_NETWORK_CURRENCY_NAME=Ether
NEXT_PUBLIC_NETWORK_CURRENCY_NAME=Ether
NEXT_PUBLIC_NETWORK_CURRENCY_SYMBOL=ETH
NEXT_PUBLIC_NETWORK_CURRENCY_SYMBOL=ETH
...
...
lib/hooks/useNavItems.tsx
View file @
9df90f58
import
{
useColorModeValue
}
from
'
@chakra-ui/react
'
;
import
{
useRouter
}
from
'
next/router
'
;
import
{
useRouter
}
from
'
next/router
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
...
@@ -6,6 +7,7 @@ import type { NavItemInternal, NavItem, NavGroupItem } from 'types/client/naviga
...
@@ -6,6 +7,7 @@ import type { NavItemInternal, NavItem, NavGroupItem } from 'types/client/naviga
import
config
from
'
configs/app
'
;
import
config
from
'
configs/app
'
;
import
{
useRewardsContext
}
from
'
lib/contexts/rewards
'
;
import
{
useRewardsContext
}
from
'
lib/contexts/rewards
'
;
import
{
rightLineArrow
}
from
'
lib/html-entities
'
;
import
{
rightLineArrow
}
from
'
lib/html-entities
'
;
import
IconSvg
from
'
ui/shared/IconSvg
'
;
import
UserAvatar
from
'
ui/shared/UserAvatar
'
;
import
UserAvatar
from
'
ui/shared/UserAvatar
'
;
interface
ReturnType
{
interface
ReturnType
{
...
@@ -28,8 +30,11 @@ export default function useNavItems(): ReturnType {
...
@@ -28,8 +30,11 @@ export default function useNavItems(): ReturnType {
const
{
const
{
openLoginModal
:
openRewardsLoginModal
,
openLoginModal
:
openRewardsLoginModal
,
balance
:
rewardsBalance
,
balance
:
rewardsBalance
,
dailyReward
,
apiToken
:
rewardsApiToken
,
apiToken
:
rewardsApiToken
,
}
=
useRewardsContext
();
}
=
useRewardsContext
();
const
themeBgColor
=
useColorModeValue
(
'
white
'
,
'
black
'
);
const
activeItemBgColor
=
useColorModeValue
(
'
blue.50
'
,
'
gray.800
'
);
return
React
.
useMemo
(()
=>
{
return
React
.
useMemo
(()
=>
{
let
blockchainNavItems
:
Array
<
NavItem
>
|
Array
<
Array
<
NavItem
>>
=
[];
let
blockchainNavItems
:
Array
<
NavItem
>
|
Array
<
Array
<
NavItem
>>
=
[];
...
@@ -273,10 +278,31 @@ export default function useNavItems(): ReturnType {
...
@@ -273,10 +278,31 @@ export default function useNavItems(): ReturnType {
const
accountNavItems
:
ReturnType
[
'
accountNavItems
'
]
=
[
const
accountNavItems
:
ReturnType
[
'
accountNavItems
'
]
=
[
config
.
features
.
rewards
.
isEnabled
?
{
config
.
features
.
rewards
.
isEnabled
?
{
text
:
rewardsBalance
?.
total
?
`
${
rewardsBalance
?.
total
}
Merits
` : 'Merits',
text
:
rewardsBalance
?.
total
?
`
${
rewardsBalance
?.
total
}
Merits
` : 'Merits',
nextRoute:
rewardsApiToken ? { pathname: '/account/rewards' as const } : undefined
,
nextRoute:
{ pathname: '/account/rewards' as const }
,
onClick: rewardsApiToken ? undefined : openRewardsLoginModal,
onClick: rewardsApiToken ? undefined : openRewardsLoginModal,
icon: 'merits',
iconComponent: () => (
isActive: Boolean(rewardsApiToken) && pathname === '/account/rewards',
<IconSvg
name="merits"
boxSize="30px"
flexShrink={ 0 }
position="relative"
_before={{
display: dailyReward?.available ? 'block' : 'none',
content: '""',
position: 'absolute',
top: '2px',
right: '1px',
width: '10px',
height: '10px',
boxSizing: 'border-box',
borderRadius: '50%',
backgroundColor: 'red.500',
border: '2px solid',
borderColor: pathname === '/account/rewards' ? activeItemBgColor : themeBgColor,
}}
/>
),
isActive: pathname === '/account/rewards',
} : null,
} : null,
{
{
text: 'Watch list',
text: 'Watch list',
...
@@ -318,5 +344,5 @@ export default function useNavItems(): ReturnType {
...
@@ -318,5 +344,5 @@ export default function useNavItems(): ReturnType {
};
};
return { mainNavItems, accountNavItems, profileItem };
return { mainNavItems, accountNavItems, profileItem };
}, [ pathname, openRewardsLoginModal, rewardsBalance,
rewardsApiToken
]);
}, [ pathname, openRewardsLoginModal, rewardsBalance,
dailyReward, rewardsApiToken, activeItemBgColor, themeBgColor
]);
}
}
types/client/navigation.ts
View file @
9df90f58
...
@@ -15,7 +15,7 @@ type NavItemCommon = {
...
@@ -15,7 +15,7 @@ type NavItemCommon = {
}
&
NavIconOrComponent
;
}
&
NavIconOrComponent
;
export
type
NavItemInternal
=
NavItemCommon
&
{
export
type
NavItemInternal
=
NavItemCommon
&
{
nextRoute
?
:
Route
;
nextRoute
:
Route
;
isActive
?:
boolean
;
isActive
?:
boolean
;
onClick
?:
()
=>
void
;
onClick
?:
()
=>
void
;
}
}
...
...
ui/snippets/navigation/vertical/NavLink.tsx
View file @
9df90f58
...
@@ -35,8 +35,8 @@ const NavLink = ({ item, isCollapsed, px, className, onClick, disableActiveState
...
@@ -35,8 +35,8 @@ const NavLink = ({ item, isCollapsed, px, className, onClick, disableActiveState
const
styleProps
=
useNavLinkStyleProps
({
isCollapsed
,
isExpanded
,
isActive
:
isInternalLink
&&
item
.
isActive
&&
!
disableActiveState
});
const
styleProps
=
useNavLinkStyleProps
({
isCollapsed
,
isExpanded
,
isActive
:
isInternalLink
&&
item
.
isActive
&&
!
disableActiveState
});
const
isXLScreen
=
useBreakpointValue
({
base
:
false
,
xl
:
true
});
const
isXLScreen
=
useBreakpointValue
({
base
:
false
,
xl
:
true
});
let
href
;
let
href
;
if
(
isInternalLink
)
{
if
(
isInternalLink
&&
!
item
.
onClick
)
{
href
=
item
.
nextRoute
?
route
(
item
.
nextRoute
)
:
undefined
;
href
=
route
(
item
.
nextRoute
)
;
}
else
if
(
'
url
'
in
item
)
{
}
else
if
(
'
url
'
in
item
)
{
href
=
item
.
url
;
href
=
item
.
url
;
}
}
...
@@ -87,7 +87,7 @@ const NavLink = ({ item, isCollapsed, px, className, onClick, disableActiveState
...
@@ -87,7 +87,7 @@ const NavLink = ({ item, isCollapsed, px, className, onClick, disableActiveState
return
(
return
(
<
Box
as=
"li"
listStyleType=
"none"
w=
"100%"
className=
{
className
}
>
<
Box
as=
"li"
listStyleType=
"none"
w=
"100%"
className=
{
className
}
>
{
isInternalLink
&&
item
.
nextRoute
?
(
{
isInternalLink
&&
!
item
.
onClick
?
(
<
NextLink
href=
{
item
.
nextRoute
}
passHref
legacyBehavior
>
<
NextLink
href=
{
item
.
nextRoute
}
passHref
legacyBehavior
>
{
content
}
{
content
}
</
NextLink
>
</
NextLink
>
...
...
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