Skip to content

Commit

Permalink
Merge pull request #232 from COS301-SE-2024/update/students
Browse files Browse the repository at this point in the history
Update/students
  • Loading branch information
bukhosi-eugene-mpande authored Sep 16, 2024
2 parents 2cad04b + 1e3bc3d commit d774917
Show file tree
Hide file tree
Showing 36 changed files with 1,690 additions and 734 deletions.
Binary file added bun.lockb
Binary file not shown.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "dependencies": { "@types/three": "^0.168.0" } }
Binary file modified src/bun.lockb
Binary file not shown.
5 changes: 5 additions & 0 deletions src/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare module '*.svelte' {
import type { ComponentType } from 'svelte';
const component: ComponentType;
export default component;
}
3 changes: 2 additions & 1 deletion src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"@threlte/extras": "^8.11.4",
"@threlte/xr": "^0.1.4",
"@types/canvas-confetti": "^1.6.4",
"@types/three": "^0.168.0",
"@vercel/analytics": "^1.3.1",
"@vercel/speed-insights": "^1.0.12",
"aws-sdk": "^2.1670.0",
Expand All @@ -86,6 +87,6 @@
"stream-chat": "^8.37.0",
"svelte-french-toast": "^1.2.0",
"svelte-tweakpane-ui": "^1.3.0",
"three": "^0.165.0"
"three": "^0.168.0"
}
}
68 changes: 56 additions & 12 deletions src/src/lib/components/common/Header.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!--

Check warning on line 1 in src/src/lib/components/common/Header.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/common/Header.svelte#L1

Added line #L1 was not covered by tests
<script>
import { Avatar, Navbar, DarkMode } from 'flowbite-svelte';
import BreadCrumbs from '$lib/components/common/Breadcrumbs.svelte';
Expand All @@ -9,6 +10,8 @@
$: ({ name, image, maps } = data);
let isMobile;

Check warning on line 13 in src/src/lib/components/common/Header.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/common/Header.svelte#L11-L13

