Skip to content

Commit

Permalink
feat(client): sidebar for sprint 2 (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
SporadicToast authored Mar 23, 2023
2 parents 3f1efbd + 4626e6a commit 9140baa
Show file tree
Hide file tree
Showing 23 changed files with 192 additions and 166 deletions.
1 change: 1 addition & 0 deletions client/src/assets/icons/menu.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions client/src/components/icons/Menu.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<script lang="ts">
import './icon-styles.css';
import { IconColor, IconSize } from '../types.ts';
export let color = IconColor.Default;
export let size = IconSize.Normal;
export let alt = '';
// Replace the next lines to generate an icon.
const iconUrl = new URL('../../assets/icons/menu.svg', import.meta.url);
</script>

<img class="{color} {size}" {alt} src="{iconUrl.pathname}" on:click on:keydown />
39 changes: 0 additions & 39 deletions client/src/components/ui/Navbar.svelte

This file was deleted.

72 changes: 72 additions & 0 deletions client/src/components/ui/navigationbar/SideDrawer.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<script>
import active from 'svelte-spa-router/active';
export let show = false;
</script>

<nav class:show={show}>
<section>
<a href="#/inbox" use:active>Inbox</a>
<a href="#/outbox" use:active>Outbox</a>
<a href="#/drafts" use:active>Drafts</a>
<a href="#/barcodes" use:active>Manage Barcodes</a>
<a href="#/invites" use:active>Manage Invites</a>
<a href="#/staff" use:active>Manage Staff</a>
<a href="#/admin" use:active>Manage Administrators</a>
<a href="#/metrics" use:active>Metrics</a>
<a href="#/settings" use:active>Settings</a>
</section>
<form method="POST" action="/auth/logout">
<input type="submit" value="Logout" />
</form>
</nav>

<style>
@import url('../../../pages/vars.css');
nav {
background-color: var(--dashboard-bg);
display: flex;
flex-direction: column;
font-family: inherit;
height: 100%;
justify-content: space-between;
max-width: 300px;
left: -100%;
position: absolute;
transition: left var(--animation-length);
}
.show {
left: 0;
}
a {
border-right: var(--spacing-small) solid transparent;
color: initial;
display: block;
padding: var(--spacing-normal);
text-decoration: none;
transition: background-color var(--animation-length), border-right var(--animation-length);
}
input[type="submit"] {
background-color: var(--dashboard-bg);
border-top: 0;
border-bottom: 0;
border-left: 0;
border-right: var(--spacing-small) solid transparent;
cursor: pointer;
font-family: inherit;
margin: 0;
outline: 0;
padding: var(--spacing-normal);
text-align: initial;
transition: background-color var(--animation-length), border-right var(--animation-length);
width: 100%;
}
a:hover, input[type="submit"]:hover, :global(a.active) {
background-color: var(--hover-color);
border-right: var(--spacing-small) solid var(--primary-color);
}
</style>
39 changes: 39 additions & 0 deletions client/src/components/ui/navigationbar/TopBar.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<script lang="ts">
import type { User } from '../../../../../model/src/user.ts';
import Hamburger from '../../icons/Menu.svelte';
export let show = false;
export let user: User;
</script>

<nav>
<div>
<span id="icon"><Hamburger on:click={() => show = !show} /></span>
<span>Hello, {user.name}!</span>
</div>
<img src={user.picture} alt="{user.name}" />
</nav>

<style>
@import url('../../../pages/vars.css');
nav {
align-content: center;
background-color: var(--primary-color);
box-shadow: 0 1px var(--spacing-normal) var(--shadow-color);
display: flex;
justify-content: space-between;
padding: var(--spacing-small);
}
#icon {
cursor: pointer;
}
img {
border-radius: 50%;
display: block;
height: 1.25rem;
}
</style>
41 changes: 30 additions & 11 deletions client/src/pages/dashboard/Dashboard.svelte
Original file line number Diff line number Diff line change
@@ -1,22 +1,41 @@
<script lang="ts">
import Router, { push, pop, replace } from 'svelte-spa-router';
<script>
import Router from 'svelte-spa-router';
import TopBar from '../../components/ui/navigationbar/TopBar.svelte';
import SideDrawer from '../../components/ui/navigationbar/SideDrawer.svelte';
import routes from './views/index.ts';
import { register } from '../register.ts';
import { Session } from '../../api/session.ts';
import Navbar from '../../components/ui/Navbar.svelte';
import Button from '../../components/ui/Button.svelte'
import routes from './routes.ts';
let toggleDrawer = false;
</script>

