1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-11-15 01:34:57 +01:00

global layout and menu refactor

This commit is contained in:
Matthias Kretschmann 2020-07-09 13:20:50 +02:00
parent 39fb280666
commit 8159b66a52
Signed by: m
GPG Key ID: 606EEEF3C479A91F
11 changed files with 159 additions and 91 deletions

View File

@ -12,10 +12,7 @@
} }
.main { .main {
padding: calc(var(--spacer) * 2) calc(var(--spacer) / 1.5); padding: calc(var(--spacer) * 2) 0;
margin-left: auto;
margin-right: auto;
max-width: var(--layout-max-width);
/* sticky footer technique */ /* sticky footer technique */
flex: 1; flex: 1;

View File

@ -5,6 +5,7 @@ import Footer from './organisms/Footer'
import PageHeader from './molecules/PageHeader' import PageHeader from './molecules/PageHeader'
import styles from './Layout.module.css' import styles from './Layout.module.css'
import Seo from './atoms/Seo' import Seo from './atoms/Seo'
import Container from './atoms/Container'
export interface LayoutProps { export interface LayoutProps {
children: ReactNode children: ReactNode
@ -33,10 +34,12 @@ export default function Layout({
<Header /> <Header />
<main className={styles.main}> <main className={styles.main}>
<Container>
{title && !noPageHeader && ( {title && !noPageHeader && (
<PageHeader title={title} description={description} /> <PageHeader title={title} description={description} />
)} )}
{children} {children}
</Container>
</main> </main>
<Footer /> <Footer />
</div> </div>

View File

@ -0,0 +1,12 @@
.container {
max-width: var(--break-point--large);
margin-left: auto;
margin-right: auto;
padding-left: calc(var(--spacer) / 1.2);
padding-right: calc(var(--spacer) / 1.2);
width: 100%;
}
.container.narrow {
max-width: 42rem;
}

View File

@ -0,0 +1,22 @@
import React, { ReactElement, ReactNode } from 'react'
import styles from './Container.module.css'
export default function Container({
children,
narrow,
className
}: {
children: ReactNode
narrow?: boolean
className?: string
}): ReactElement {
return (
<div
className={`${styles.container} ${narrow && styles.narrow} ${
className && className
}`}
>
{children}
</div>
)
}

View File

@ -1,12 +1,91 @@
.menu { .menu {
width: 100%;
} }
.menu > div, .menu > div {
.link { display: flex;
justify-content: space-between;
align-items: center;
padding-top: calc(var(--spacer) / 2);
padding-bottom: calc(var(--spacer) / 2);
}
.logoUnit {
display: flex;
align-items: center;
}
.logoUnit svg {
fill: var(--color-primary);
width: 4rem;
height: 4rem;
margin-left: -0.5rem;
}
.logoUnit path {
fill: var(--brand-black);
}
.logoUnit:hover path {
fill: var(--brand-pink);
}
.title {
display: none;
}
@media screen and (min-width: 40rem) {
.title {
margin: 0;
display: block;
color: var(--color-secondary);
font-size: var(--font-size-base);
}
.logoUnit svg {
margin-top: -0.4rem;
}
}
@media screen and (min-width: 60rem) {
.title {
font-size: var(--font-size-large);
}
}
.navigation {
white-space: nowrap;
overflow-y: hidden;
overflow-x: auto;
-webkit-overflow-scrolling: touch;
}
.navigation::-webkit-scrollbar,
.navigation::-moz-scrollbar {
display: none;
}
.navigation li {
display: inline-block; display: inline-block;
}
.navigation button,
.link {
display: block;
padding: calc(var(--spacer) / 2);
margin-left: var(--spacer);
text-transform: uppercase;
color: var(--brand-grey); color: var(--brand-grey);
font-weight: var(--font-weight-bold); font-weight: var(--font-weight-bold);
margin: calc(var(--spacer) / 4) var(--spacer); font-size: var(--font-size-small);
position: relative;
z-index: 1;
}
.navigation button {
text-transform: none;
padding-top: calc(var(--spacer) / 4);
padding-bottom: calc(var(--spacer) / 4);
} }
.link:hover, .link:hover,
@ -15,14 +94,12 @@
color: var(--brand-pink); color: var(--brand-pink);
} }
.link.active { .link[aria-current],
.link[aria-current]:hover,
.link[aria-current]:focus {
color: var(--brand-pink); color: var(--brand-pink);
} }
.link:first-child {
margin-left: 0;
}
.link:last-child { .link:last-child {
margin-right: 0; padding-right: 0;
} }

View File

@ -1,9 +1,11 @@
import React from 'react' import React, { ReactElement } from 'react'
import { Link } from 'gatsby' import { Link } from 'gatsby'
import { useLocation } from '@reach/router' import { useLocation } from '@reach/router'
import styles from './Menu.module.css' import styles from './Menu.module.css'
import { useSiteMetadata } from '../../hooks/useSiteMetadata' import { useSiteMetadata } from '../../hooks/useSiteMetadata'
import Wallet from './Wallet' import Wallet from './Wallet'
import { ReactComponent as Logo } from '@oceanprotocol/art/logo/logo.svg'
import Container from '../atoms/Container'
declare type MenuItem = { declare type MenuItem = {
name: string name: string
@ -25,15 +27,28 @@ function MenuLink({ item }: { item: MenuItem }) {
) )
} }
export default function Menu() { export default function Menu(): ReactElement {
const { menu } = useSiteMetadata() const { menu, siteTitle } = useSiteMetadata()
return ( return (
<nav className={styles.menu}> <nav className={styles.menu}>
<Container>
<Link to="/" className={styles.logoUnit}>
<Logo />
<h1 className={styles.title}>{siteTitle}</h1>
</Link>
<ul className={styles.navigation}>
<li>
<Wallet /> <Wallet />
</li>
{menu.map((item: MenuItem) => ( {menu.map((item: MenuItem) => (
<MenuLink key={item.name} item={item} /> <li key={item.name}>
<MenuLink item={item} />
</li>
))} ))}
</ul>
</Container>
</nav> </nav>
) )
} }

View File

@ -5,7 +5,7 @@
text-transform: uppercase; text-transform: uppercase;
border: 1px solid var(--brand-grey-lighter); border: 1px solid var(--brand-grey-lighter);
border-radius: var(--border-radius); border-radius: var(--border-radius);
padding: calc(var(--spacer) / 6) calc(var(--spacer) / 4); padding: calc(var(--spacer) / 4);
white-space: nowrap; white-space: nowrap;
background: none; background: none;
color: var(--brand-grey); color: var(--brand-grey);

View File

@ -6,7 +6,7 @@
@media screen and (min-width: 25rem) { @media screen and (min-width: 25rem) {
.assetList { .assetList {
grid-template-columns: repeat(auto-fit, minmax(25rem, 1fr)); grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
gap: var(--spacer); gap: var(--spacer);
} }
} }

View File

@ -1,55 +1,3 @@
.header { .header {
background-color: var(--brand-white); background-color: var(--brand-white);
} }
.content {
padding: calc(var(--spacer) / 2) var(--spacer);
display: flex;
justify-content: space-between;
align-items: center;
margin-left: auto;
margin-right: auto;
max-width: var(--layout-max-width);
}
.logoUnit {
display: flex;
align-items: center;
}
.logoUnit svg {
fill: var(--color-primary);
width: 4rem;
height: 4rem;
margin-right: calc(var(--spacer) / 2);
}
.logoUnit path {
fill: var(--brand-black);
}
.logoUnit:hover path {
fill: var(--brand-pink);
}
.title {
display: none;
}
@media screen and (min-width: 40rem) {
.title {
margin: 0;
display: block;
color: var(--color-secondary);
font-size: var(--font-size-base);
}
.logoUnit svg {
margin-top: -0.4rem;
}
}
@media screen and (min-width: 60rem) {
.title {
font-size: var(--font-size-large);
}
}

View File

@ -1,23 +1,11 @@
import React, { ReactElement } from 'react' import React, { ReactElement } from 'react'
import { Link } from 'gatsby'
import Menu from '../molecules/Menu' import Menu from '../molecules/Menu'
import styles from './Header.module.css' import styles from './Header.module.css'
import { ReactComponent as Logo } from '@oceanprotocol/art/logo/logo.svg'
import { useSiteMetadata } from '../../hooks/useSiteMetadata'
export default function Header(): ReactElement { export default function Header(): ReactElement {
const { siteTitle } = useSiteMetadata()
return ( return (
<header className={styles.header}> <header className={styles.header}>
<div className={styles.content}>
<Link to="/" className={styles.logoUnit}>
<Logo />
<h1 className={styles.title}>{siteTitle}</h1>
</Link>
<Menu /> <Menu />
</div>
</header> </header>
) )
} }

View File

@ -6,6 +6,12 @@
box-sizing: border-box; box-sizing: border-box;
} }
html,
body {
margin: 0;
padding: 0;
}
html { html {
font-size: var(--font-size-root); font-size: var(--font-size-root);
scroll-behavior: smooth; scroll-behavior: smooth;