new grid layout

This commit is contained in:
Matthias Kretschmann 2022-10-18 15:45:01 +01:00
parent 15d288ee6a
commit 2bd57735b8
Signed by: m
GPG Key ID: 606EEEF3C479A91F
2 changed files with 31 additions and 87 deletions

View File

@ -1,9 +1,10 @@
import Head from 'next/head' import Head from 'next/head'
import React, { ReactElement, useEffect, useState } from 'react' import React, { Fragment, ReactElement, useEffect, useState } from 'react'
import { Status, State, Summary, NetworkSummary } from '../@types' import { Status, State, Summary, NetworkSummary } from '../@types'
import styles from '../styles/Home.module.css' import styles from '../styles/Home.module.css'
import { getData, getNetworkSUmmary, getSummary } from '../utils/getData' import { getData, getNetworkSUmmary, getSummary } from '../utils/getData'
import LogoAsset from '../images/logo.svg' import LogoAsset from '../images/logo.svg'
import Image from 'next/image'
function statusIcon(state: State): string { function statusIcon(state: State): string {
if (state === State.Up) { if (state === State.Up) {
@ -48,17 +49,20 @@ export default function HomePage(): ReactElement {
<meta name="description" content="Generated by create next app" /> <meta name="description" content="Generated by create next app" />
<link rel="icon" href="/favicon.ico" /> <link rel="icon" href="/favicon.ico" />
</Head> </Head>
<main className={styles.main}>
<header>
<LogoAsset className={styles.logo} /> <LogoAsset className={styles.logo} />
<h1 className={styles.title}>Ocean Status</h1> <h1 className={styles.title}>Ocean Status</h1>
<p className={styles.description}> <p className={styles.description}>
Current Status of Ocean Components{' '} Current Status of Ocean Components{' '}
</p> </p>
</header>
<main>
{networks?.map((network: NetworkSummary, i: number) => ( {networks?.map((network: NetworkSummary, i: number) => (
<> <Fragment key={i}>
<h2>{network.name}</h2> <h2 className={styles.networkName}>{network.name}</h2>
<div className={styles.grid}> <div className={styles.grid}>
{summary?.map((value: Summary) => ( {summary?.map((value: Summary) => (
@ -71,7 +75,7 @@ export default function HomePage(): ReactElement {
</div> </div>
))} ))}
</div> </div>
</> </Fragment>
// <button // <button
// key={i} // key={i}
// className={`${styles.network} ${networkStyle(network.name)}`} // className={`${styles.network} ${networkStyle(network.name)}`}

View File

@ -1,19 +1,10 @@
.container { .container {
padding: 0 2rem; padding: var(--spacer);
margin: 0 auto; margin: 0 auto;
max-width: 40rem;
}
.main {
min-height: 100vh;
padding: 2rem 0;
font-family: 'Sharp Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI',
Helvetica, Arial, sans-serif;
} }
.footer { .footer {
padding: 2rem 0; padding: 2rem 0;
border-top: 1px solid #eaeaea;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
} }
@ -30,83 +21,27 @@
} }
.description { .description {
line-height: 1.5; font-size: var(--font-size-large);
font-size: 1.5rem;
}
.code {
background: #fafafa;
border-radius: 5px;
padding: 0.75rem;
font-size: 1.1rem;
font-family: Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono,
Bitstream Vera Sans Mono, Courier New, monospace;
} }
.grid { .grid {
display: flex; display: grid;
align-items: center; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
justify-content: center; gap: var(--spacer);
flex-wrap: wrap; }
max-width: 800px;
.networkName {
margin-top: calc(var(--spacer) * 2);
text-transform: capitalize;
} }
.card { .card {
margin: 1rem;
padding: 1.5rem; padding: 1.5rem;
text-align: left; text-align: left;
color: inherit; color: inherit;
text-decoration: none; text-decoration: none;
border-radius: 10px; border-radius: 10px;
transition: color 0.15s ease, border-color 0.15s ease; transition: color 0.15s ease, border-color 0.15s ease;
max-width: 300px;
min-width: 150px;
}
.network {
display: inline-block;
border: 1px solid;
border-radius: 0.2rem;
margin-right: calc(2rem / 6);
margin-bottom: calc(2rem / 6);
padding: calc(2rem / 6);
box-shadow: none;
cursor: pointer;
width: fit-content;
min-width: auto;
text-align: center;
text-transform: uppercase;
font-size: 0.85rem;
font-weight: 600;
transition: 0.2s ease-out;
}
.networkUnselected {
color: #8b98a9;
background: #fff;
border-color: #e2e2e2;
}
.networkUnselected:hover {
color: #41474e;
}
.networkSelected {
color: #fcfcfc;
background: #41474e;
border-color: #fcfcfc;
}
.up {
border: 2px solid #5fb359;
}
.warning {
border: 2px solid #eac146;
}
.down {
border: 2px solid #d80606;
} }
.card h2 { .card h2 {
@ -122,14 +57,19 @@
.logo { .logo {
fill: var(--font-color-heading); fill: var(--font-color-heading);
height: 3rem; height: 4rem;
width: 3rem; width: 4rem;
margin: 0 auto; margin: 0 auto;
} }
@media (max-width: 600px) { .up {
.grid { border: 2px solid #5fb359;
width: 100%;
flex-direction: column;
} }
.warning {
border: 2px solid #eac146;
}
.down {
border: 2px solid #d80606;
} }