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
c4669d53
Commit
c4669d53
authored
Aug 26, 2022
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
navigation links
parent
0385fabf
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
110 additions
and
43 deletions
+110
-43
useNavItems.tsx
lib/hooks/useNavItems.tsx
+37
-0
Burger.tsx
ui/header/Burger.tsx
+44
-9
NavFooter.tsx
ui/navigation/NavFooter.tsx
+15
-4
NavLink.tsx
ui/navigation/NavLink.tsx
+11
-2
Navigation.tsx
ui/navigation/Navigation.tsx
+2
-27
Page.tsx
ui/shared/Page/Page.tsx
+1
-1
No files found.
lib/hooks/useNavItems.tsx
0 → 100644
View file @
c4669d53
import
React
from
'
react
'
;
import
abiIcon
from
'
icons/ABI.svg
'
;
import
apiKeysIcon
from
'
icons/API.svg
'
;
import
appsIcon
from
'
icons/apps.svg
'
;
import
blocksIcon
from
'
icons/block.svg
'
;
import
gearIcon
from
'
icons/gear.svg
'
;
import
privateTagIcon
from
'
icons/privattags.svg
'
;
import
publicTagIcon
from
'
icons/publictags.svg
'
;
import
tokensIcon
from
'
icons/token.svg
'
;
import
transactionsIcon
from
'
icons/transactions.svg
'
;
import
watchlistIcon
from
'
icons/watchlist.svg
'
;
import
useBasePath
from
'
lib/hooks/useBasePath
'
;
export
default
function
useNavItems
()
{
const
basePath
=
useBasePath
();
return
React
.
useMemo
(()
=>
{
const
mainNavItems
=
[
{
text
:
'
Blocks
'
,
pathname
:
basePath
+
'
/blocks
'
,
icon
:
blocksIcon
},
{
text
:
'
Transactions
'
,
pathname
:
basePath
+
'
/transactions
'
,
icon
:
transactionsIcon
},
{
text
:
'
Tokens
'
,
pathname
:
basePath
+
'
/tokens
'
,
icon
:
tokensIcon
},
{
text
:
'
Apps
'
,
pathname
:
basePath
+
'
/apps
'
,
icon
:
appsIcon
},
{
text
:
'
Other
'
,
pathname
:
basePath
+
'
/other
'
,
icon
:
gearIcon
},
];
const
accountNavItems
=
[
{
text
:
'
Watchlist
'
,
pathname
:
basePath
+
'
/watchlist
'
,
icon
:
watchlistIcon
},
{
text
:
'
Private tags
'
,
pathname
:
basePath
+
'
/private-tags
'
,
icon
:
privateTagIcon
},
{
text
:
'
Public tags
'
,
pathname
:
basePath
+
'
/public-tags
'
,
icon
:
publicTagIcon
},
{
text
:
'
API keys
'
,
pathname
:
basePath
+
'
/api-keys
'
,
icon
:
apiKeysIcon
},
{
text
:
'
Custom ABI
'
,
pathname
:
basePath
+
'
/custom-abi
'
,
icon
:
abiIcon
},
];
return
{
mainNavItems
,
accountNavItems
};
},
[
basePath
]);
}
ui/header/Burger.tsx
View file @
c4669d53
import
{
Icon
,
Box
,
useColorModeValue
}
from
'
@chakra-ui/react
'
;
import
{
Icon
,
Box
,
Flex
,
VStack
,
Drawer
,
DrawerOverlay
,
DrawerContent
,
DrawerBody
,
useColorModeValue
,
useDisclosure
}
from
'
@chakra-ui/react
'
;
import
{
useRouter
}
from
'
next/router
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
burgerIcon
from
'
icons/burger.svg
'
;
import
burgerIcon
from
'
icons/burger.svg
'
;
import
useNavItems
from
'
lib/hooks/useNavItems
'
;
import
NavFooter
from
'
ui/navigation/NavFooter
'
;
import
NavLink
from
'
ui/navigation/NavLink
'
;
import
NetworkLogo
from
'
ui/navigation/NetworkLogo
'
;
const
Burger
=
()
=>
{
const
Burger
=
()
=>
{
const
iconColor
=
useColorModeValue
(
'
gray.600
'
,
'
white
'
);
const
iconColor
=
useColorModeValue
(
'
gray.600
'
,
'
white
'
);
const
{
isOpen
,
onOpen
,
onClose
}
=
useDisclosure
();
const
{
mainNavItems
,
accountNavItems
}
=
useNavItems
();
const
router
=
useRouter
();
return
(
return
(
<
Box
padding=
{
2
}
>
<>
<
Icon
<
Box
padding=
{
2
}
onClick=
{
onOpen
}
>
as=
{
burgerIcon
}
<
Icon
boxSize=
{
6
}
as=
{
burgerIcon
}
display=
"block"
boxSize=
{
6
}
color=
{
iconColor
}
display=
"block"
/>
color=
{
iconColor
}
</
Box
>
/>
</
Box
>
<
Drawer
isOpen=
{
isOpen
}
placement=
"left"
onClose=
{
onClose
}
>
<
DrawerOverlay
bgColor=
"blackAlpha.800"
/>
<
DrawerContent
maxWidth=
"260px"
>
<
DrawerBody
p=
{
6
}
>
<
Flex
>
<
NetworkLogo
/>
</
Flex
>
<
Box
as=
"nav"
mt=
{
8
}
>
<
VStack
as=
"ul"
spacing=
"2"
alignItems=
"flex-start"
overflow=
"hidden"
>
{
mainNavItems
.
map
((
item
)
=>
<
NavLink
key=
{
item
.
text
}
{
...
item
}
isActive=
{
router
.
asPath
===
item
.
pathname
}
/>)
}
</
VStack
>
</
Box
>
<
Box
as=
"nav"
mt=
{
6
}
>
<
VStack
as=
"ul"
spacing=
"2"
alignItems=
"flex-start"
overflow=
"hidden"
>
{
accountNavItems
.
map
((
item
)
=>
<
NavLink
key=
{
item
.
text
}
{
...
item
}
isActive=
{
router
.
asPath
===
item
.
pathname
}
/>)
}
</
VStack
>
</
Box
>
<
NavFooter
/>
</
DrawerBody
>
</
DrawerContent
>
</
Drawer
>
</>
);
);
};
};
...
...
ui/navigation/NavFooter.tsx
View file @
c4669d53
...
@@ -5,6 +5,7 @@ import ghIcon from 'icons/social/git.svg';
...
@@ -5,6 +5,7 @@ import ghIcon from 'icons/social/git.svg';
import
statsIcon
from
'
icons/social/stats.svg
'
;
import
statsIcon
from
'
icons/social/stats.svg
'
;
import
tgIcon
from
'
icons/social/telega.svg
'
;
import
tgIcon
from
'
icons/social/telega.svg
'
;
import
twIcon
from
'
icons/social/tweet.svg
'
;
import
twIcon
from
'
icons/social/tweet.svg
'
;
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
import
getDefaultTransitionProps
from
'
theme/utils/getDefaultTransitionProps
'
;
import
getDefaultTransitionProps
from
'
theme/utils/getDefaultTransitionProps
'
;
const
SOCIAL_LINKS
=
[
const
SOCIAL_LINKS
=
[
...
@@ -15,19 +16,29 @@ const SOCIAL_LINKS = [
...
@@ -15,19 +16,29 @@ const SOCIAL_LINKS = [
];
];
interface
Props
{
interface
Props
{
isCollapsed
:
boolean
;
isCollapsed
?
:
boolean
;
}
}
const
NavFooter
=
({
isCollapsed
}:
Props
)
=>
{
const
NavFooter
=
({
isCollapsed
}:
Props
)
=>
{
const
isMobile
=
useIsMobile
();
const
width
=
(()
=>
{
if
(
isMobile
)
{
return
'
100%
'
;
}
return
isCollapsed
?
'
20px
'
:
'
180px
'
;
})();
return
(
return
(
<
VStack
<
VStack
as=
"footer"
as=
"footer"
spacing=
{
8
}
spacing=
{
8
}
borderTop=
"1px solid"
borderTop=
"1px solid"
borderColor=
{
useColorModeValue
(
'
blackAlpha.200
'
,
'
whiteAlpha.200
'
)
}
borderColor=
{
useColorModeValue
(
'
blackAlpha.200
'
,
'
whiteAlpha.200
'
)
}
width=
{
isCollapsed
?
'
20px
'
:
'
180px
'
}
width=
{
width
}
paddingTop=
{
8
}
paddingTop=
{
isMobile
?
6
:
8
}
marginTop=
{
20
}
marginTop=
{
isMobile
?
6
:
20
}
alignItems=
"flex-start"
alignItems=
"flex-start"
color=
"gray.500"
color=
"gray.500"
fontSize=
"xs"
fontSize=
"xs"
...
...
ui/navigation/NavLink.tsx
View file @
c4669d53
...
@@ -2,12 +2,13 @@ import { Link, Icon, Text, HStack, Tooltip } from '@chakra-ui/react';
...
@@ -2,12 +2,13 @@ import { Link, Icon, Text, HStack, Tooltip } from '@chakra-ui/react';
import
NextLink
from
'
next/link
'
;
import
NextLink
from
'
next/link
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
import
getDefaultTransitionProps
from
'
theme/utils/getDefaultTransitionProps
'
;
import
getDefaultTransitionProps
from
'
theme/utils/getDefaultTransitionProps
'
;
import
useColors
from
'
./useColors
'
;
import
useColors
from
'
./useColors
'
;
interface
Props
{
interface
Props
{
isCollapsed
:
boolean
;
isCollapsed
?
:
boolean
;
isActive
:
boolean
;
isActive
:
boolean
;
pathname
:
string
;
pathname
:
string
;
text
:
string
;
text
:
string
;
...
@@ -16,13 +17,21 @@ interface Props {
...
@@ -16,13 +17,21 @@ interface Props {
const
NavLink
=
({
text
,
pathname
,
icon
,
isCollapsed
,
isActive
}:
Props
)
=>
{
const
NavLink
=
({
text
,
pathname
,
icon
,
isCollapsed
,
isActive
}:
Props
)
=>
{
const
colors
=
useColors
();
const
colors
=
useColors
();
const
isMobile
=
useIsMobile
();
const
width
=
(()
=>
{
if
(
isMobile
)
{
return
'
100%
'
;
}
return
isCollapsed
?
'
60px
'
:
'
180px
'
;
})();
return
(
return
(
<
NextLink
href=
{
pathname
}
passHref
>
<
NextLink
href=
{
pathname
}
passHref
>
<
Link
<
Link
as=
"li"
as=
"li"
listStyleType=
"none"
listStyleType=
"none"
w=
{
isCollapsed
?
'
60px
'
:
'
180px
'
}
w=
{
width
}
px=
{
isCollapsed
?
'
15px
'
:
3
}
px=
{
isCollapsed
?
'
15px
'
:
3
}
py=
{
2.5
}
py=
{
2.5
}
color=
{
isActive
?
colors
.
text
.
active
:
colors
.
text
.
default
}
color=
{
isActive
?
colors
.
text
.
active
:
colors
.
text
.
default
}
...
...
ui/navigation/Navigation.tsx
View file @
c4669d53
...
@@ -3,19 +3,9 @@ import { Flex, Box, VStack, useColorModeValue } from '@chakra-ui/react';
...
@@ -3,19 +3,9 @@ import { Flex, Box, VStack, useColorModeValue } from '@chakra-ui/react';
import
{
useRouter
}
from
'
next/router
'
;
import
{
useRouter
}
from
'
next/router
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
abiIcon
from
'
icons/ABI.svg
'
;
import
apiKeysIcon
from
'
icons/API.svg
'
;
import
appsIcon
from
'
icons/apps.svg
'
;
import
blocksIcon
from
'
icons/block.svg
'
;
import
gearIcon
from
'
icons/gear.svg
'
;
import
privateTagIcon
from
'
icons/privattags.svg
'
;
import
publicTagIcon
from
'
icons/publictags.svg
'
;
import
tokensIcon
from
'
icons/token.svg
'
;
import
transactionsIcon
from
'
icons/transactions.svg
'
;
import
watchlistIcon
from
'
icons/watchlist.svg
'
;
import
*
as
cookies
from
'
lib/cookies
'
;
import
*
as
cookies
from
'
lib/cookies
'
;
import
useBasePath
from
'
lib/hooks/useBasePath
'
;
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
import
useNavItems
from
'
lib/hooks/useNavItems
'
;
import
getDefaultTransitionProps
from
'
theme/utils/getDefaultTransitionProps
'
;
import
getDefaultTransitionProps
from
'
theme/utils/getDefaultTransitionProps
'
;
import
NavFooter
from
'
./NavFooter
'
;
import
NavFooter
from
'
./NavFooter
'
;
...
@@ -25,24 +15,9 @@ import NetworkMenu from './networkMenu/NetworkMenu';
...
@@ -25,24 +15,9 @@ import NetworkMenu from './networkMenu/NetworkMenu';
const
Navigation
=
()
=>
{
const
Navigation
=
()
=>
{
const
router
=
useRouter
();
const
router
=
useRouter
();
const
basePath
=
useBasePath
();
const
isMobile
=
useIsMobile
();
const
isMobile
=
useIsMobile
();
const
mainNavItems
=
[
const
{
mainNavItems
,
accountNavItems
}
=
useNavItems
();
{
text
:
'
Blocks
'
,
pathname
:
basePath
+
'
/blocks
'
,
icon
:
blocksIcon
},
{
text
:
'
Transactions
'
,
pathname
:
basePath
+
'
/transactions
'
,
icon
:
transactionsIcon
},
{
text
:
'
Tokens
'
,
pathname
:
basePath
+
'
/tokens
'
,
icon
:
tokensIcon
},
{
text
:
'
Apps
'
,
pathname
:
basePath
+
'
/apps
'
,
icon
:
appsIcon
},
{
text
:
'
Other
'
,
pathname
:
basePath
+
'
/other
'
,
icon
:
gearIcon
},
];
const
accountNavItems
=
[
{
text
:
'
Watchlist
'
,
pathname
:
basePath
+
'
/watchlist
'
,
icon
:
watchlistIcon
},
{
text
:
'
Private tags
'
,
pathname
:
basePath
+
'
/private-tags
'
,
icon
:
privateTagIcon
},
{
text
:
'
Public tags
'
,
pathname
:
basePath
+
'
/public-tags
'
,
icon
:
publicTagIcon
},
{
text
:
'
API keys
'
,
pathname
:
basePath
+
'
/api-keys
'
,
icon
:
apiKeysIcon
},
{
text
:
'
Custom ABI
'
,
pathname
:
basePath
+
'
/custom-abi
'
,
icon
:
abiIcon
},
];
const
[
isCollapsed
,
setCollapsedState
]
=
React
.
useState
(
cookies
.
get
(
cookies
.
NAMES
.
NAV_BAR_COLLAPSED
)
===
'
true
'
);
const
[
isCollapsed
,
setCollapsedState
]
=
React
.
useState
(
cookies
.
get
(
cookies
.
NAMES
.
NAV_BAR_COLLAPSED
)
===
'
true
'
);
...
...
ui/shared/Page/Page.tsx
View file @
c4669d53
...
@@ -19,7 +19,7 @@ const Page = ({ children }: Props) => {
...
@@ -19,7 +19,7 @@ const Page = ({ children }: Props) => {
alignItems=
"stretch"
alignItems=
"stretch"
>
>
<
Navigation
/>
<
Navigation
/>
<
VStack
width=
"100%"
paddingX=
{
isMobile
?
4
:
8
}
paddingTop=
{
isMobile
?
'
104px
'
:
9
}
>
<
VStack
width=
"100%"
paddingX=
{
isMobile
?
4
:
8
}
paddingTop=
{
isMobile
?
'
104px
'
:
9
}
paddingBottom=
{
10
}
>
<
Header
/>
<
Header
/>
<
Box
<
Box
as=
"main"
as=
"main"
...
...
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