mirror of
https://github.com/ItzCrazyKns/Perplexica.git
synced 2025-10-18 13:28:15 +00:00
feat(sidebar): improve UI, use new settings dialog
This commit is contained in:
@@ -1,20 +1,34 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@/lib/utils';
|
||||||
import { BookOpenText, Home, Search, SquarePen, Settings } from 'lucide-react';
|
import {
|
||||||
|
BookOpenText,
|
||||||
|
Home,
|
||||||
|
Search,
|
||||||
|
SquarePen,
|
||||||
|
Settings,
|
||||||
|
Plus,
|
||||||
|
ArrowLeft,
|
||||||
|
} from 'lucide-react';
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import { useSelectedLayoutSegments } from 'next/navigation';
|
import { useSelectedLayoutSegments } from 'next/navigation';
|
||||||
import React, { useState, type ReactNode } from 'react';
|
import React, { useState, type ReactNode } from 'react';
|
||||||
import Layout from './Layout';
|
import Layout from './Layout';
|
||||||
|
import {
|
||||||
|
Description,
|
||||||
|
Dialog,
|
||||||
|
DialogPanel,
|
||||||
|
DialogTitle,
|
||||||
|
} from '@headlessui/react';
|
||||||
|
import SettingsButton from './Settings/SettingsButton';
|
||||||
|
|
||||||
const VerticalIconContainer = ({ children }: { children: ReactNode }) => {
|
const VerticalIconContainer = ({ children }: { children: ReactNode }) => {
|
||||||
return (
|
return <div className="flex flex-col items-center w-full">{children}</div>;
|
||||||
<div className="flex flex-col items-center gap-y-3 w-full">{children}</div>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const Sidebar = ({ children }: { children: React.ReactNode }) => {
|
const Sidebar = ({ children }: { children: React.ReactNode }) => {
|
||||||
const segments = useSelectedLayoutSegments();
|
const segments = useSelectedLayoutSegments();
|
||||||
|
const [isOpen, setIsOpen] = useState<boolean>(true);
|
||||||
|
|
||||||
const navLinks = [
|
const navLinks = [
|
||||||
{
|
{
|
||||||
@@ -39,10 +53,13 @@ const Sidebar = ({ children }: { children: React.ReactNode }) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className="hidden lg:fixed lg:inset-y-0 lg:z-50 lg:flex lg:w-20 lg:flex-col">
|
<div className="hidden lg:fixed lg:inset-y-0 lg:z-50 lg:flex lg:w-[72px] lg:flex-col border-r border-light-200 dark:border-dark-200">
|
||||||
<div className="flex grow flex-col items-center justify-between gap-y-5 overflow-y-auto bg-light-secondary dark:bg-dark-secondary px-2 py-8 mx-2 my-2 rounded-2xl shadow-sm shadow-light-200/10 dark:shadow-black/25">
|
<div className="flex grow flex-col items-center justify-between gap-y-5 overflow-y-auto bg-light-secondary dark:bg-dark-secondary px-2 py-8 shadow-sm shadow-light-200/10 dark:shadow-black/25">
|
||||||
<a href="/">
|
<a
|
||||||
<SquarePen className="cursor-pointer" />
|
className="p-2.5 rounded-full bg-light-200 text-black/70 dark:bg-dark-200 dark:text-white/70 hover:opacity-70 hover:scale-105 tansition duration-200"
|
||||||
|
href="/"
|
||||||
|
>
|
||||||
|
<Plus size={19} className="cursor-pointer" />
|
||||||
</a>
|
</a>
|
||||||
<VerticalIconContainer>
|
<VerticalIconContainer>
|
||||||
{navLinks.map((link, i) => (
|
{navLinks.map((link, i) => (
|
||||||
@@ -50,23 +67,41 @@ const Sidebar = ({ children }: { children: React.ReactNode }) => {
|
|||||||
key={i}
|
key={i}
|
||||||
href={link.href}
|
href={link.href}
|
||||||
className={cn(
|
className={cn(
|
||||||
'relative flex flex-row items-center justify-center cursor-pointer hover:bg-black/10 dark:hover:bg-white/10 duration-150 transition w-full py-2 rounded-lg',
|
'relative flex flex-col items-center justify-center space-y-0.5 cursor-pointer w-full py-2 rounded-lg',
|
||||||
link.active
|
link.active
|
||||||
? 'text-black dark:text-white'
|
? 'text-black/70 dark:text-white/70 '
|
||||||
: 'text-black/70 dark:text-white/70',
|
: 'text-black/60 dark:text-white/60',
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<link.icon />
|
<div
|
||||||
{link.active && (
|
className={cn(
|
||||||
<div className="absolute right-0 -mr-2 h-full w-1 rounded-l-lg bg-black dark:bg-white" />
|
link.active && 'bg-light-200 dark:bg-dark-200',
|
||||||
)}
|
'group rounded-lg hover:bg-light-200 hover:dark:bg-dark-200 transition duration-200',
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<link.icon
|
||||||
|
size={25}
|
||||||
|
className={cn(
|
||||||
|
!link.active && 'group-hover:scale-105',
|
||||||
|
'transition duration:200 m-1.5',
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<p
|
||||||
|
className={cn(
|
||||||
|
link.active
|
||||||
|
? 'text-black/80 dark:text-white/80'
|
||||||
|
: 'text-black/60 dark:text-white/60',
|
||||||
|
'text-[10px]',
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{link.label}
|
||||||
|
</p>
|
||||||
</Link>
|
</Link>
|
||||||
))}
|
))}
|
||||||
</VerticalIconContainer>
|
</VerticalIconContainer>
|
||||||
|
|
||||||
<Link href="/settings">
|
<SettingsButton />
|
||||||
<Settings className="cursor-pointer" />
|
|
||||||
</Link>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user