Nav: wzajemne linki Panel admina/Aplikacja z SSO + rowne ikony w railu (p-2.5 nadpisywalo p-0)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { useState } from 'react';
|
||||
import { NavLink, Outlet, useNavigate } from 'react-router-dom';
|
||||
import {
|
||||
AppWindow,
|
||||
Building2,
|
||||
Dumbbell,
|
||||
LogOut,
|
||||
@@ -15,6 +16,7 @@ import {
|
||||
type LucideIcon,
|
||||
} from 'lucide-react';
|
||||
import { useAuth } from '../store/auth';
|
||||
import { APP_URL } from '../config';
|
||||
import { Button, ThemeToggle } from './ui';
|
||||
import { Topbar } from '../topbar';
|
||||
import { Brandmark } from './Brandmark';
|
||||
@@ -26,6 +28,8 @@ interface NavItem {
|
||||
label: string;
|
||||
icon: LucideIcon;
|
||||
end: boolean;
|
||||
/** Link na inny origin (np. aplikacja) — <a href>, nie <NavLink>. */
|
||||
external?: boolean;
|
||||
}
|
||||
|
||||
interface NavSection {
|
||||
@@ -53,7 +57,12 @@ const SECTIONS: NavSection[] = [
|
||||
},
|
||||
{
|
||||
label: 'System',
|
||||
items: [{ to: '/logs', label: 'Logi', icon: ScrollText, end: true }],
|
||||
items: [
|
||||
{ to: '/logs', label: 'Logi', icon: ScrollText, end: true },
|
||||
// Powrót do aplikacji użytkownika — zawsze na końcu, inny origin (aplikacja
|
||||
// wznowi sesję z własnego ciastka fitos_refresh, panelu nie dotyka).
|
||||
{ to: APP_URL, label: 'Aplikacja', icon: AppWindow, end: false, external: true },
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
@@ -82,41 +91,60 @@ function NavLinks({
|
||||
className={cn('flex flex-col gap-0.5', collapsed ? 'px-2' : 'px-3')}
|
||||
aria-label="Nawigacja główna"
|
||||
>
|
||||
{items.map((item) => (
|
||||
<NavLink
|
||||
key={item.to}
|
||||
to={item.to}
|
||||
end={item.end}
|
||||
onClick={onNavigate}
|
||||
title={collapsed ? item.label : undefined}
|
||||
aria-label={collapsed ? item.label : undefined}
|
||||
className={({ isActive }) =>
|
||||
cn(
|
||||
'relative flex h-[38px] items-center gap-2.5 rounded-[10px] text-[13.5px] font-semibold transition-colors duration-150',
|
||||
collapsed ? 'justify-center px-0' : 'px-3',
|
||||
isActive
|
||||
? 'bg-accent/11 text-accent-text'
|
||||
: 'text-dim hover:bg-line/30 hover:text-ink',
|
||||
)
|
||||
}
|
||||
>
|
||||
{({ isActive }) => (
|
||||
<>
|
||||
{isActive && (
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className={cn(
|
||||
'absolute bottom-[9px] top-[9px] w-[3px] rounded-full bg-(image:--nav-bar-grad)',
|
||||
collapsed ? '-left-2' : '-left-3',
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
<item.icon className="h-[17px] w-[17px] shrink-0" strokeWidth={1.9} />
|
||||
{!collapsed && <span className="min-w-0 truncate">{item.label}</span>}
|
||||
</>
|
||||
)}
|
||||
</NavLink>
|
||||
))}
|
||||
{items.map((item) => {
|
||||
const rowClass = (isActive: boolean) =>
|
||||
cn(
|
||||
'relative flex h-[38px] items-center gap-2.5 rounded-[10px] text-[13.5px] font-semibold transition-colors duration-150',
|
||||
collapsed ? 'justify-center px-0' : 'px-3',
|
||||
isActive ? 'bg-accent/11 text-accent-text' : 'text-dim hover:bg-line/30 hover:text-ink',
|
||||
);
|
||||
const icon = <item.icon className="h-[17px] w-[17px] shrink-0" strokeWidth={1.9} />;
|
||||
const label = !collapsed && <span className="min-w-0 truncate">{item.label}</span>;
|
||||
|
||||
if (item.external) {
|
||||
return (
|
||||
<a
|
||||
key={item.to}
|
||||
href={item.to}
|
||||
onClick={onNavigate}
|
||||
title={collapsed ? item.label : undefined}
|
||||
aria-label={collapsed ? item.label : undefined}
|
||||
className={rowClass(false)}
|
||||
>
|
||||
{icon}
|
||||
{label}
|
||||
</a>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<NavLink
|
||||
key={item.to}
|
||||
to={item.to}
|
||||
end={item.end}
|
||||
onClick={onNavigate}
|
||||
title={collapsed ? item.label : undefined}
|
||||
aria-label={collapsed ? item.label : undefined}
|
||||
className={({ isActive }) => rowClass(isActive)}
|
||||
>
|
||||
{({ isActive }) => (
|
||||
<>
|
||||
{isActive && (
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className={cn(
|
||||
'absolute bottom-[9px] top-[9px] w-[3px] rounded-full bg-(image:--nav-bar-grad)',
|
||||
collapsed ? '-left-2' : '-left-3',
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
{icon}
|
||||
{label}
|
||||
</>
|
||||
)}
|
||||
</NavLink>
|
||||
);
|
||||
})}
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
@@ -185,13 +213,13 @@ export default function Layout() {
|
||||
const footerRail = (
|
||||
<div className="mt-auto flex flex-col items-center gap-2.5 border-t border-line px-2 pb-4 pt-3">
|
||||
<Avatar name={fullName} size={32} />
|
||||
<ThemeToggle className="h-8 w-8 p-0" />
|
||||
<ThemeToggle />
|
||||
<button
|
||||
type="button"
|
||||
onClick={doLogout}
|
||||
aria-label="Wyloguj"
|
||||
title="Wyloguj"
|
||||
className="grid h-8 w-8 cursor-pointer place-items-center rounded-[10px] border border-line bg-card text-dim shadow-card transition-colors hover:border-danger/45 hover:text-danger"
|
||||
className="grid h-[38px] w-[38px] cursor-pointer place-items-center rounded-[10px] border border-line bg-card text-dim shadow-card transition-colors hover:border-danger/45 hover:text-danger"
|
||||
>
|
||||
<LogOut className="h-5 w-5" />
|
||||
</button>
|
||||
|
||||
@@ -8,7 +8,7 @@ export function ThemeToggle({ className = '' }: { className?: string }) {
|
||||
onClick={toggle}
|
||||
aria-label="Przełącz motyw"
|
||||
title="Przełącz motyw"
|
||||
className={`inline-flex shrink-0 items-center justify-center p-2.5 rounded-[10px] bg-card border border-line text-dim shadow-card hover:text-ink hover:border-accent/45 cursor-pointer transition-all duration-150 ${className}`.trim()}
|
||||
className={`inline-flex items-center justify-center p-2.5 rounded-[10px] bg-card border border-line text-dim shadow-card hover:text-ink hover:border-accent/45 cursor-pointer transition-all duration-150 ${className}`.trim()}
|
||||
>
|
||||
{theme === 'dark' ? <Sun className="w-5 h-5" /> : <Moon className="w-5 h-5" />}
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user