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
591c0ead
Commit
591c0ead
authored
Feb 16, 2023
by
isstuev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix types
parent
3ee03ae6
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
32 deletions
+19
-32
useNavItems.tsx
lib/hooks/useNavItems.tsx
+8
-1
NavLinkGroupDesktop.tsx
ui/snippets/navigation/NavLinkGroupDesktop.tsx
+2
-13
NavLinkGroupMobile.tsx
ui/snippets/navigation/NavLinkGroupMobile.tsx
+2
-13
NavigationDesktop.tsx
ui/snippets/navigation/NavigationDesktop.tsx
+2
-2
NavigationMobile.tsx
ui/snippets/navigation/NavigationMobile.tsx
+5
-3
No files found.
lib/hooks/useNavItems.tsx
View file @
591c0ead
...
...
@@ -42,6 +42,13 @@ interface ReturnType {
profileItem
:
NavItem
;
}
export
function
isGroupItem
(
item
:
NavItem
|
NavGroupItem
):
item
is
NavGroupItem
{
if
((
item
as
NavGroupItem
).
subItems
)
{
return
true
;
}
return
false
;
}
export
default
function
useNavItems
():
ReturnType
{
const
isMarketplaceFilled
=
appConfig
.
marketplaceAppList
.
length
>
0
;
...
...
@@ -49,7 +56,7 @@ export default function useNavItems(): ReturnType {
const
pathname
=
router
.
pathname
;
return
React
.
useMemo
(()
=>
{
const
blockchainNavItems
=
[
const
blockchainNavItems
:
Array
<
NavItem
>
=
[
{
text
:
'
Top accounts
'
,
nextRoute
:
{
pathname
:
'
/accounts
'
as
const
},
icon
:
topAccountsIcon
,
isActive
:
pathname
===
'
/accounts
'
,
isNewUi
:
true
},
{
text
:
'
Blocks
'
,
nextRoute
:
{
pathname
:
'
/blocks
'
as
const
},
icon
:
blocksIcon
,
isActive
:
pathname
.
startsWith
(
'
/block
'
),
isNewUi
:
true
},
{
text
:
'
Transactions
'
,
nextRoute
:
{
pathname
:
'
/txs
'
as
const
},
icon
:
transactionsIcon
,
isActive
:
pathname
.
startsWith
(
'
/tx
'
),
isNewUi
:
true
},
...
...
ui/snippets/navigation/NavLinkGroupDesktop.tsx
View file @
591c0ead
...
...
@@ -13,25 +13,14 @@ import {
import
React
from
'
react
'
;
import
chevronIcon
from
'
icons/arrows/east-mini.svg
'
;
import
type
{
NavGroupItem
}
from
'
lib/hooks/useNavItems
'
;
import
getDefaultTransitionProps
from
'
theme/utils/getDefaultTransitionProps
'
;
import
NavLink
from
'
./NavLink
'
;
import
useColors
from
'
./useColors
'
;
type
NavigationLink
=
{
text
:
string
;
url
:
string
;
icon
:
React
.
FunctionComponent
<
React
.
SVGAttributes
<
SVGElement
>>
;
isNewUi
:
boolean
;
isActive
:
boolean
;
}
interface
Props
{
type
Props
=
NavGroupItem
&
{
isCollapsed
?:
boolean
;
isActive
?:
boolean
;
subItems
:
Array
<
NavigationLink
>
;
text
:
string
;
icon
:
React
.
FunctionComponent
<
React
.
SVGAttributes
<
SVGElement
>>
;
}
const
NavLinkGroupDesktop
=
({
text
,
subItems
,
icon
,
isCollapsed
,
isActive
}:
Props
)
=>
{
...
...
ui/snippets/navigation/NavLinkGroupMobile.tsx
View file @
591c0ead
...
...
@@ -8,24 +8,13 @@ import {
import
React
from
'
react
'
;
import
chevronIcon
from
'
icons/arrows/east-mini.svg
'
;
import
type
{
NavGroupItem
}
from
'
lib/hooks/useNavItems
'
;
import
getDefaultTransitionProps
from
'
theme/utils/getDefaultTransitionProps
'
;
import
useColors
from
'
./useColors
'
;
type
NavigationLink
=
{
text
:
string
;
url
:
string
;
icon
:
React
.
FunctionComponent
<
React
.
SVGAttributes
<
SVGElement
>>
;
isNewUi
:
boolean
;
isActive
:
boolean
;
}
interface
Props
{
type
Props
=
NavGroupItem
&
{
isCollapsed
?:
boolean
;
isActive
?:
boolean
;
subItems
:
Array
<
NavigationLink
>
;
text
:
string
;
icon
:
React
.
FunctionComponent
<
React
.
SVGAttributes
<
SVGElement
>>
;
onClick
:
()
=>
void
;
}
...
...
ui/snippets/navigation/NavigationDesktop.tsx
View file @
591c0ead
...
...
@@ -5,7 +5,7 @@ import appConfig from 'configs/app/config';
import
chevronIcon
from
'
icons/arrows/east-mini.svg
'
;
import
{
useAppContext
}
from
'
lib/appContext
'
;
import
*
as
cookies
from
'
lib/cookies
'
;
import
useNavItems
from
'
lib/hooks/useNavItems
'
;
import
useNavItems
,
{
isGroupItem
}
from
'
lib/hooks/useNavItems
'
;
import
getDefaultTransitionProps
from
'
theme/utils/getDefaultTransitionProps
'
;
import
NetworkLogo
from
'
ui/snippets/networkMenu/NetworkLogo
'
;
import
NetworkMenu
from
'
ui/snippets/networkMenu/NetworkMenu
'
;
...
...
@@ -80,7 +80,7 @@ const NavigationDesktop = () => {
<
Box
as=
"nav"
mt=
{
8
}
>
<
VStack
as=
"ul"
spacing=
"1"
alignItems=
"flex-start"
>
{
mainNavItems
.
map
((
item
)
=>
{
if
(
i
tem
.
subItems
)
{
if
(
i
sGroupItem
(
item
)
)
{
return
<
NavLinkGroupDesktop
key=
{
item
.
text
}
{
...
item
}
isCollapsed=
{
isCollapsed
}
/>;
}
else
{
return
<
NavLink
key=
{
item
.
text
}
{
...
item
}
isCollapsed=
{
isCollapsed
}
/>;
...
...
ui/snippets/navigation/NavigationMobile.tsx
View file @
591c0ead
...
...
@@ -5,7 +5,7 @@ import React, { useCallback } from 'react';
import
appConfig
from
'
configs/app/config
'
;
import
chevronIcon
from
'
icons/arrows/east-mini.svg
'
;
import
*
as
cookies
from
'
lib/cookies
'
;
import
useNavItems
from
'
lib/hooks/useNavItems
'
;
import
useNavItems
,
{
isGroupItem
}
from
'
lib/hooks/useNavItems
'
;
import
NavFooter
from
'
ui/snippets/navigation/NavFooter
'
;
import
NavLink
from
'
ui/snippets/navigation/NavLink
'
;
...
...
@@ -35,6 +35,8 @@ const NavigationMobile = () => {
const
iconColor
=
useColorModeValue
(
'
blue.600
'
,
'
blue.300
'
);
const
openedItem
=
mainNavItems
[
openedGroupIndex
];
return
(
<>
<
Box
position=
"relative"
>
...
...
@@ -50,7 +52,7 @@ const NavigationMobile = () => {
alignItems=
"flex-start"
>
{
mainNavItems
.
map
((
item
,
index
)
=>
{
if
(
i
tem
.
subItems
)
{
if
(
i
sGroupItem
(
item
)
)
{
return
<
NavLinkGroupMobile
key=
{
item
.
text
}
{
...
item
}
onClick=
{
onGroupItemOpen
(
index
)
}
/>;
}
else
{
return
<
NavLink
key=
{
item
.
text
}
{
...
item
}
/>;
...
...
@@ -88,7 +90,7 @@ const NavigationMobile = () => {
<
Icon
as=
{
chevronIcon
}
boxSize=
{
6
}
mr=
{
2
}
color=
{
iconColor
}
/>
<
Text
variant=
"secondary"
fontSize=
"sm"
>
{
mainNavItems
[
openedGroupIndex
].
text
}
</
Text
>
</
Flex
>
{
mainNavItems
[
openedGroupIndex
]
.
subItems
?.
map
((
item
)
=>
<
NavLink
key=
{
item
.
text
}
{
...
item
}
/>)
}
{
isGroupItem
(
openedItem
)
&&
openedItem
.
subItems
?.
map
((
item
)
=>
<
NavLink
key=
{
item
.
text
}
{
...
item
}
/>)
}
</
VStack
>
</
Box
>
)
}
...
...
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