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
5dd0d773
Commit
5dd0d773
authored
Aug 13, 2022
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
useBathPath hook
parent
a79bf3ea
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
17 deletions
+26
-17
useBasePath.tsx
lib/hooks/useBasePath.tsx
+6
-0
SearchBar.tsx
ui/header/SearchBar.tsx
+5
-2
Navigation.tsx
ui/navigation/Navigation.tsx
+12
-11
NetworkMenuPopup.tsx
ui/navigation/networkMenu/NetworkMenuPopup.tsx
+3
-4
No files found.
lib/hooks/useBasePath.tsx
0 → 100644
View file @
5dd0d773
import
{
useRouter
}
from
'
next/router
'
;
export
default
function
useBasePath
()
{
const
router
=
useRouter
();
return
`/
${
router
.
query
.
network_name
}
/
${
router
.
query
.
network_type
}
`
;
}
ui/header/SearchBar.tsx
View file @
5dd0d773
...
...
@@ -3,8 +3,11 @@ import { InputGroup, Input, InputLeftAddon, InputLeftElement, useColorModeValue
import
type
{
ChangeEvent
,
FormEvent
}
from
'
react
'
;
import
React
from
'
react
'
;
import
useBasePath
from
'
lib/hooks/useBasePath
'
;
const
SearchBar
=
()
=>
{
const
[
value
,
setValue
]
=
React
.
useState
(
''
);
const
basePath
=
useBasePath
();
const
handleChange
=
React
.
useCallback
((
event
:
ChangeEvent
<
HTMLInputElement
>
)
=>
{
setValue
(
event
.
target
.
value
);
...
...
@@ -12,8 +15,8 @@ const SearchBar = () => {
const
handleSubmit
=
React
.
useCallback
((
event
:
FormEvent
<
HTMLFormElement
>
)
=>
{
event
.
preventDefault
();
window
.
location
.
assign
(
`https://blockscout.com
/xdai/mainnet
/search-results?q=
${
value
}
`
);
},
[
value
]);
window
.
location
.
assign
(
`https://blockscout.com
${
basePath
}
/search-results?q=
${
value
}
`
);
},
[
value
,
basePath
]);
return
(
<
form
noValidate
onSubmit=
{
handleSubmit
}
>
...
...
ui/navigation/Navigation.tsx
View file @
5dd0d773
...
...
@@ -15,6 +15,7 @@ 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
useBasePath
from
'
lib/hooks/useBasePath
'
;
import
getDefaultTransitionProps
from
'
theme/utils/getDefaultTransitionProps
'
;
import
NavFooter
from
'
./NavFooter
'
;
...
...
@@ -23,22 +24,22 @@ import NetworkMenu from './networkMenu/NetworkMenu';
const
Navigation
=
()
=>
{
const
router
=
useRouter
();
const
basePath
Name
=
`/
${
router
.
query
.
network_name
}
/
${
router
.
query
.
network_type
}
`
;
const
basePath
=
useBasePath
()
;
const
mainNavItems
=
[
{
text
:
'
Blocks
'
,
pathname
:
basePath
Name
+
'
/blocks
'
,
icon
:
blocksIcon
},
{
text
:
'
Transactions
'
,
pathname
:
basePath
Name
+
'
/transactions
'
,
icon
:
transactionsIcon
},
{
text
:
'
Tokens
'
,
pathname
:
basePath
Name
+
'
/tokens
'
,
icon
:
tokensIcon
},
{
text
:
'
Apps
'
,
pathname
:
basePath
Name
+
'
/apps
'
,
icon
:
appsIcon
},
{
text
:
'
Other
'
,
pathname
:
basePath
Name
+
'
/other
'
,
icon
:
gearIcon
},
{
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
Name
+
'
/watchlist
'
,
icon
:
watchlistIcon
},
{
text
:
'
Private tags
'
,
pathname
:
basePath
Name
+
'
/private-tags
'
,
icon
:
privateTagIcon
},
{
text
:
'
Public tags
'
,
pathname
:
basePath
Name
+
'
/public-tags
'
,
icon
:
publicTagIcon
},
{
text
:
'
API keys
'
,
pathname
:
basePath
Name
+
'
/api-keys
'
,
icon
:
apiKeysIcon
},
{
text
:
'
Custom ABI
'
,
pathname
:
basePath
Name
+
'
/custom-abi
'
,
icon
:
abiIcon
},
{
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
'
);
...
...
ui/navigation/networkMenu/NetworkMenuPopup.tsx
View file @
5dd0d773
import
{
PopoverContent
,
PopoverBody
,
Text
,
Tabs
,
TabList
,
TabPanels
,
TabPanel
,
Tab
,
VStack
,
useColorModeValue
}
from
'
@chakra-ui/react
'
;
import
{
useRouter
}
from
'
next/router
'
;
import
React
from
'
react
'
;
import
type
{
NetworkLink
}
from
'
./types
'
;
...
...
@@ -12,6 +11,7 @@ import gnosisIcon from 'icons/networks/gnosis.svg';
import
poaSokolIcon
from
'
icons/networks/poa-sokol.svg
'
;
import
poaIcon
from
'
icons/networks/poa.svg
'
;
import
rskIcon
from
'
icons/networks/rsk.svg
'
;
import
useBasePath
from
'
lib/hooks/useBasePath
'
;
import
NetworkMenuLink
from
'
./NetworkMenuLink
'
;
...
...
@@ -20,11 +20,10 @@ type PopupTab = 'mainnets' | 'testnets' | 'other';
const
TABS
:
Array
<
PopupTab
>
=
[
'
mainnets
'
,
'
testnets
'
,
'
other
'
];
const
NetworkMenuPopup
=
()
=>
{
const
router
=
useRouter
();
const
gnosisChainIconColor
=
useColorModeValue
(
'
black
'
,
'
white
'
);
const
poaChainIconColor
=
useColorModeValue
(
'
gray.100
'
,
'
gray.100
'
);
const
basePath
Name
=
`/
${
router
.
query
.
network_name
}
/
${
router
.
query
.
network_type
}
`
;
const
basePath
=
useBasePath
()
;
const
LINKS
:
Record
<
PopupTab
,
Array
<
NetworkLink
>>
=
{
mainnets
:
[
...
...
@@ -58,7 +57,7 @@ const NetworkMenuPopup = () => {
{
TABS
.
map
((
tab
)
=>
(
<
TabPanel
key=
{
tab
}
p=
{
0
}
>
<
VStack
as=
"ul"
spacing=
{
2
}
alignItems=
"stretch"
mt=
{
4
}
>
{
LINKS
[
tab
].
map
((
link
)
=>
<
NetworkMenuLink
key=
{
link
.
name
}
{
...
link
}
isActive=
{
basePath
Name
===
link
.
pathname
}
/>)
}
{
LINKS
[
tab
].
map
((
link
)
=>
<
NetworkMenuLink
key=
{
link
.
name
}
{
...
link
}
isActive=
{
basePath
===
link
.
pathname
}
/>)
}
</
VStack
>
</
TabPanel
>
))
}
...
...
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