router.push('/content?tag=all')} className={`w-full cursor-pointer py-2 my-2 hover:bg-gray-700 rounded-lg ${isActive('/content?tag=all') ? 'bg-gray-700' : ''}`}>
-
All
+ {isExpanded ? (
+
+
router.push('/')} className={`w-full flex flex-row items-center cursor-pointer py-2 my-2 hover:bg-gray-700 rounded-lg ${isActive('/') ? 'bg-gray-700' : ''}`}>
+
Home
-
router.push('/content?tag=courses')} className={`w-full cursor-pointer py-2 my-2 hover:bg-gray-700 rounded-lg ${isActive('/content?tag=courses') ? 'bg-gray-700' : ''}`}>
-
Courses
+
+ ({
+ className: `hover:bg-gray-700 rounded-lg ${isActive('/content') || router.pathname === '/content' ? 'bg-gray-700' : ''} ${styles['p-accordion-header-link']}`
+ }),
+ content: styles['p-accordion-content'],
+ header: 'text-lg'
+ }}
+ header={'Content'}>
+ router.push('/content?tag=all')} className={`w-full cursor-pointer py-2 my-2 hover:bg-gray-700 rounded-lg ${isActive('/content?tag=all') ? 'bg-gray-700' : ''}`}>
+
All
+
+ router.push('/content?tag=courses')} className={`w-full cursor-pointer py-2 my-2 hover:bg-gray-700 rounded-lg ${isActive('/content?tag=courses') ? 'bg-gray-700' : ''}`}>
+
Courses
+
+ router.push('/content?tag=workshops')} className={`w-full cursor-pointer py-2 my-2 hover:bg-gray-700 rounded-lg ${isActive('/content?tag=workshops') ? 'bg-gray-700' : ''}`}>
+
Workshops
+
+ router.push('/content?tag=resources')} className={`w-full cursor-pointer py-2 my-2 hover:bg-gray-700 rounded-lg ${isActive('/content?tag=resources') ? 'bg-gray-700' : ''}`}>
+
Resources
+
+
+
+
router.push('/create')} className={`w-full flex flex-row items-center cursor-pointer py-2 my-2 hover:bg-gray-700 rounded-lg ${isActive('/create') ? 'bg-gray-700' : ''}`}>
+
Create
-
router.push('/content?tag=workshops')} className={`w-full cursor-pointer py-2 my-2 hover:bg-gray-700 rounded-lg ${isActive('/content?tag=workshops') ? 'bg-gray-700' : ''}`}>
-
Workshops
+
session ? router.push('/profile?tab=subscribe') : router.push('/auth/signin')} className={`w-full flex flex-row items-center cursor-pointer py-2 my-2 hover:bg-gray-700 rounded-lg ${isActive('/profile?tab=subscribe') ? 'bg-gray-700' : ''}`}>
+
Subscribe
-
router.push('/content?tag=resources')} className={`w-full cursor-pointer py-2 my-2 hover:bg-gray-700 rounded-lg ${isActive('/content?tag=resources') ? 'bg-gray-700' : ''}`}>
-
Resources
-
-
-
-
router.push('/create')} className={`w-full flex flex-row items-center cursor-pointer py-2 my-2 hover:bg-gray-700 rounded-lg ${isActive('/create') ? 'bg-gray-700' : ''}`}>
-
Create
-
-
session ? router.push('/profile?tab=subscribe') : router.push('/auth/signin')} className={`w-full flex flex-row items-center cursor-pointer py-2 my-2 hover:bg-gray-700 rounded-lg ${isActive('/profile?tab=subscribe') ? 'bg-gray-700' : ''}`}>
-
Subscribe
-
-
- ({
- className: `hover:bg-gray-700 rounded-lg ${isActive('/feed') ? 'bg-gray-700' : ''} ${styles['p-accordion-header-link']}`
- }),
- content: styles['p-accordion-content'],
- header: 'text-lg'
- }}
- header={"Community"}>
- router.push('/feed?channel=global')} className={`w-full cursor-pointer py-2 my-2 hover:bg-gray-700 rounded-lg ${isActive('/feed?channel=global') ? 'bg-gray-700' : ''}`}>
-
global
-
- router.push('/feed?channel=nostr')} className={`w-full cursor-pointer py-2 my-2 hover:bg-gray-700 rounded-lg ${isActive('/feed?channel=nostr') ? 'bg-gray-700' : ''}`}>
-
nostr
-
- router.push('/feed?channel=discord')} className={`w-full cursor-pointer py-2 my-2 hover:bg-gray-700 rounded-lg ${isActive('/feed?channel=discord') ? 'bg-gray-700' : ''}`}>
-
discord
-
- router.push('/feed?channel=stackernews')} className={`w-full cursor-pointer py-2 my-2 hover:bg-gray-700 rounded-lg ${isActive('/feed?channel=stackernews') ? 'bg-gray-700' : ''}`}>
-
stackernews
-
-
-
+
+ ({
+ className: `hover:bg-gray-700 rounded-lg ${isActive('/feed') ? 'bg-gray-700' : ''} ${styles['p-accordion-header-link']}`
+ }),
+ content: styles['p-accordion-content'],
+ header: 'text-lg'
+ }}
+ header={"Community"}>
+ router.push('/feed?channel=global')} className={`w-full cursor-pointer py-2 my-2 hover:bg-gray-700 rounded-lg ${isActive('/feed?channel=global') ? 'bg-gray-700' : ''}`}>
+
global
+
+ router.push('/feed?channel=nostr')} className={`w-full cursor-pointer py-2 my-2 hover:bg-gray-700 rounded-lg ${isActive('/feed?channel=nostr') ? 'bg-gray-700' : ''}`}>
+
nostr
+
+ router.push('/feed?channel=discord')} className={`w-full cursor-pointer py-2 my-2 hover:bg-gray-700 rounded-lg ${isActive('/feed?channel=discord') ? 'bg-gray-700' : ''}`}>
+
discord
+
+ router.push('/feed?channel=stackernews')} className={`w-full cursor-pointer py-2 my-2 hover:bg-gray-700 rounded-lg ${isActive('/feed?channel=stackernews') ? 'bg-gray-700' : ''}`}>
+
stackernews
+
+
+
+
+ ) : (
+ // Collapsed sidebar content (icons only)
+
+ router.push('/')} />
+ router.push('/content')} />
+ router.push('/create')} />
+ session ? router.push('/profile?tab=subscribe') : router.push('/auth/signin')} />
+ router.push('/feed')} />
+
+ )}
-
router.push('/profile?tab=settings')} className={`w-full flex flex-row items-center cursor-pointer py-2 my-2 hover:bg-gray-700 rounded-lg ${isActive('/profile?tab=settings') ? 'bg-gray-700' : ''}`}>
-
Settings
-
-
session ? signOut() : router.push('/auth/signin')} className={`w-full flex flex-row items-center cursor-pointer py-2 my-2 hover:bg-gray-700 rounded-lg ${isActive('/auth/signin') ? 'bg-gray-700' : ''}`}>
-
{session ? 'Logout' : 'Login'}
-
- {/* todo: have to add this extra button to push the sidebar to the right space but it doesnt seem to cause any negative side effects? */}
-
+ {isExpanded ? (
+
+
router.push('/profile?tab=settings')} className={`w-full flex flex-row items-center cursor-pointer py-2 my-2 hover:bg-gray-700 rounded-lg ${isActive('/profile?tab=settings') ? 'bg-gray-700' : ''}`}>
+
Settings
+
+
session ? signOut() : router.push('/auth/signin')} className={`w-full flex flex-row items-center cursor-pointer py-2 my-2 hover:bg-gray-700 rounded-lg ${isActive('/auth/signin') ? 'bg-gray-700' : ''}`}>
+
{session ? 'Logout' : 'Login'}
+
+ {/* todo: have to add this extra button to push the sidebar to the right space but it doesnt seem to cause any negative side effects? */}
+
+
+ ) : (
+
+ router.push('/profile?tab=settings')} />
+ session ? signOut() : router.push('/auth/signin')} />
+
+ )}
);
diff --git a/src/pages/_app.js b/src/pages/_app.js
index cdb071f..9d45260 100644
--- a/src/pages/_app.js
+++ b/src/pages/_app.js
@@ -1,5 +1,5 @@
import { PrimeReactProvider } from 'primereact/api';
-import { useEffect } from 'react';
+import { useEffect, useState } from 'react';
import Navbar from '@/components/navbar/Navbar';
import { ToastProvider } from '@/hooks/useToast';
import { SessionProvider } from "next-auth/react"
@@ -24,28 +24,41 @@ const queryClient = new QueryClient()
export default function MyApp({
Component, pageProps: { session, ...pageProps }
}) {
+ const [sidebarExpanded, setSidebarExpanded] = useState(true);
+
+ useEffect(() => {
+ const handleSidebarToggle = (event) => {
+ setSidebarExpanded(event.detail.isExpanded);
+ };
+
+ window.addEventListener('sidebarToggle', handleSidebarToggle);
+
+ return () => {
+ window.removeEventListener('sidebarToggle', handleSidebarToggle);
+ };
+ }, []);
+
return (
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
);
diff --git a/src/styles/globals.css b/src/styles/globals.css
index f3f7026..178aa1d 100644
--- a/src/styles/globals.css
+++ b/src/styles/globals.css
@@ -136,4 +136,5 @@ code {
.hljs-type,
.hljs-addition {
color: #ce9178;
-}
\ No newline at end of file
+}
+