summaryrefslogtreecommitdiff
path: root/ui/routes
diff options
context:
space:
mode:
authorOwen Jacobson <owen@grimoire.ca>2024-11-02 13:01:01 -0400
committerOwen Jacobson <owen@grimoire.ca>2024-11-02 13:01:01 -0400
commite2908921d25347e3aab45afed9b9b4b807f79c25 (patch)
tree9e0e7361d9b397ad92c9109523c072e2c5c66bba /ui/routes
parent8088a8bd8bced9127edcb2284b993332d291b443 (diff)
parenta32b0ab6ad7995b8fff98e423793a7c6521ea1e9 (diff)
Merge remote-tracking branch 'origin/wip/mobile'
Diffstat (limited to 'ui/routes')
-rw-r--r--ui/routes/(app)/+layout.svelte109
-rw-r--r--ui/routes/+layout.svelte48
2 files changed, 117 insertions, 40 deletions
diff --git a/ui/routes/(app)/+layout.svelte b/ui/routes/(app)/+layout.svelte
index 08c6694..cf5d5f1 100644
--- a/ui/routes/(app)/+layout.svelte
+++ b/ui/routes/(app)/+layout.svelte
@@ -4,7 +4,7 @@
import { onMount, onDestroy } from 'svelte';
import { boot, subscribeToEvents } from '$lib/apiServer';
- import { currentUser, logins, channelsList, messages } from '$lib/store';
+ import { showMenu, currentUser, logins, channelsList, messages } from '$lib/store';
import ChannelList from '$lib/components/ChannelList.svelte';
import CreateChannelForm from '$lib/components/CreateChannelForm.svelte';
@@ -12,6 +12,15 @@
let loading = true;
let events = null;
+ let showMenuValue;
+ showMenu.subscribe((value) => {
+ showMenuValue = value;
+ });
+
+
+ function toggleMenu() {
+ showMenu.update((value) => !value);
+ }
$: channel = $page?.params?.channel;
@@ -54,36 +63,84 @@
});
</script>
+<svelte:head>
+ <title>understory</title>
+</svelte:head>
+
{#if loading}
<h2>Loading&hellip;</h2>
{:else}
- <div id="interface">
- <div class="channel-list">
- <ChannelList active={channel} />
- </div>
- <div class="active-channel">
- <slot />
- </div>
- <div class="create-channel">
- <CreateChannelForm />
- </div>
- <div class="create-message">
- <MessageInput {channel} />
- </div>
+ <div id="interface" class="p-2">
+ <nav id="sidebar" data-expanded={showMenuValue}>
+ <button class="h-4 w-4" aria-controls="sidebar" aria-expanded={showMenuValue} on:click={toggleMenu}>&#10006;</button>
+ <div class="channel-list">
+ <ChannelList active={channel} />
+ </div>
+ <div class="create-channel">
+ <CreateChannelForm />
+ </div>
+ </nav>
+ <main>
+ <div class="active-channel border border-solid border-gray-400 rounded-[1.25rem]">
+ <slot />
+ </div>
+ <div class="create-message overflow-scroll max-h-full">
+ <MessageInput {channel} />
+ </div>
+ </main>
</div>
{/if}
<style>
- #interface {
- height: 88vh;
- margin: 1rem;
- display: grid;
- grid-template-columns: 18rem auto;
- grid-template-rows: auto 2rem;
- grid-gap: 0.25rem;
- }
- #interface div {
- max-height: 100%;
- overflow: scroll;
- }
+:root {
+ --app-bar-height: 68px;
+ --input-row-height: 2rem;
+ --interface-padding: 16px;
+}
+
+#interface {
+ margin: unset;
+ display: grid;
+ grid-template:
+ 'side main' 1fr
+ / auto 1fr
+ ;
+ height: calc(100vh - var(--app-bar-height));
+
+ @media (width > 640px) {
+ --overlay: static;
+ --translate: 0;
+ }
+}
+nav {
+ grid-area: side;
+ background-color: rgb(var(--color-surface-600));
+ inset: auto auto 0 0;
+ padding: 0.25rem;
+ position: var(--overlay, absolute);
+ transition: translate 300ms ease-out;
+ width: 21rem;
+ height: calc(100vh - var(--app-bar-height) - var(--interface-padding));
+ z-index: 10;
+}
+nav button {
+ position: absolute;
+ top: 0;
+ right: 0;
+}
+main {
+ grid-area: main;
+ height: calc(100vh - var(--app-bar-height) - var(--interface-padding));
+}
+.active-channel {
+ height: calc(100vh - var(--app-bar-height) - var(--interface-padding) - var(--input-row-height));
+ overflow: scroll;
+}
+.channel-list {
+ height: calc(100vh - var(--app-bar-height) - var(--interface-padding) - var(--input-row-height));
+ overflow: scroll;
+}
+nav[data-expanded=false] {
+ translate: var(--translate, -100% 0);
+}
</style>
diff --git a/ui/routes/+layout.svelte b/ui/routes/+layout.svelte
index 0140699..eb29179 100644
--- a/ui/routes/+layout.svelte
+++ b/ui/routes/+layout.svelte
@@ -1,21 +1,41 @@
<script>
- import { AppBar } from '@skeletonlabs/skeleton';
- import "../app.css";
+ import "../app.css";
+ import logo from '$lib/assets/logo.png';
- import { currentUser } from '$lib/store';
- import CurrentUser from '$lib/components/CurrentUser.svelte';
+ import { onMount } from 'svelte';
+
+ import { AppBar } from '@skeletonlabs/skeleton';
+ import { showMenu, currentUser } from '$lib/store';
+
+ import CurrentUser from '$lib/components/CurrentUser.svelte';
+
+ function toggleMenu() {
+ showMenu.update((value) => !value);
+ }
+
+ onMount(() => {
+ Notification.requestPermission().then((result) => {
+ console.log(result);
+ });
+ });
</script>
-<div id="app">
- <AppBar>
- <svelte:fragment slot="lead">🌳</svelte:fragment>
- <a href="/">understory</a>
- <svelte:fragment slot="trail">
- {#if $currentUser}
- <CurrentUser />
- {/if}
- </svelte:fragment>
- </AppBar>
+<div id="app" class="m-0 p-0 h-vh w-full">
+ <div class="w-full">
+ <AppBar class="app-bar">
+ <svelte:fragment slot="lead">
+ <a on:click|preventDefault={toggleMenu} class="cursor-pointer">
+ <img class="w-8 h-8" alt="logo" src={logo} />
+ </a>
+ </svelte:fragment>
+ <a href="/">understory</a>
+ <svelte:fragment slot="trail">
+ {#if $currentUser}
+ <CurrentUser />
+ {/if}
+ </svelte:fragment>
+ </AppBar>
+ </div>
<slot />
</div>