Added lines #L11 - L13 were not covered by tests
async function updateUserData() {

Check warning on line 15 in src/src/lib/components/common/Header.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/common/Header.svelte#L15

Added line #L15 was not covered by tests
try {
const user = await getUserData();
Expand All @@ -21,6 +24,16 @@
onMount(async () => {
updateUserData();
const checkMobile = () => {
isMobile = window.innerWidth < 768;
};
checkMobile();
window.addEventListener('resize', checkMobile);
return () => {
window.removeEventListener('resize', checkMobile);
};

Check warning on line 36 in src/src/lib/components/common/Header.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/common/Header.svelte#L26-L36

Added lines #L26 - L36 were not covered by tests
});
$: {
Expand All @@ -30,19 +43,50 @@
}
</script>
<Navbar data-testid="navbar">
<BreadCrumbs {maps} />
<div class="m-4 {isMobile ? 'ml-4' : 'ml-72'}">
<Navbar
data-testid="navbar"
class="glassmorphic rounded-xl bg-white/60 px-4 py-2 shadow-md dark:bg-gray-900/60 transition-all duration-300 ease-in-out"
>
{#if !isMobile}
<BreadCrumbs {maps} />
{/if}

Check warning on line 53 in src/src/lib/components/common/Header.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/common/Header.svelte#L46-L53

Added lines #L46 - L53 were not covered by tests
<div class="flex items-center md:order-2">
<DarkMode
class="mx-2 border text-gray-500 dark:border-gray-800 dark:text-gray-600"
data-testid="darkmode"
/>
<div class="flex items-center md:order-2">
<DarkMode
class="mx-2 border text-gray-500 dark:border-gray-800 dark:text-gray-600"
data-testid="darkmode"
/>

Check warning on line 59 in src/src/lib/components/common/Header.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/common/Header.svelte#L55-L59

Added lines #L55 - L59 were not covered by tests
<Avatar id="avatar-menu" src={image} class="mx-2" data-testid="avatar" />
<Avatar id="avatar-menu" src={image} class="mx-2" data-testid="avatar" />

Check warning on line 61 in src/src/lib/components/common/Header.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/common/Header.svelte#L61

Added line #L61 was not covered by tests
<div class="mx-2">
<div class="text-lg font-semibold">{name}</div>
{#if !isMobile}
<div class="mx-2">
<div class="text-lg font-semibold">{name}</div>
</div>
{/if}
</div>
</div>
</Navbar>
</Navbar>
</div>
<style>
.glassmorphic {
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
position: relative;
overflow: hidden;
}
.glassmorphic::before {
content: "";
position: absolute;
top: -50%;
left: -50%;
width: 200%;
height: 200%;
background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0) 70%);
transform: rotate(30deg);
pointer-events: none;
}
</style>
-->
58 changes: 58 additions & 0 deletions src/src/lib/components/common/Navbar.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<script lang="ts">
import { Navbar, NavBrand, NavLi, NavUl, NavHamburger } from 'flowbite-svelte';

Check warning on line 2 in src/src/lib/components/common/Navbar.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/common/Navbar.svelte#L1-L2

Added lines #L1 - L2 were not covered by tests
export let role: 'lecturer' | 'admin' | 'student';
export let activeUrl = '';

Check warning on line 5 in src/src/lib/components/common/Navbar.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/common/Navbar.svelte#L4-L5

Added lines #L4 - L5 were not covered by tests
const navLinks = {
admin: [
{ name: 'Dashboard', href: '/dashboard' },
{ name: 'Announcements', href: '/announcements' },
{ name: 'Organisation', href: '/organisation' },
{ name: 'Workspaces', href: '/workspaces' },
{ name: 'Admins', href: '/admins' },
{ name: 'Lecturers', href: '/lecturers' },
{ name: 'Students', href: '/students' }

Check warning on line 15 in src/src/lib/components/common/Navbar.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/common/Navbar.svelte#L7-L15

Added lines #L7 - L15 were not covered by tests
],
lecturer: [
{ name: 'Workspaces', href: '/workspaces' },
{ name: 'Announcements', href: '/announcements' }

Check warning on line 19 in src/src/lib/components/common/Navbar.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/common/Navbar.svelte#L17-L19

Added lines #L17 - L19 were not covered by tests
],
student: [
{ name: 'Dashboard', href: '/dashboard' },
{ name: 'Workspaces', href: '/workspaces' },
{ name: 'Announcements', href: '/announcements' },
{ name: 'Grades', href: '/grades' }

Check warning on line 25 in src/src/lib/components/common/Navbar.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/common/Navbar.svelte#L21-L25

Added lines #L21 - L25 were not covered by tests
]
};
const commonLinks = [
{ name: 'Settings', href: '/settings' },
{ name: 'FAQ', href: '/faq' }

Check warning on line 31 in src/src/lib/components/common/Navbar.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/common/Navbar.svelte#L29-L31

Added lines #L29 - L31 were not covered by tests
];
const currentLinks = navLinks[role];

Check warning on line 34 in src/src/lib/components/common/Navbar.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/common/Navbar.svelte#L34

Added line #L34 was not covered by tests
</script>

<Navbar class="fixed start-0 top-0 z-20 w-full border-b px-2 py-2.5 sm:px-4">
<NavBrand href="/">
<img src="images/class-connect-logo.png" class="mr-3 h-8 sm:h-10" alt="ClassConnect Logo" />
<span

Check warning on line 40 in src/src/lib/components/common/Navbar.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/common/Navbar.svelte#L39-L40

Added lines #L39 - L40 were not covered by tests
class="self-center whitespace-nowrap text-xl font-semibold text-gray-800 transition-colors duration-300 dark:text-white"
>ClassConnect</span
>

Check warning on line 43 in src/src/lib/components/common/Navbar.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/common/Navbar.svelte#L43

Added line #L43 was not covered by tests
</NavBrand>
<NavHamburger />
<NavUl>
{#each currentLinks as { name, href }}
<NavLi {href} active={activeUrl === href}>
{name}

Check warning on line 49 in src/src/lib/components/common/Navbar.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/common/Navbar.svelte#L47-L49

Added lines #L47 - L49 were not covered by tests
</NavLi>
{/each}
{#each commonLinks as { name, href }}
<NavLi {href} active={activeUrl === href}>
{name}

Check warning on line 54 in src/src/lib/components/common/Navbar.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/common/Navbar.svelte#L52-L54

Added lines #L52 - L54 were not covered by tests
</NavLi>
{/each}
</NavUl>
</Navbar>
2 changes: 1 addition & 1 deletion src/src/lib/components/common/Settings.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@
class="mb-4 rounded-lg border border-gray-200 bg-white p-4 shadow-sm dark:border-gray-700 dark:bg-gray-800 sm:p-6 2xl:col-span-2"
>
<div class="items-center sm:flex sm:space-x-4 xl:block xl:space-x-0 2xl:flex 2xl:space-x-4">
<h3 class="mb-4 text-xl font-semibold dark:text-white">Profile Picture</h3>

Check warning on line 47 in src/src/lib/components/common/Settings.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/common/Settings.svelte#L47

Added line #L47 was not covered by tests
<img
class="mb-4 h-28 w-28 rounded-[100px] sm:mb-0 xl:mb-4 2xl:mb-0"
src={user.image}
alt="profile"
/>
<div>
<h3 class="mb-1 text-xl font-bold text-gray-900 dark:text-white">Profile Picture</h3>
<div class="mb-4 text-sm text-gray-500 dark:text-gray-400">
JPG, WEBP or PNG. Max size of 1 MB
</div>
Expand Down
155 changes: 107 additions & 48 deletions src/src/lib/components/common/SideBar.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!--

Check warning on line 1 in src/src/lib/components/common/SideBar.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/common/SideBar.svelte#L1

Added line #L1 was not covered by tests
<script lang="ts">
import {
GridSolid,
Expand All @@ -10,12 +11,31 @@
UsersGroupSolid,
ChartLineUpOutline,
ArrowLeftToBracketOutline,
AdjustmentsHorizontalSolid
AdjustmentsHorizontalSolid,
ObjectsColumnSolid

Check warning on line 15 in src/src/lib/components/common/SideBar.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/common/SideBar.svelte#L14-L15

Added lines #L14 - L15 were not covered by tests
} from 'flowbite-svelte-icons';
import { page } from '$app/stores';
import { onMount } from 'svelte';

Check warning on line 18 in src/src/lib/components/common/SideBar.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/common/SideBar.svelte#L18

Added line #L18 was not covered by tests
export let role: 'lecturer' | 'admin' | 'student';
let isMobile: boolean;
let isOpen: boolean = false;
onMount(() => {
const checkMobile = () => {
isMobile = window.innerWidth < 768;
isOpen = !isMobile;
};
checkMobile();
window.addEventListener('resize', checkMobile);
return () => {
window.removeEventListener('resize', checkMobile);
};
});

Check warning on line 38 in src/src/lib/components/common/SideBar.svelte

View check run for this annotation

Codecov / codecov/patch

src/src/lib/components/common/SideBar.svelte#L22-L38

Added lines #L22 - L38 were not covered by tests
const navLinks = {
admin: [
{ icon: GridSolid, name: 'Dashboard', href: '/dashboard' },
Expand Down Expand Up @@ -45,53 +65,92 @@
];
const currentLinks = navLinks[role];
function getClasses(href: string) {
const baseClasses =
'flex items-center rounded-lg px-4 py-3 text-gray-600 transition-all duration-300 hover:bg-green-50 hover:text-green-700 dark:text-gray-300 dark:hover:bg-green-900 dark:hover:text-green-100';
const activeClasses =
'bg-green-100 text-green-800 dark:bg-green-800 dark:text-green-100 font-medium';
return href === $page.url.pathname ? `${baseClasses} ${activeClasses}` : baseClasses;
}
function toggleSidebar() {
isOpen = !isOpen;
}
</script>
<aside
class="flex h-screen w-64 flex-col overflow-y-auto border-r bg-primary-100 px-4 py-6 dark:border-gray-700 dark:bg-gray-900 rtl:border-l rtl:border-r-0"
>
<a href="/" class="mx-auto mb-6">
<div class="flex items-center">
<img class="mr-3 h-16 w-16" src="images/class-connect-logo.png" alt="ClassConnect owl logo" />
<div class="text-2xl font-semibold text-gray-800 dark:text-gray-300">ClassConnect</div>
</div>
</a>

<nav class="flex-1 space-y-2">
{#each currentLinks as { icon, name, href }}
<a
class="flex items-center rounded-lg px-4 py-2 text-gray-600 transition duration-300 hover:bg-primary-300 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-green-400 dark:hover:text-gray-800 {href ===
$page.url.pathname
? 'active-sidebar dark:text-gray-800'
: ''}"
{href}
>
<svelte:component this={icon} class="h-5 w-5" />
<span class="ml-4 text-base font-medium">{name}</span>
</a>
{/each}

<hr class="my-4 border-gray-300 dark:border-gray-700" />

{#each commonLinks as { icon, name, href }}
<a
class="flex items-center rounded-lg px-4 py-2 text-gray-600 transition duration-300 hover:bg-primary-300 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-green-400 dark:hover:text-gray-800 {href ===
$page.url.pathname
? 'active-sidebar dark:text-gray-800'
: ''}"
{href}
>
<svelte:component this={icon} class="h-5 w-5" />
<span class="ml-4 text-base font-medium">{name}</span>
</a>
{/each}
</nav>

<a
class="mt-6 flex items-center rounded-lg px-4 py-2 text-gray-600 transition duration-300 hover:bg-primary-300 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-green-400 dark:hover:text-gray-800"
href="/signout"
<div class="relative">
<button
on:click={toggleSidebar}
class="fixed left-4 top-4 z-50 rounded-lg bg-green-500 p-2 text-white shadow-lg md:hidden"
>
<ObjectsColumnSolid class="h-6 w-6" />
</button>
<aside
class="glassmorphic fixed left-0 top-0 z-40 h-[calc(100vh-2rem)] m-4 w-64 transform overflow-y-auto bg-white/60 px-4 py-6 shadow-xl transition-all duration-300 ease-in-out dark:bg-gray-900/60 rounded-xl {isOpen ? 'translate-x-0' : '-translate-x-full'}"
>
<svelte:component this={ArrowLeftToBracketOutline} class="h-5 w-5" />
<span class="ml-4 text-base font-medium">Sign Out</span>
</a>
</aside>
<a href="/" class="mx-auto mb-8">
<div class="flex items-center">
<img
class="mr-3 h-10 w-10"
src="images/class-connect-logo.png"
alt="ClassConnect owl logo"
/>
<div class="text-xl font-bold text-green-700 dark:text-green-300">ClassConnect</div>
</div>
</a>
<nav class="flex-1 space-y-1">
{#each currentLinks as { icon, name, href }}
<a class={getClasses(href)} {href} on:click={() => (isMobile ? (isOpen = false) : null)}>
<svelte:component this={icon} class="mr-3 h-5 w-5" />
<span class="text-sm">{name}</span>
</a>
{/each}
<hr class="my-6 border-gray-200 dark:border-gray-700" />
{#each commonLinks as { icon, name, href }}
<a class={getClasses(href)} {href} on:click={() => (isMobile ? (isOpen = false) : null)}>
<svelte:component this={icon} class="mr-3 h-5 w-5" />
<span class="text-sm">{name}</span>
</a>
{/each}
</nav>
<a
class="mt-6 flex items-center rounded-lg px-4 py-3 text-gray-600 transition-all duration-300 hover:bg-red-50 hover:text-red-700 dark:text-gray-300 dark:hover:bg-red-900 dark:hover:text-red-100"
href="/signout"
>
<svelte:component this={ArrowLeftToBracketOutline} class="mr-3 h-5 w-5" />
<span class="text-sm font-medium">Sign Out</span>
</a>
</aside>
</div>
<style>
.glassmorphic {
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
}
aside {
transition: transform 0.3s ease, backdrop-filter 0.3s ease;
position: relative;
overflow: hidden;
}
aside::before {
content: "";
position: absolute;
top: -50%;
left: -50%;
width: 200%;
height: 200%;
background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0) 70%);
transform: rotate(30deg);
pointer-events: none;
}
</style>
-->
Empty file.
Loading

0 comments on commit d774917

Please sign in to comment.