<main>
{#await register()}
Waiting for service worker...
{:then}
<Navbar />
<!-- Sample navigation of pages. Implement in drawer
<Button on:click={() => push('/inbox')}>Inbox</Button>
<Button on:click={() => push('/outbox')}>Outbox</Button>
-->
<Router {routes} />
{#await Session.getUser()}
Loading user...
{:then user}
<TopBar {user} bind:show={toggleDrawer} />
<section>
<SideDrawer show={toggleDrawer} />
<Router {routes} />
</section>
{/await}
{/await}
</main>

<style>
main {
display: flex;
flex-direction: column;
height: 100%;
}
section {
height: 100%;
position: relative;
}
</style>
1 change: 1 addition & 0 deletions client/src/pages/dashboard/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="manifest" href="../manifest.json" />
<link rel="stylesheet" href="../global.css" />
<script src="index.ts" type="module"></script>
<title>Dashboard</title>
</head>
Expand Down
21 changes: 0 additions & 21 deletions client/src/pages/dashboard/routes.ts

This file was deleted.

1 change: 1 addition & 0 deletions client/src/pages/dashboard/views/Admins.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>Manage Admins!</p>
11 changes: 1 addition & 10 deletions client/src/pages/dashboard/views/Barcodes.svelte
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
<div>
<p>Barcodes</p>
</div>


<style>
div{
text-align: center;
}
</style>
<p>Barcodes!</p>
11 changes: 1 addition & 10 deletions client/src/pages/dashboard/views/Drafts.svelte
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
<div>
<p>Drafts</p>
</div>


<style>
div{
text-align: center;
}
</style>
<p>Drafts!</p>
11 changes: 1 addition & 10 deletions client/src/pages/dashboard/views/Inbox.svelte
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
<div>
<p>Inbox</p>
</div>


<style>
div{
text-align: center;
}
</style>
<p>Inbox!</p>
1 change: 1 addition & 0 deletions client/src/pages/dashboard/views/Invites.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>Invites!</p>
10 changes: 0 additions & 10 deletions client/src/pages/dashboard/views/ManageAdministrators.svelte

This file was deleted.

10 changes: 0 additions & 10 deletions client/src/pages/dashboard/views/ManageGlobalSettings.svelte

This file was deleted.

10 changes: 0 additions & 10 deletions client/src/pages/dashboard/views/ManageInvites.svelte

This file was deleted.

10 changes: 0 additions & 10 deletions client/src/pages/dashboard/views/ManageStaff.svelte

This file was deleted.

11 changes: 1 addition & 10 deletions client/src/pages/dashboard/views/Metrics.svelte
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
<div>
<p>Metrics</p>
</div>


<style>
div{
text-align: center;
}
</style>
<p>Metrics!</p>
11 changes: 1 addition & 10 deletions client/src/pages/dashboard/views/Outbox.svelte
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
<div>
<p>Outbox</p>
</div>


<style>
div{
text-align: center;
}
</style>
<p>Outbox!</p>
1 change: 1 addition & 0 deletions client/src/pages/dashboard/views/Settings.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>Manage Settings!</p>
1 change: 1 addition & 0 deletions client/src/pages/dashboard/views/Staff.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>Manage Staff!</p>
21 changes: 21 additions & 0 deletions client/src/pages/dashboard/views/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import Barcodes from './Barcodes.svelte';
import Drafts from './Drafts.svelte';
import Inbox from './Inbox.svelte';
import ManageAdministrators from './Admins.svelte';
import ManageGlobalSettings from './Settings.svelte';
import ManageInvites from './Invites.svelte';
import ManageStaff from './Staff.svelte';
import Metrics from './Metrics.svelte';
import Outbox from './Outbox.svelte';

export default {
'/barcodes': Barcodes,
'/drafts': Drafts,
'/inbox': Inbox,
'/admin': ManageAdministrators,
'/settings': ManageGlobalSettings,
'/invites': ManageInvites,
'/staff': ManageStaff,
'/metrics': Metrics,
'/outbox': Outbox,
};
Loading

0 comments on commit 9140baa

Please sign in to comment.