mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-25 07:45:47 +00:00
chore: adjust Navbar styling and add breadcrumb to navbar
This commit is contained in:
+41
-31
@@ -1,26 +1,26 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import toast from 'react-hot-toast';
|
import toast from 'react-hot-toast';
|
||||||
import { useRouter } from 'next/navigation';
|
import { usePathname, useRouter } from 'next/navigation';
|
||||||
|
|
||||||
import { Icon } from '@iconify/react';
|
import { Icon } from '@iconify/react';
|
||||||
import Menu from '@/components/menu/Menu';
|
|
||||||
import MenuItem from '@/components/menu/MenuItem';
|
|
||||||
import Button from '@/components/Button';
|
import Button from '@/components/Button';
|
||||||
import Dropdown from '@/components/Dropdown';
|
import Breadcrumb, { buildBreadcrumbs } from '@/components/Breadcrumb';
|
||||||
|
import PopoverButton from '@/components/popover/PopoverButton';
|
||||||
|
import PopoverContent from '@/components/popover/PopoverContent';
|
||||||
|
|
||||||
import { useAuth } from '@/services/hooks/useAuth';
|
import { useAuth } from '@/services/hooks/useAuth';
|
||||||
import { AuthApi } from '@/services/api/auth';
|
import { AuthApi } from '@/services/api/auth';
|
||||||
import { isResponseError } from '@/lib/api-helper';
|
import { isResponseError } from '@/lib/api-helper';
|
||||||
|
|
||||||
interface NavbarProps {
|
interface NavbarProps {
|
||||||
title: string;
|
|
||||||
toggleSidebar?: () => void;
|
toggleSidebar?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Navbar = ({ title, toggleSidebar }: NavbarProps) => {
|
const Navbar = ({ toggleSidebar }: NavbarProps) => {
|
||||||
const { setUser } = useAuth();
|
const { setUser } = useAuth();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const pathname = usePathname();
|
||||||
|
|
||||||
const logoutClickHandler = async () => {
|
const logoutClickHandler = async () => {
|
||||||
const logoutRes = await AuthApi.logout();
|
const logoutRes = await AuthApi.logout();
|
||||||
@@ -35,42 +35,52 @@ const Navbar = ({ title, toggleSidebar }: NavbarProps) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='navbar px-4 bg-base-100 shadow-sm'>
|
<div className='navbar p-3 bg-base-100 border-b border-base-content/10'>
|
||||||
<div className='flex-1'>
|
<div className='flex-1'>
|
||||||
<div className='flex flex-row items-center gap-4'>
|
<div className='flex flex-row items-center gap-4'>
|
||||||
{toggleSidebar && (
|
{toggleSidebar && (
|
||||||
<Button onClick={toggleSidebar} className='block lg:hidden'>
|
<Button
|
||||||
<Icon
|
variant='ghost'
|
||||||
icon='material-symbols:menu-rounded'
|
color='none'
|
||||||
width={24}
|
onClick={toggleSidebar}
|
||||||
height={24}
|
className='block lg:hidden p-[9px] text-base-content/50 border border-base-content/10 rounded-xl shadow-button-soft'
|
||||||
/>
|
>
|
||||||
|
<Icon icon='heroicons:bars-3' width={20} height={20} />
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<span className='font-bold text-xl text-primary'>{title}</span>
|
<Breadcrumb items={buildBreadcrumbs(pathname)} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className='flex gap-2'>
|
<div className='flex gap-2'>
|
||||||
<Dropdown
|
<PopoverButton
|
||||||
align='end'
|
tabIndex={0}
|
||||||
direction='bottom'
|
variant='ghost'
|
||||||
trigger={
|
color='none'
|
||||||
<div className='btn btn-ghost btn-circle avatar'>
|
popoverTarget='accountNavbar'
|
||||||
<div className='w-10 rounded-full border flex justify-center items-center'>
|
anchorName='--account-navbar'
|
||||||
<Icon icon='uil:user' width={40} height={40} />
|
className='p-[9px] text-base-content/50 border border-base-content/10 rounded-xl shadow-button-soft'
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
className={{
|
|
||||||
content: 'w-52 mt-3',
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<Menu>
|
<Icon icon='heroicons:user' width={20} height={20} />
|
||||||
<MenuItem title='Logout' onClick={logoutClickHandler} />
|
</PopoverButton>
|
||||||
</Menu>
|
|
||||||
</Dropdown>
|
<PopoverContent
|
||||||
|
id='accountNavbar'
|
||||||
|
anchorName='--account-navbar'
|
||||||
|
position='bottom-start'
|
||||||
|
className='rounded-xl border border-base-content/5 shadow-sm'
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
onClick={logoutClickHandler}
|
||||||
|
variant='ghost'
|
||||||
|
color='error'
|
||||||
|
className='p-3 justify-start text-sm font-semibold w-full'
|
||||||
|
>
|
||||||
|
<Icon icon='heroicons-outline:logout' width={20} height={20} />
|
||||||
|
Logout
|
||||||
|
</Button>
|
||||||
|
</PopoverContent>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user