Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: create app drawer #12

Merged
merged 20 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/app.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,13 @@
@tailwind utilities;
@tailwind components;
@tailwind utilities;

@layer utilities {
.flex-center {
@apply flex items-center justify-center;
}

.flex-between {
@apply flex items-center justify-between;
}
}
38 changes: 38 additions & 0 deletions src/lib/components/Header/Header.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<script lang="ts">
import { getDrawerStore } from "@skeletonlabs/skeleton";

import HamburgerMenu from "~icons/material-symbols/menu-rounded";

export let hamburger: boolean;

const drawerStore = getDrawerStore();

const openDrawer = () => {
drawerStore.open();
};
</script>

<!-- Header for the app -->

<header class="h-16 bg-primary-600">
<div class="h-full flex-between md:mx-4">
<img src="/icon.png" class="w-10 h-10 rounded-full" alt="ZotMeet icon" />
<div class="text-4xl font-bold md:ml-10">
<a href="/">ZotMeet</a>
</div>

<!-- Hamburger -->
{#if hamburger}
<button on:click={openDrawer}>
<HamburgerMenu class="w-12 h-12" />
</button>
{:else}
<div id="user-info-container" class="flex items-center justify-end flex-1 gap-2">
<div id="user-name-container">
<span class="text-lg">Peter Anteater</span>
</div>
<img src="user-icon.png" alt="User Icon" class="w-12 h-12 rounded-full user-icon" />
</div>
{/if}
</div>
</header>
1 change: 1 addition & 0 deletions src/lib/components/Header/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from "./Header.svelte";
37 changes: 37 additions & 0 deletions src/lib/components/SideBar/SideBar.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<script lang="ts">
import { getDrawerStore } from "@skeletonlabs/skeleton";

import SideBarFooter from "./SideBarFooter.svelte";
import SideBarLink from "./SideBarLink.svelte";

import CalendarIcon from "~icons/material-symbols/calendar-clock";
import CloseIcon from "~icons/material-symbols/close-rounded";
import SettingsIcon from "~icons/material-symbols/settings-rounded";
MinhxNguyen7 marked this conversation as resolved.
Show resolved Hide resolved

export let displayCloseButton = false;

const drawerStore = getDrawerStore();

const closeDrawer = drawerStore.close;
MinhxNguyen7 marked this conversation as resolved.
Show resolved Hide resolved
</script>

<div
id="sidebar"
class="flex flex-col w-full h-full rounded-r-none rounded-left-lg md:rounded-r-lg md:rounded-l-none bg-secondary-400 outline-secondary-800 card outline-5"
>
<div id="sidebar-links" class="flex flex-col">
{#if displayCloseButton}
<div class="w-full flex flex-row justify-end">
<button class="p-2 ml-auto" on:click={closeDrawer}>
<CloseIcon class="h-12 w-12" />
</button>
</div>
{/if}
<SideBarLink Icon={CalendarIcon} label="Summary" href="/summary" />
<SideBarLink Icon={SettingsIcon} label="Settings" href="/settings" />
</div>

<div id="sidebar-footer-container" class="mt-auto m-2">
<SideBarFooter />
</div>
</div>
9 changes: 9 additions & 0 deletions src/lib/components/SideBar/SideBarFooter.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<script lang="ts">
import { LightSwitch } from "@skeletonlabs/skeleton";
</script>

<div id="sidebar-footer" class="flex-between">
<LightSwitch />
<a href="https://google.com">Feedback</a>
<a href="https://google.com">About</a>
</div>
22 changes: 22 additions & 0 deletions src/lib/components/SideBar/SideBarLink.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<script lang="ts">
import { getDrawerStore } from "@skeletonlabs/skeleton";

/**
* Should be an SVG icon from Iconify `~icons/material-symbols`
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export let Icon: any;
export let label: string;
export let href: string;

const closeDrawer = getDrawerStore().close;
MinhxNguyen7 marked this conversation as resolved.
Show resolved Hide resolved
</script>

<a id="sidebar-link-{label}" {href} on:click={closeDrawer}>
<div
class="flex flex-row items-center whitespace-nowrap hover:bg-secondary-500 w-full gap-4 p-5 md:p-3 rounded-lg"
>
<Icon class="w-14 h-14 md:w-10 md:h-10 ml-3" />
<span class="text-2xl md:text-xl">{label}</span>
</div>
</a>
1 change: 1 addition & 0 deletions src/lib/components/SideBar/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from "./SideBar.svelte";
48 changes: 46 additions & 2 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,52 @@
<script>
<script lang="ts">
import "../app.pcss";
import { AppShell, Drawer, initializeStores } from "@skeletonlabs/skeleton";
import { onMount } from "svelte";

import Header from "$lib/components/Header";
import SideBar from "$lib/components/SideBar";

$: activateHamburger = true;
let appContainer: HTMLElement; // To listen to resize events

onMount(() => {
const reiszeObserver = new ResizeObserver((entries) => {
// Only listen to the app container
const entry = entries[0];
activateHamburger = entry.contentRect.width < 768;
});

reiszeObserver.observe(appContainer);

return () => {
reiszeObserver.disconnect();
};
});

initializeStores(); // Should be called only once
</script>

<slot />
{#if activateHamburger}
<Drawer position="right">
<SideBar displayCloseButton={true} />
</Drawer>
{/if}

<div id="app-container" bind:this={appContainer} class="h-screen w-screen">
<AppShell slotSidebarLeft={activateHamburger ? "" : "w-64 h-full"} class="h-screen">
<svelte:fragment slot="header">
<Header hamburger={activateHamburger} />
</svelte:fragment>

<svelte:fragment slot="sidebarLeft">
{#if !activateHamburger}
<SideBar />
{/if}
</svelte:fragment>

<slot />
</AppShell>
</div>

<!-- Global styles -->
<style lang="postcss">
Expand Down
4 changes: 1 addition & 3 deletions src/routes/summary/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { LightSwitch, TabGroup, Tab } from "@skeletonlabs/skeleton";
import { TabGroup, Tab } from "@skeletonlabs/skeleton";

import GroupList from "$lib/components/summary/GroupsCarousel.svelte";
import ScheduledMeetingsList from "$lib/components/summary/ScheduledMeetingsList.svelte";
Expand All @@ -8,8 +8,6 @@
let tabSet: number = 0;
</script>

<LightSwitch />

<div class="flex flex-col gap-8 px-4 pt-8 md:px-32">
<div class="flex flex-col gap-4">
<h1 class="text-4xl font-bold border-b border-surface-400-500-token">Groups</h1>
Expand Down
Binary file added static/user-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.