1
Fork 0

typescript(loopover-leaderboards): feat: basic navbar

Signed-off-by: prescientmoon <git@moonythm.dev>
This commit is contained in:
Matei Adriel 2019-12-28 22:12:58 +02:00 committed by prescientmoon
parent 37754f1a3f
commit 744c7cf49a
Signed by: prescientmoon
SSH key fingerprint: SHA256:UUF9JT2s8Xfyv76b8ZuVL7XrmimH4o49p4b+iexbVH4
7 changed files with 80 additions and 6 deletions

View file

@ -10,7 +10,8 @@ export default function(config, env, helpers) {
banner: banner:
"// This file is automatically generated from your CSS. Any edits will be overwritten.", "// This file is automatically generated from your CSS. Any edits will be overwritten.",
namedExport: true, namedExport: true,
silent: true silent: true,
modules: true
}); });
}); });

View file

@ -1,4 +1,4 @@
@import url("https://fonts.googleapis.com/css?family=Varela+Round&display=swap"); @import url("https://fonts.googleapis.com/css?family=Roboto|Varela+Round&display=swap");
html, html,
body { body {
@ -13,7 +13,12 @@ body {
height: 100%; height: 100%;
} }
* {
font-family: var(--font);
}
:root { :root {
--font: "Roboto", sans-serif;
--title-font: "Varela Round", sans-serif; --title-font: "Varela Round", sans-serif;
--max-width: 800px; --max-width: 800px;
--spacing: 2rem; --spacing: 2rem;

View file

@ -0,0 +1,2 @@
// This file is automatically generated from your CSS. Any edits will be overwritten.
export const app: string;

View file

@ -1,7 +1,8 @@
import { h } from "preact"; import { h } from "preact";
import { Route, Router } from "preact-router"; import { Route, Router } from "preact-router";
import { Home } from "./Home"; import { Home } from "./Home";
import { Nav } from "./Nav";
import { Layer, Stack } from "./Stack";
if ((module as any).hot) { if ((module as any).hot) {
// tslint:disable-next-line:no-var-requires // tslint:disable-next-line:no-var-requires
@ -11,9 +12,17 @@ if ((module as any).hot) {
export const App: preact.FunctionalComponent = () => { export const App: preact.FunctionalComponent = () => {
return ( return (
<div id="app"> <div id="app">
<Router> <Stack height="100vh">
<Route path="/" component={Home} /> <Layer>
</Router> <Router>
<Route path="/" component={Home} />
</Router>
</Layer>
<Layer>
<Nav />
</Layer>
</Stack>
</div> </div>
); );
}; };

View file

@ -0,0 +1,12 @@
.link {
text-decoration: none;
color: white;
filter: brightness(0.8);
font-size: 1.6rem;
padding: 1.4rem;
font: "Roboto light";
}
.activeLink {
filter: brightness(1);
}

View file

@ -0,0 +1,3 @@
// This file is automatically generated from your CSS. Any edits will be overwritten.
export const link: string;
export const activeLink: string;

View file

@ -0,0 +1,42 @@
import { Block, Row } from "jsxstyle";
import { h } from "preact";
import { Link } from "preact-router/match";
import styles from "./Nav.css";
interface Route {
url: string;
name: string;
}
const routes: Route[] = [
{
url: "/",
name: "Home"
},
{
url: "/leaderboards",
name: "Leaderboards"
},
{
url: "/play",
name: "Play"
}
];
export const Nav = () => {
return (
<Row background="rgba(0,0,0, 0.3)">
{routes.map(route => (
// We cannot style this directly, so I'm using classes
<Link
key={route.url}
href={route.url}
class={styles.link}
activeClassName={styles.activeLink}
>
{route.name}
</Link>
))}
</Row>
);
};