2024-03-16 14:56:58 -05:00
|
|
|
import React from 'react';
|
2024-03-13 17:45:55 -05:00
|
|
|
import { Accordion, AccordionTab } from 'primereact/accordion';
|
|
|
|
import { useRouter } from 'next/router';
|
|
|
|
import 'primeicons/primeicons.css';
|
|
|
|
|
|
|
|
const Sidebar = () => {
|
|
|
|
const router = useRouter();
|
|
|
|
|
2024-03-16 14:56:58 -05:00
|
|
|
// Helper function to determine if the path matches the current route
|
|
|
|
const isActive = (path) => {
|
2024-09-02 12:41:26 -05:00
|
|
|
const pathWithQuery = router.pathname + router.asPath.split(router.pathname)[1];
|
|
|
|
return pathWithQuery === path;
|
2024-03-16 14:56:58 -05:00
|
|
|
};
|
|
|
|
|
2024-03-13 17:45:55 -05:00
|
|
|
return (
|
2024-09-02 09:49:17 -05:00
|
|
|
<div className='max-sidebar:hidden w-[13vw] bg-gray-800 p-2 fixed z-10 h-[100%]'>
|
2024-09-02 12:09:27 -05:00
|
|
|
<div onClick={() => 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' : ''}`}>
|
2024-09-02 12:41:26 -05:00
|
|
|
<i className="pi pi-home pl-5" /> <p className="pl-2 rounded-md font-bold">Home</p>
|
2024-03-13 17:45:55 -05:00
|
|
|
</div>
|
2024-09-02 12:09:27 -05:00
|
|
|
<div onClick={() => router.push('/content')} className={`w-full flex flex-row items-center cursor-pointer py-2 my-2 hover:bg-gray-700 rounded-lg ${isActive('/content') ? 'bg-gray-700' : ''}`}>
|
2024-09-02 12:41:26 -05:00
|
|
|
<i className="pi pi-video pl-5" /> <p className="pl-2 rounded-md font-bold">Content</p>
|
2024-09-02 09:49:17 -05:00
|
|
|
</div>
|
2024-09-02 12:09:27 -05:00
|
|
|
<div onClick={() => 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' : ''}`}>
|
2024-09-02 12:41:26 -05:00
|
|
|
<i className="pi pi-plus pl-5" /> <p className="pl-2 rounded-md font-bold">Create</p>
|
2024-03-13 17:45:55 -05:00
|
|
|
</div>
|
2024-09-02 12:09:27 -05:00
|
|
|
<Accordion activeIndex={0}>
|
2024-09-02 12:41:26 -05:00
|
|
|
<AccordionTab pt={{
|
|
|
|
headerAction: ({ context }) => ({
|
|
|
|
className: `hover:bg-gray-700 rounded-lg ${isActive('/feed') ? 'bg-gray-700' : ''}`
|
|
|
|
})
|
|
|
|
}}
|
|
|
|
header={"Community"}>
|
|
|
|
<div onClick={() => router.push('/feed?channel=global')} className={`w-full cursor-pointer py-2 hover:bg-gray-700 rounded-lg ${isActive('/feed?channel=global') ? 'bg-gray-700' : ''}`}>
|
2024-09-02 12:09:27 -05:00
|
|
|
<p className="pl-3 rounded-md font-bold"><i className="pi pi-hashtag text-sm"></i> global</p>
|
2024-03-16 14:56:58 -05:00
|
|
|
</div>
|
2024-09-02 12:41:26 -05:00
|
|
|
<div onClick={() => 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' : ''}`}>
|
2024-09-02 12:09:27 -05:00
|
|
|
<p className="pl-3 rounded-md font-bold"><i className="pi pi-hashtag text-sm"></i> nostr</p>
|
2024-03-16 14:56:58 -05:00
|
|
|
</div>
|
2024-09-02 12:41:26 -05:00
|
|
|
<div onClick={() => 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' : ''}`}>
|
2024-09-02 12:09:27 -05:00
|
|
|
<p className="pl-3 rounded-md font-bold"><i className="pi pi-hashtag text-sm"></i> discord</p>
|
2024-03-16 14:56:58 -05:00
|
|
|
</div>
|
2024-09-02 12:41:26 -05:00
|
|
|
<div onClick={() => 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' : ''}`}>
|
2024-09-02 12:09:27 -05:00
|
|
|
<p className="pl-3 rounded-md font-bold"><i className="pi pi-hashtag text-sm"></i> stackernews</p>
|
2024-03-16 14:56:58 -05:00
|
|
|
</div>
|
2024-03-13 17:45:55 -05:00
|
|
|
</AccordionTab>
|
|
|
|
</Accordion>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Sidebar;
|