Files
classroomio/apps/dashboard/src/lib/components/LMS/SideBar.svelte
T
Adeyemi AdetunjiandRotimi Best cbf6ae7e63 feat: move away from carbon components and TinyMCE (#597)
* feat: remove tinymce & replace org sidebar

* chore: PR Fixes

* chore: move ui font into src dir

* remove files in vite config

* use google font import for loading font

* remove custom font

* more fonts update

* remove font bold

* more removals of font bold

* fix import

* checkpoint

* chore: checkpoint (add course & lms shadcn sidebar)

* minor css improvements and try out font sans

* chore: replace carbon components with shadcn's

* chore: replace carbon components with shadcn _ v3

* chore: ui fixes & storybook update

* feat: UI cleanup

* fix: quick ui fixes

* chore: update pnpm-lock.yaml with new dependencies and versions; fix output.css formatting

* chore: add isloading to button

* feat: add loading state to button stories

* chore: feedback fixes

* fix: feedback fixes

* chore: remove console

* fix: PR comments

* fix: PR comments

---------

Co-authored-by: Rotimi Best <[email protected]>
2025-11-21 12:18:04 +01:00

124 lines
3.5 KiB
Svelte

<script lang="ts">
import { page } from '$app/state';
import type { Component } from 'svelte';
import * as Sidebar from '@cio/ui/base/sidebar';
import UsersIcon from '@lucide/svelte/icons/users';
import MapPlusIcon from '@lucide/svelte/icons/map-plus';
import ListTodoIcon from '@lucide/svelte/icons/list-todo';
import LibraryBigIcon from '@lucide/svelte/icons/library-big';
import LayoutDashboardIcon from '@lucide/svelte/icons/layout-dashboard';
import { profile } from '$lib/utils/store/user';
import { currentOrg } from '$lib/utils/store/org';
import { sideBar } from '$lib/components/Org/store';
import { t } from '$lib/utils/functions/translations';
import NavUser from '../Sidebar/components/nav-user.svelte';
interface SideLinks {
name: string;
icon: Component;
link: string;
show?: () => boolean;
}
const user = $derived.by(() => ({
name: $profile.fullname,
email: $profile.email,
avatar: $profile.avatar_url
}));
function isActive(pagePath: string, itemPath: string) {
const pageLinkItems = pagePath.split('/');
const itemLinkItems = itemPath.split('/');
if (itemLinkItems.length !== pageLinkItems.length) {
return false;
}
return pagePath.includes(itemPath);
}
const sideLinks: SideLinks[] = $derived.by(() =>
[
{
name: $t('lms_navigation.home'),
icon: LayoutDashboardIcon,
link: '/lms'
},
{
name: $t('lms_navigation.my_learning'),
icon: LibraryBigIcon,
link: '/lms/mylearning'
},
{
name: $t('lms_navigation.exercise'),
icon: ListTodoIcon,
link: '/lms/exercises',
show() {
return $currentOrg?.customization?.dashboard?.exercise;
}
},
{
name: $t('lms_navigation.community'),
icon: UsersIcon,
link: '/lms/community',
show() {
return $currentOrg?.customization?.dashboard?.community;
}
},
{
name: $t('lms_navigation.explore'),
icon: MapPlusIcon,
link: '/lms/explore'
}
].filter((link) => (link.show ? link.show() : true))
);
const toggleSidebar = () => {
$sideBar.hidden = !$sideBar.hidden;
};
</script>
<Sidebar.Provider class="w-fit">
<Sidebar.Root collapsible="icon" class="inset-y-12 h-[calc(100vh-48px)] {$sideBar.hidden ? 'hidden' : ''}">
<Sidebar.Content>
<Sidebar.Group>
<Sidebar.GroupLabel>LMS Navigation</Sidebar.GroupLabel>
<Sidebar.Menu>
{#each sideLinks as item (item.link)}
<Sidebar.MenuItem>
<Sidebar.MenuButton tooltipContent={item.name}>
<a
href={item.link}
onclick={toggleSidebar}
class="flex w-full items-center gap-4 {isActive(page.url.pathname, item.link)
? 'bg-accent text-accent-foreground rounded-md px-3 py-2'
: ''}"
>
<item.icon size={16} />
{item.name}
</a>
</Sidebar.MenuButton>
</Sidebar.MenuItem>
{/each}
</Sidebar.Menu>
</Sidebar.Group>
</Sidebar.Content>
{#if user}
<Sidebar.Footer>
<NavUser {user} />
</Sidebar.Footer>
{/if}
<Sidebar.Rail />
</Sidebar.Root>
<!-- TODO: FIGURE OUT WHY THIS APPEARANCE IS BUGGY -->
<!-- TODO: THE SIDEBAR COLLAPSE VIEW IS BAD -->
<!-- <Sidebar.Inset>
<Sidebar.Trigger class="-ml-1" />
</Sidebar.Inset> -->
</Sidebar.Provider>