Feat/48-mobile-experience (#194)
* Mobile nav * Made the logo into a link to the home route * Bit of padding on transaction table cells to avoid smooshing
This commit is contained in:
parent
c4d10d04af
commit
1f14b4fbe1
@ -1,3 +1,5 @@
|
|||||||
|
import { useState, useEffect, useMemo } from 'react';
|
||||||
|
import { useLocation } from 'react-router';
|
||||||
import { ApolloProvider } from '@apollo/client';
|
import { ApolloProvider } from '@apollo/client';
|
||||||
import { ThemeContext } from '@vegaprotocol/react-helpers';
|
import { ThemeContext } from '@vegaprotocol/react-helpers';
|
||||||
import { useThemeSwitcher } from '@vegaprotocol/react-helpers';
|
import { useThemeSwitcher } from '@vegaprotocol/react-helpers';
|
||||||
@ -5,26 +7,37 @@ import { createClient } from './lib/apollo-client';
|
|||||||
import { Nav } from './components/nav';
|
import { Nav } from './components/nav';
|
||||||
import { Header } from './components/header';
|
import { Header } from './components/header';
|
||||||
import { Main } from './components/main';
|
import { Main } from './components/main';
|
||||||
import React from 'react';
|
|
||||||
import { DATA_SOURCES } from './config';
|
import { DATA_SOURCES } from './config';
|
||||||
import { TendermintWebsocketProvider } from './contexts/websocket/tendermint-websocket-provider';
|
import { TendermintWebsocketProvider } from './contexts/websocket/tendermint-websocket-provider';
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const [theme, toggleTheme] = useThemeSwitcher();
|
const [theme, toggleTheme] = useThemeSwitcher();
|
||||||
|
const [menuOpen, setMenuOpen] = useState(false);
|
||||||
|
|
||||||
const client = React.useMemo(
|
const location = useLocation();
|
||||||
() => createClient(DATA_SOURCES.dataNodeUrl),
|
|
||||||
[]
|
useEffect(() => {
|
||||||
);
|
setMenuOpen(false);
|
||||||
|
}, [location]);
|
||||||
|
|
||||||
|
const client = useMemo(() => createClient(DATA_SOURCES.dataNodeUrl), []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ThemeContext.Provider value={theme}>
|
<ThemeContext.Provider value={theme}>
|
||||||
<TendermintWebsocketProvider>
|
<TendermintWebsocketProvider>
|
||||||
<ApolloProvider client={client}>
|
<ApolloProvider client={client}>
|
||||||
<div className="antialiased m-0 bg-white dark:bg-black text-black dark:text-white ">
|
<div
|
||||||
<div className="min-h-[100vh] max-w-[1300px] grid grid-rows-[auto_minmax(700px,_1fr)] grid-cols-[300px_minmax(auto,_1fr)] border-black dark:border-white lg:border-l-1 lg:border-r-1 mx-auto">
|
className={`${
|
||||||
<Nav />
|
menuOpen && 'h-[100vh] overflow-hidden'
|
||||||
<Header toggleTheme={toggleTheme} />
|
} antialiased m-0 bg-white dark:bg-black text-black dark:text-white`}
|
||||||
|
>
|
||||||
|
<div className="min-h-[100vh] max-w-[1300px] grid grid-rows-[repeat(2,_auto)_1fr] grid-cols-[1fr] md:grid-rows-[auto_minmax(700px,_1fr)] md:grid-cols-[300px_1fr] border-black dark:border-white lg:border-l-1 lg:border-r-1 mx-auto">
|
||||||
|
<Header
|
||||||
|
toggleTheme={toggleTheme}
|
||||||
|
menuOpen={menuOpen}
|
||||||
|
setMenuOpen={setMenuOpen}
|
||||||
|
/>
|
||||||
|
<Nav menuOpen={menuOpen} />
|
||||||
<Main />
|
<Main />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,20 +1,34 @@
|
|||||||
import { ThemeSwitcher } from '@vegaprotocol/ui-toolkit';
|
import type { Dispatch, SetStateAction } from 'react';
|
||||||
|
import { Link } from 'react-router-dom';
|
||||||
|
import { ThemeSwitcher, Icon } from '@vegaprotocol/ui-toolkit';
|
||||||
import { t } from '@vegaprotocol/react-helpers';
|
import { t } from '@vegaprotocol/react-helpers';
|
||||||
import { Search } from '../search';
|
import { Search } from '../search';
|
||||||
|
import { Routes } from '../../routes/router-config';
|
||||||
|
|
||||||
interface ThemeToggleProps {
|
interface ThemeToggleProps {
|
||||||
toggleTheme: () => void;
|
toggleTheme: () => void;
|
||||||
|
menuOpen: boolean;
|
||||||
|
setMenuOpen: Dispatch<SetStateAction<boolean>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Header = ({ toggleTheme }: ThemeToggleProps) => {
|
export const Header = ({
|
||||||
|
toggleTheme,
|
||||||
|
menuOpen,
|
||||||
|
setMenuOpen,
|
||||||
|
}: ThemeToggleProps) => {
|
||||||
return (
|
return (
|
||||||
<header className="flex items-center px-16 py-16 border-b-1 col-start-1 col-end-3 row-start-1 row-end-2">
|
<header className="grid grid-rows-2 grid-cols-[1fr_auto] md:flex md:col-span-2 p-16 gap-12 border-b-1">
|
||||||
|
<Link to={Routes.HOME}>
|
||||||
<h1
|
<h1
|
||||||
className="text-h3 font-alpha uppercase calt"
|
className="text-h3 font-alpha uppercase calt"
|
||||||
data-testid="explorer-header"
|
data-testid="explorer-header"
|
||||||
>
|
>
|
||||||
{t('Vega Explorer')}
|
{t('Vega Explorer')}
|
||||||
</h1>
|
</h1>
|
||||||
|
</Link>
|
||||||
|
<button className="md:hidden" onClick={() => setMenuOpen(!menuOpen)}>
|
||||||
|
<Icon name={menuOpen ? 'cross' : 'menu'} size={20} />
|
||||||
|
</button>
|
||||||
<Search />
|
<Search />
|
||||||
<ThemeSwitcher onToggle={toggleTheme} />
|
<ThemeSwitcher onToggle={toggleTheme} />
|
||||||
</header>
|
</header>
|
||||||
|
@ -2,7 +2,7 @@ import { AppRouter } from '../../routes';
|
|||||||
|
|
||||||
export const Main = () => {
|
export const Main = () => {
|
||||||
return (
|
return (
|
||||||
<main className="p-20 col-start-2 col-end-2 row-start-2 row-end-3 overflow-hidden">
|
<main className="p-20 overflow-hidden">
|
||||||
<AppRouter />
|
<AppRouter />
|
||||||
</main>
|
</main>
|
||||||
);
|
);
|
||||||
|
@ -1,9 +1,18 @@
|
|||||||
import { NavLink } from 'react-router-dom';
|
import { NavLink } from 'react-router-dom';
|
||||||
import routerConfig from '../../routes/router-config';
|
import routerConfig from '../../routes/router-config';
|
||||||
|
|
||||||
export const Nav = () => {
|
interface NavProps {
|
||||||
|
menuOpen: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const Nav = ({ menuOpen }: NavProps) => {
|
||||||
return (
|
return (
|
||||||
<nav className="border-r-1 p-20 col-start-1 col-end-1 row-start-2 row-end-3 overflow-hidden">
|
<nav className="relative">
|
||||||
|
<div
|
||||||
|
className={`${
|
||||||
|
menuOpen ? 'right-0' : 'right-[200vw]'
|
||||||
|
} transition-all absolute top-0 h-[100vh] w-full md:static md:border-r-1 bg-white dark:bg-black p-20`}
|
||||||
|
>
|
||||||
{routerConfig.map((r) => (
|
{routerConfig.map((r) => (
|
||||||
<NavLink
|
<NavLink
|
||||||
key={r.name}
|
key={r.name}
|
||||||
@ -17,6 +26,7 @@ export const Nav = () => {
|
|||||||
{r.text}
|
{r.text}
|
||||||
</NavLink>
|
</NavLink>
|
||||||
))}
|
))}
|
||||||
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -53,9 +53,9 @@ export const Search = () => {
|
|||||||
return (
|
return (
|
||||||
<form
|
<form
|
||||||
onSubmit={handleSubmit(onSubmit)}
|
onSubmit={handleSubmit(onSubmit)}
|
||||||
className="flex-1 flex ml-16 mr-12 justify-end"
|
className="flex-1 flex self-center md:ml-16 md:mr-12 md:justify-end"
|
||||||
>
|
>
|
||||||
<FormGroup className="relative w-2/3 mb-0">
|
<FormGroup className="relative w-full md:w-2/3 mb-0">
|
||||||
<Input
|
<Input
|
||||||
{...register('search')}
|
{...register('search')}
|
||||||
id="search"
|
id="search"
|
||||||
|
@ -50,7 +50,7 @@ export const TxsPerBlock = ({ blockHeight }: TxsPerBlockProps) => {
|
|||||||
key={TxHash}
|
key={TxHash}
|
||||||
data-testid="transaction-row"
|
data-testid="transaction-row"
|
||||||
>
|
>
|
||||||
<TableCell modifier="bordered">
|
<TableCell modifier="bordered" className="pr-12">
|
||||||
<TruncatedLink
|
<TruncatedLink
|
||||||
to={`/${Routes.TX}/${TxHash}`}
|
to={`/${Routes.TX}/${TxHash}`}
|
||||||
text={TxHash}
|
text={TxHash}
|
||||||
@ -58,7 +58,7 @@ export const TxsPerBlock = ({ blockHeight }: TxsPerBlockProps) => {
|
|||||||
endChars={truncateLength}
|
endChars={truncateLength}
|
||||||
/>
|
/>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell modifier="bordered">
|
<TableCell modifier="bordered" className="pr-12">
|
||||||
<TruncatedLink
|
<TruncatedLink
|
||||||
to={`/${Routes.PARTIES}/${PubKey}`}
|
to={`/${Routes.PARTIES}/${PubKey}`}
|
||||||
text={PubKey}
|
text={PubKey}
|
||||||
|
Loading…
Reference in New Issue
Block a user