Skip to content

Commit 9140baa

Browse files
feat(client): sidebar for sprint 2 (#34)
2 parents 3f1efbd + 4626e6a commit 9140baa

23 files changed

+192
-166
lines changed

client/src/assets/icons/menu.svg

Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<script lang="ts">
2+
import './icon-styles.css';
3+
import { IconColor, IconSize } from '../types.ts';
4+
5+
export let color = IconColor.Default;
6+
export let size = IconSize.Normal;
7+
export let alt = '';
8+
9+
// Replace the next lines to generate an icon.
10+
const iconUrl = new URL('../../assets/icons/menu.svg', import.meta.url);
11+
</script>
12+
13+
<img class="{color} {size}" {alt} src="{iconUrl.pathname}" on:click on:keydown />

client/src/components/ui/Navbar.svelte

Lines changed: 0 additions & 39 deletions
This file was deleted.
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<script>
2+
import active from 'svelte-spa-router/active';
3+
export let show = false;
4+
</script>
5+
6+
<nav class:show={show}>
7+
<section>
8+
<a href="#/inbox" use:active>Inbox</a>
9+
<a href="#/outbox" use:active>Outbox</a>
10+
<a href="#/drafts" use:active>Drafts</a>
11+
<a href="#/barcodes" use:active>Manage Barcodes</a>
12+
<a href="#/invites" use:active>Manage Invites</a>
13+
<a href="#/staff" use:active>Manage Staff</a>
14+
<a href="#/admin" use:active>Manage Administrators</a>
15+
<a href="#/metrics" use:active>Metrics</a>
16+
<a href="#/settings" use:active>Settings</a>
17+
</section>
18+
<form method="POST" action="/auth/logout">
19+
<input type="submit" value="Logout" />
20+
</form>
21+
</nav>
22+
23+
<style>
24+
@import url('../../../pages/vars.css');
25+
26+
nav {
27+
background-color: var(--dashboard-bg);
28+
display: flex;
29+
flex-direction: column;
30+
font-family: inherit;
31+
height: 100%;
32+
justify-content: space-between;
33+
max-width: 300px;
34+
left: -100%;
35+
position: absolute;
36+
transition: left var(--animation-length);
37+
}
38+
39+
.show {
40+
left: 0;
41+
}
42+
43+
a {
44+
border-right: var(--spacing-small) solid transparent;
45+
color: initial;
46+
display: block;
47+
padding: var(--spacing-normal);
48+
text-decoration: none;
49+
transition: background-color var(--animation-length), border-right var(--animation-length);
50+
}
51+
52+
input[type="submit"] {
53+
background-color: var(--dashboard-bg);
54+
border-top: 0;
55+
border-bottom: 0;
56+
border-left: 0;
57+
border-right: var(--spacing-small) solid transparent;
58+
cursor: pointer;
59+
font-family: inherit;
60+
margin: 0;
61+
outline: 0;
62+
padding: var(--spacing-normal);
63+
text-align: initial;
64+
transition: background-color var(--animation-length), border-right var(--animation-length);
65+
width: 100%;
66+
}
67+
68+
a:hover, input[type="submit"]:hover, :global(a.active) {
69+
background-color: var(--hover-color);
70+
border-right: var(--spacing-small) solid var(--primary-color);
71+
}
72+
</style>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<script lang="ts">
2+
import type { User } from '../../../../../model/src/user.ts';
3+
4+
import Hamburger from '../../icons/Menu.svelte';
5+
6+
export let show = false;
7+
export let user: User;
8+
</script>
9+
10+
<nav>
11+
<div>
12+
<span id="icon"><Hamburger on:click={() => show = !show} /></span>
13+
<span>Hello, {user.name}!</span>
14+
</div>
15+
<img src={user.picture} alt="{user.name}" />
16+
</nav>
17+
18+
<style>
19+
@import url('../../../pages/vars.css');
20+
21+
nav {
22+
align-content: center;
23+
background-color: var(--primary-color);
24+
box-shadow: 0 1px var(--spacing-normal) var(--shadow-color);
25+
display: flex;
26+
justify-content: space-between;
27+
padding: var(--spacing-small);
28+
}
29+
30+
#icon {
31+
cursor: pointer;
32+
}
33+
34+
img {
35+
border-radius: 50%;
36+
display: block;
37+
height: 1.25rem;
38+
}
39+
</style>
Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,41 @@
1-
<script lang="ts">
2-
import Router, { push, pop, replace } from 'svelte-spa-router';
1+
<script>
2+
import Router from 'svelte-spa-router';
33
4+
import TopBar from '../../components/ui/navigationbar/TopBar.svelte';
5+
import SideDrawer from '../../components/ui/navigationbar/SideDrawer.svelte';
6+
7+
import routes from './views/index.ts';
48
import { register } from '../register.ts';
59
import { Session } from '../../api/session.ts';
6-
import Navbar from '../../components/ui/Navbar.svelte';
7-
import Button from '../../components/ui/Button.svelte'
810
9-
import routes from './routes.ts';
11+
let toggleDrawer = false;
1012
</script>
13+
1114
<main>
1215
{#await register()}
1316
Waiting for service worker...
1417
{:then}
15-
<Navbar />
16-
<!-- Sample navigation of pages. Implement in drawer
17-
<Button on:click={() => push('/inbox')}>Inbox</Button>
18-
<Button on:click={() => push('/outbox')}>Outbox</Button>
19-
-->
20-
<Router {routes} />
18+
{#await Session.getUser()}
19+
Loading user...
20+
{:then user}
21+
<TopBar {user} bind:show={toggleDrawer} />
22+
<section>
23+
<SideDrawer show={toggleDrawer} />
24+
<Router {routes} />
25+
</section>
26+
{/await}
2127
{/await}
2228
</main>
29+
30+
<style>
31+
main {
32+
display: flex;
33+
flex-direction: column;
34+
height: 100%;
35+
}
36+
37+
section {
38+
height: 100%;
39+
position: relative;
40+
}
41+
</style>

client/src/pages/dashboard/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
66
<link rel="manifest" href="../manifest.json" />
7+
<link rel="stylesheet" href="../global.css" />
78
<script src="index.ts" type="module"></script>
89
<title>Dashboard</title>
910
</head>

client/src/pages/dashboard/routes.ts

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<p>Manage Admins!</p>
Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1 @@
1-
<div>
2-
<p>Barcodes</p>
3-
</div>
4-
5-
6-
<style>
7-
div{
8-
text-align: center;
9-
}
10-
</style>
1+
<p>Barcodes!</p>

0 commit comments

Comments
 (0)