templates

This commit is contained in:
Gleb Koval 2021-07-07 19:47:26 +01:00
parent 1ebcd9ca3b
commit 16cd5b70e3
No known key found for this signature in database
GPG Key ID: 120F2F6DA9D995FB
2 changed files with 46 additions and 30 deletions

View File

@ -2,22 +2,31 @@
export let status: number; export let status: number;
export let error: Error; export let error: Error;
const dev = process.env.NODE_ENV === 'development'; const dev = process.env.NODE_ENV === "development";
</script> </script>
<style> <svelte:head>
h1, p { <title>{status}</title>
margin: 0 auto; </svelte:head>
} <div id="content">
<div>
<h1>{status}</h1>
<p>{error.message}</p>
</div>
h1 { {#if dev && error.stack}
font-size: 2.8em; <pre>{error.stack}</pre>
font-weight: 700; {/if}
margin: 0 0 0.5em 0; </div>
}
p { <style lang="scss">
margin: 1em auto; div#content {
width: 100%;
display: grid;
place-items: center;
div {
text-align: center;
}
} }
@media (min-width: 480px) { @media (min-width: 480px) {
@ -26,15 +35,3 @@
} }
} }
</style> </style>
<svelte:head>
<title>{status}</title>
</svelte:head>
<h1>{status}</h1>
<p>{error.message}</p>
{#if dev && error.stack}
<pre>{error.stack}</pre>
{/if}

View File

@ -1,24 +1,43 @@
<script lang="ts"> <script lang="ts">
export let segment: string | undefined;
import { onMount } from "svelte";
import Navbar from "../components/Navbar.svelte"; import Navbar from "../components/Navbar.svelte";
import { login } from "../components/stores";
import { postLogin } from "../lib/api";
onMount(async () => {
try {
login.set(await postLogin());
} catch (e) {
login.set(null);
}
});
</script> </script>
<Navbar /> <Navbar {segment} />
<main> <main>
<slot /> <slot />
</main> </main>
<style lang="scss"> <style lang="scss">
@import url("https://fonts.googleapis.com/css2?family=Fira+Code&display=swap");
@font-face {
font-family: "Minecraft";
src: url("/Minecraft-Regular.otf");
}
$navbar-padding: 0.75em * 2 + 1em * 2 + 1.4375em;
:global(body) { :global(body) {
background-color: hsl(236, 10%, 5%); background-color: black;
font-family: monospace, "Courier New"; font-family: "Fira Code", monospace;
color: hsl(30, 20%, 90%); color: hsl(30, 20%, 90%);
} }
main { main {
display: flex; display: flex;
flex-direction: column; align-items: stretch;
padding: 0.75em; padding: 0.75em;
padding-top: 4.67em; padding-top: $navbar-padding;
min-height: calc(100% - 5.42em); min-height: calc(100% - #{$navbar-padding} - 0.75em);
} }
</style> </style>