feat(admin): replace app name with dashboard icon in breadcrumb root
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import { Fragment } from 'react';
|
import { Fragment } from 'react';
|
||||||
import { Menu, MenuButton, MenuItem, MenuItems, Transition } from '@headlessui/react';
|
import { Menu, MenuButton, MenuItem, MenuItems, Transition } from '@headlessui/react';
|
||||||
import { ChevronDownIcon, User03Icon } from '@zen/core/shared/icons';
|
import { ChevronDownIcon, User03Icon, DashboardSquare03Icon } from '@zen/core/shared/icons';
|
||||||
import { UserAvatar } from '@zen/core/shared/components';
|
import { UserAvatar } from '@zen/core/shared/components';
|
||||||
import { useRouter, usePathname } from 'next/navigation';
|
import { useRouter, usePathname } from 'next/navigation';
|
||||||
import { getPages } from '../registry.js';
|
import { getPages } from '../registry.js';
|
||||||
@@ -36,12 +36,12 @@ const AdminTop = ({ isMobileMenuOpen, setIsMobileMenuOpen, user, onLogout, appNa
|
|||||||
const themeLabel = theme === 'light' ? 'Mode clair' : theme === 'dark' ? 'Mode sombre' : 'Thème système';
|
const themeLabel = theme === 'light' ? 'Mode clair' : theme === 'dark' ? 'Mode sombre' : 'Thème système';
|
||||||
|
|
||||||
const buildBreadcrumbs = () => {
|
const buildBreadcrumbs = () => {
|
||||||
const crumbs = [{ label: appName, href: '/admin/dashboard' }];
|
const crumbs = [{ icon: DashboardSquare03Icon, href: '/admin/dashboard' }];
|
||||||
const after = pathname.replace(/^\/admin\/?/, '');
|
const after = pathname.replace(/^\/admin\/?/, '');
|
||||||
if (!after) return crumbs;
|
if (!after) return crumbs;
|
||||||
|
|
||||||
const segments = after.split('/').filter(Boolean);
|
const segments = after.split('/').filter(Boolean);
|
||||||
if (!segments.length) return crumbs;
|
if (!segments.length || (segments[0] === 'dashboard' && segments.length === 1)) return crumbs;
|
||||||
|
|
||||||
const [first, second] = segments;
|
const [first, second] = segments;
|
||||||
const allItems = navigationSections.flatMap(s => s.items);
|
const allItems = navigationSections.flatMap(s => s.items);
|
||||||
@@ -93,7 +93,14 @@ const AdminTop = ({ isMobileMenuOpen, setIsMobileMenuOpen, user, onLogout, appNa
|
|||||||
<polyline points="9 18 15 12 9 6" />
|
<polyline points="9 18 15 12 9 6" />
|
||||||
</svg>
|
</svg>
|
||||||
)}
|
)}
|
||||||
{crumb.href ? (
|
{crumb.icon ? (
|
||||||
|
<button
|
||||||
|
onClick={() => router.push(crumb.href)}
|
||||||
|
className="text-neutral-500 dark:text-neutral-400 hover:text-neutral-900 dark:hover:text-white transition-colors cursor-pointer"
|
||||||
|
>
|
||||||
|
<crumb.icon className="w-4 h-4" />
|
||||||
|
</button>
|
||||||
|
) : crumb.href ? (
|
||||||
<button
|
<button
|
||||||
onClick={() => router.push(crumb.href)}
|
onClick={() => router.push(crumb.href)}
|
||||||
className="text-neutral-500 dark:text-neutral-400 hover:text-neutral-900 dark:hover:text-white transition-colors cursor-pointer"
|
className="text-neutral-500 dark:text-neutral-400 hover:text-neutral-900 dark:hover:text-white transition-colors cursor-pointer"
|
||||||
|
|||||||
Reference in New Issue
Block a user