Commit 005ba93e authored by tom's avatar tom

new route trees

parent d58f9abc
...@@ -7,4 +7,13 @@ module.exports = withReactSvg({ ...@@ -7,4 +7,13 @@ module.exports = withReactSvg({
webpack(config) { webpack(config) {
return config; return config;
}, },
async redirects() {
return [
{
source: '/',
destination: '/xdai/mainnet',
permanent: true,
},
];
},
}); });
import { Center } from '@chakra-ui/react';
import type { NextPage } from 'next';
import { useRouter } from 'next/router';
import React from 'react';
import Page from 'ui/shared/Page/Page';
const Home: NextPage = () => {
const router = useRouter();
return (
<Page>
<Center h="100%">
home page for { router.query.network_name } { router.query.network_type } network
</Center>
</Page>
);
};
export default Home;
import { Center } from '@chakra-ui/react';
import type { NextPage } from 'next'; import type { NextPage } from 'next';
import React from 'react';
import Page from 'ui/shared/Page/Page';
const Home: NextPage = () => { const Home: NextPage = () => {
return ( return null;
<Page>
<Center h="100%">
Home Page
</Center>
</Page>
);
}; };
export default Home; export default Home;
import { Link, Icon, Text, HStack, Tooltip } from '@chakra-ui/react'; import { Link, Icon, Text, HStack, Tooltip } from '@chakra-ui/react';
import NextLink from 'next/link'; import NextLink from 'next/link';
import { useRouter } from 'next/router';
import React from 'react'; import React from 'react';
import getDefaultTransitionProps from 'theme/utils/getDefaultTransitionProps'; import getDefaultTransitionProps from 'theme/utils/getDefaultTransitionProps';
...@@ -9,15 +8,13 @@ import useColors from './useColors'; ...@@ -9,15 +8,13 @@ import useColors from './useColors';
interface Props { interface Props {
isCollapsed: boolean; isCollapsed: boolean;
isActive: boolean;
pathname: string; pathname: string;
text: string; text: string;
icon: React.FunctionComponent<React.SVGAttributes<SVGElement>>; icon: React.FunctionComponent<React.SVGAttributes<SVGElement>>;
} }
const NavLink = ({ text, pathname, icon, isCollapsed }: Props) => { const NavLink = ({ text, pathname, icon, isCollapsed, isActive }: Props) => {
const router = useRouter();
const isActive = router.pathname === pathname;
const colors = useColors(); const colors = useColors();
return ( return (
......
import { ChevronLeftIcon } from '@chakra-ui/icons'; import { ChevronLeftIcon } from '@chakra-ui/icons';
import { Flex, Icon, Box, VStack, useColorModeValue } from '@chakra-ui/react'; import { Flex, Icon, Box, VStack, useColorModeValue } from '@chakra-ui/react';
import { useRouter } from 'next/router';
import React from 'react'; import React from 'react';
import abiIcon from 'icons/ABI.svg'; import abiIcon from 'icons/ABI.svg';
...@@ -20,23 +21,26 @@ import NavFooter from './NavFooter'; ...@@ -20,23 +21,26 @@ import NavFooter from './NavFooter';
import NavLink from './NavLink'; import NavLink from './NavLink';
import NetworkMenu from './networkMenu/NetworkMenu'; import NetworkMenu from './networkMenu/NetworkMenu';
const mainNavItems = [ const Navigation = () => {
{ text: 'Blocks', pathname: '/blocks', icon: blocksIcon }, const router = useRouter();
{ text: 'Transactions', pathname: '/transactions', icon: transactionsIcon }, const basePathName = `/${ router.query.network_name }/${ router.query.network_type }`;
{ text: 'Tokens', pathname: '/tokens', icon: tokensIcon },
{ text: 'Apps', pathname: '/apps', icon: appsIcon },
{ text: 'Other', pathname: '/other', icon: gearIcon },
];
const accountNavItems = [ const mainNavItems = [
{ text: 'Watchlist', pathname: '/watchlist', icon: watchlistIcon }, { text: 'Blocks', pathname: basePathName + '/blocks', icon: blocksIcon },
{ text: 'Private tags', pathname: '/private-tags', icon: privateTagIcon }, { text: 'Transactions', pathname: basePathName + '/transactions', icon: transactionsIcon },
{ text: 'Public tags', pathname: '/public-tags', icon: publicTagIcon }, { text: 'Tokens', pathname: basePathName + '/tokens', icon: tokensIcon },
{ text: 'API keys', pathname: '/api-keys', icon: apiKeysIcon }, { text: 'Apps', pathname: basePathName + '/apps', icon: appsIcon },
{ text: 'Custom ABI', pathname: '/custom-abi', icon: abiIcon }, { text: 'Other', pathname: basePathName + '/other', icon: gearIcon },
]; ];
const accountNavItems = [
{ text: 'Watchlist', pathname: basePathName + '/watchlist', icon: watchlistIcon },
{ text: 'Private tags', pathname: basePathName + '/private-tags', icon: privateTagIcon },
{ text: 'Public tags', pathname: basePathName + '/public-tags', icon: publicTagIcon },
{ text: 'API keys', pathname: basePathName + '/api-keys', icon: apiKeysIcon },
{ text: 'Custom ABI', pathname: basePathName + '/custom-abi', icon: abiIcon },
];
const Navigation = () => {
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');
const handleTogglerClick = React.useCallback(() => { const handleTogglerClick = React.useCallback(() => {
...@@ -86,12 +90,12 @@ const Navigation = () => { ...@@ -86,12 +90,12 @@ const Navigation = () => {
</Box> </Box>
<Box as="nav" mt={ 14 }> <Box as="nav" mt={ 14 }>
<VStack as="ul" spacing="2" alignItems="flex-start" overflow="hidden"> <VStack as="ul" spacing="2" alignItems="flex-start" overflow="hidden">
{ mainNavItems.map((item) => <NavLink key={ item.text } { ...item } isCollapsed={ isCollapsed }/>) } { mainNavItems.map((item) => <NavLink key={ item.text } { ...item } isCollapsed={ isCollapsed } isActive={ router.asPath === item.pathname }/>) }
</VStack> </VStack>
</Box> </Box>
<Box as="nav" mt={ 12 }> <Box as="nav" mt={ 12 }>
<VStack as="ul" spacing="2" alignItems="flex-start" overflow="hidden"> <VStack as="ul" spacing="2" alignItems="flex-start" overflow="hidden">
{ accountNavItems.map((item) => <NavLink key={ item.text } { ...item } isCollapsed={ isCollapsed }/>) } { accountNavItems.map((item) => <NavLink key={ item.text } { ...item } isCollapsed={ isCollapsed } isActive={ router.asPath === item.pathname }/>) }
</VStack> </VStack>
</Box> </Box>
<NavFooter isCollapsed={ isCollapsed }/> <NavFooter isCollapsed={ isCollapsed }/>
......
...@@ -8,15 +8,17 @@ import checkIcon from 'icons/check.svg'; ...@@ -8,15 +8,17 @@ import checkIcon from 'icons/check.svg';
import useColors from '../useColors'; import useColors from '../useColors';
type Props = NetworkLink; interface Props extends NetworkLink {
isActive: boolean;
}
const NetworkMenuLink = ({ name, url, icon, iconColor }: Props) => { const NetworkMenuLink = ({ name, pathname, icon, iconColor, isActive, isNewUi }: Props) => {
const isActive = name === 'Gnosis Chain';
const colors = useColors(); const colors = useColors();
const href = isNewUi ? pathname : 'https://blockscout.com' + pathname;
return ( return (
<Box as="li" listStyleType="none"> <Box as="li" listStyleType="none">
<NextLink href={ url } passHref> <NextLink href={ href } passHref>
<Flex <Flex
as="a" as="a"
px={ 4 } px={ 4 }
......
import { PopoverContent, PopoverBody, Text, Tabs, TabList, TabPanels, TabPanel, Tab, VStack, useColorModeValue } from '@chakra-ui/react'; 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 React from 'react';
import type { NetworkLink } from './types'; import type { NetworkLink } from './types';
...@@ -19,26 +20,29 @@ type PopupTab = 'mainnets' | 'testnets' | 'other'; ...@@ -19,26 +20,29 @@ type PopupTab = 'mainnets' | 'testnets' | 'other';
const TABS: Array<PopupTab> = [ 'mainnets', 'testnets', 'other' ]; const TABS: Array<PopupTab> = [ 'mainnets', 'testnets', 'other' ];
const NetworkMenuPopup = () => { const NetworkMenuPopup = () => {
const router = useRouter();
const gnosisChainIconColor = useColorModeValue('black', 'white'); const gnosisChainIconColor = useColorModeValue('black', 'white');
const poaChainIconColor = useColorModeValue('gray.100', 'gray.100'); const poaChainIconColor = useColorModeValue('gray.100', 'gray.100');
const basePathName = `/${ router.query.network_name }/${ router.query.network_type }`;
const LINKS: Record<PopupTab, Array<NetworkLink>> = { const LINKS: Record<PopupTab, Array<NetworkLink>> = {
mainnets: [ mainnets: [
{ name: 'Gnosis Chain', url: '/xdai/mainnet', icon: gnosisIcon, iconColor: gnosisChainIconColor }, { name: 'Gnosis Chain', pathname: '/xdai/mainnet', icon: gnosisIcon, iconColor: gnosisChainIconColor, isNewUi: true },
{ name: 'Optimism on Gnosis Chain', url: '/xdai/optimism', icon: gnosisIcon, iconColor: gnosisChainIconColor }, { name: 'Optimism on Gnosis Chain', pathname: '/xdai/optimism', icon: gnosisIcon, iconColor: gnosisChainIconColor },
{ name: 'Arbitrum on xDai', url: '/xdai/aox', icon: arbitrumIcon }, { name: 'Arbitrum on xDai', pathname: '/xdai/aox', icon: arbitrumIcon },
{ name: 'Ethereum', url: '/eth/mainnet', icon: ethereumIcon }, { name: 'Ethereum', pathname: '/eth/mainnet', icon: ethereumIcon },
{ name: 'Ethereum Classic', url: '/etc/mainnet', icon: ethereumClassicIcon }, { name: 'Ethereum Classic', pathname: '/etc/mainnet', icon: ethereumClassicIcon },
{ name: 'POA', url: '/poa/core', icon: poaIcon, iconColor: poaChainIconColor }, { name: 'POA', pathname: '/poa/core', icon: poaIcon, iconColor: poaChainIconColor },
{ name: 'RSK', url: '/rsk/mainnet', icon: rskIcon }, { name: 'RSK', pathname: '/rsk/mainnet', icon: rskIcon },
], ],
testnets: [ testnets: [
{ name: 'Gnosis Chain Testnet', url: '/xdai/testnet', icon: arbitrumIcon }, { name: 'Gnosis Chain Testnet', pathname: '/xdai/testnet', icon: arbitrumIcon },
{ name: 'POA Sokol', url: '/poa/sokol', icon: poaSokolIcon }, { name: 'POA Sokol', pathname: '/poa/sokol', icon: poaSokolIcon },
], ],
other: [ other: [
{ name: 'ARTIS Σ1', url: '/artis/sigma1', icon: artisIcon }, { name: 'ARTIS Σ1', pathname: '/artis/sigma1', icon: artisIcon },
{ name: 'LUKSO L14', url: '/lukso/l14', icon: poaIcon, iconColor: poaChainIconColor }, { name: 'LUKSO L14', pathname: '/lukso/l14', icon: poaIcon, iconColor: poaChainIconColor },
], ],
}; };
...@@ -54,7 +58,7 @@ const NetworkMenuPopup = () => { ...@@ -54,7 +58,7 @@ const NetworkMenuPopup = () => {
{ TABS.map((tab) => ( { TABS.map((tab) => (
<TabPanel key={ tab } p={ 0 }> <TabPanel key={ tab } p={ 0 }>
<VStack as="ul" spacing={ 2 } alignItems="stretch" mt={ 4 }> <VStack as="ul" spacing={ 2 } alignItems="stretch" mt={ 4 }>
{ LINKS[tab].map((link) => <NetworkMenuLink key={ link.name } { ...link }/>) } { LINKS[tab].map((link) => <NetworkMenuLink key={ link.name } { ...link } isActive={ basePathName === link.pathname }/>) }
</VStack> </VStack>
</TabPanel> </TabPanel>
)) } )) }
......
import type { FunctionComponent, SVGAttributes } from 'react'; import type { FunctionComponent, SVGAttributes } from 'react';
export interface NetworkLink { export interface NetworkLink {
url: string; pathname: string;
name: string; name: string;
icon: FunctionComponent<SVGAttributes<SVGElement>>; icon: FunctionComponent<SVGAttributes<SVGElement>>;
iconColor?: string; iconColor?: string;
isNewUi?: boolean;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment