Refactored UI and compose file

This commit is contained in:
2026-09-17 07:07:05 +02:00
parent 2d74f7f1bd
commit 831d57a8a0
47 changed files with 9718 additions and 10088 deletions
@@ -1,279 +1,309 @@
import React, { useState } from 'react';
import { NavLink, Outlet, useNavigate, Link } from 'react-router-dom';
import {
LayoutDashboard,
Building2,
FolderKanban,
Coins,
ShieldAlert,
Settings,
LogOut,
Menu,
X,
ChevronRight,
ShieldCheck,
Layers,
Database,
Home,
User,
LayoutDashboard,
Building2,
FolderKanban,
Coins,
ShieldAlert,
Settings,
LogOut,
Menu,
X,
ChevronRight,
ShieldCheck,
Database,
Home,
User,
} from 'lucide-react';
import { useAuth } from '../../auth/AuthProvider';
import { BrandLogo } from '../ui/BrandLogo';
const navItems = [
{
name: 'Executive Dashboard',
path: '/dashboard',
icon: LayoutDashboard,
},
{
name: 'Governance & Structure',
path: '/governance',
icon: Building2,
},
{
name: 'Projects & Milestones',
path: '/projects',
icon: FolderKanban,
},
{
name: 'Grant & Financials',
path: '/grants',
icon: Coins,
},
{
name: 'M&E, Evidence & Risks',
path: '/monitoring',
icon: ShieldAlert,
},
{
name: 'Settings & Communications',
path: '/settings',
icon: Settings,
},
{
name: 'Executive Dashboard',
path: '/dashboard',
icon: LayoutDashboard,
},
{
name: 'Governance & Structure',
path: '/governance',
icon: Building2,
},
{
name: 'Projects & Milestones',
path: '/projects',
icon: FolderKanban,
},
{
name: 'Grant & Financials',
path: '/grants',
icon: Coins,
},
{
name: 'M&E, Evidence & Risks',
path: '/monitoring',
icon: ShieldAlert,
},
{
name: 'Settings & Communications',
path: '/settings',
icon: Settings,
},
];
export const AppLayout: React.FC = () => {
const { user, claims, sub, logout } = useAuth();
const [sidebarOpen, setSidebarOpen] = useState(true);
const [userMenuOpen, setUserMenuOpen] = useState(false);
const navigate = useNavigate();
const { user, claims, sub, logout } = useAuth();
const [sidebarOpen, setSidebarOpen] = useState(true);
const [userMenuOpen, setUserMenuOpen] = useState(false);
const navigate = useNavigate();
const handleLogout = async () => {
await logout();
};
const handleLogout = async () => {
await logout();
};
// Extract name and email directly from validated token claims
const tokenUserName =
user?.name ||
(claims.name as string) ||
(claims.preferred_username as string) ||
(claims.given_name ? `${claims.given_name} ${claims.family_name || ''}`.trim() : '') ||
'Authorized User';
// Extract name and email directly from validated token claims
const tokenUserName =
user?.name ||
(claims.name as string) ||
(claims.preferred_username as string) ||
(claims.given_name ? `${claims.given_name} ${claims.family_name || ''}`.trim() : '') ||
'Authorized User';
const tokenUserEmail =
user?.email ||
(claims.email as string) ||
(claims['http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress'] as string) ||
(claims.upn as string) ||
(sub ? `sub:${sub}` : '');
const tokenUserEmail =
user?.email ||
(claims.email as string) ||
(claims['http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress'] as string) ||
(claims.upn as string) ||
(sub ? `sub:${sub}` : '');
return (
<div className="flex h-screen w-full overflow-hidden bg-[#090d16] font-sans text-slate-100 selection:bg-blue-600 selection:text-white">
{/* Sidebar */}
<aside
className={`${sidebarOpen ? 'w-64' : 'w-20'
} shrink-0 bg-[#0b101b]/95 text-slate-200 border-r border-slate-800/80 transition-all duration-300 flex flex-col z-30 shadow-2xl backdrop-blur-md`}
>
{/* Brand Header — Clickable link navigating to auth-aware Home page */}
<div className="h-16 px-4 flex items-center justify-between border-b border-slate-800/80 bg-[#0d121f]/90">
<Link
to="/"
id="nav-brand-home-link"
title="Go to Home page"
className="flex items-center gap-3 overflow-hidden group cursor-pointer"
>
<div className="flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-gradient-to-br from-blue-600 to-indigo-700 font-bold text-white shadow-md shadow-blue-500/20 border border-blue-400/20 group-hover:scale-105 transition">
<Layers className="w-5 h-5 text-white" />
</div>
{sidebarOpen && (
<div className="flex flex-col min-w-0">
<span className="font-semibold text-sm tracking-tight text-white truncate group-hover:text-blue-400 transition">
PFM Console
</span>
<span className="text-[11px] text-blue-400 font-medium tracking-tight">Enterprise Management</span>
</div>
)}
</Link>
<button
onClick={() => setSidebarOpen(!sidebarOpen)}
className="rounded-lg p-1.5 text-slate-400 hover:text-white hover:bg-slate-800/60 transition cursor-pointer"
title={sidebarOpen ? 'Collapse sidebar' : 'Expand sidebar'}
>
{sidebarOpen ? <X className="w-4 h-4" /> : <Menu className="w-4 h-4" />}
</button>
</div>
// Extract tenant name directly from the user claim named 'tenant'
const tenantName =
(claims?.tenant as string) ||
user?.tenant ||
(claims?.['tenant'] as string) ||
user?.organisationName ||
(claims?.organisation as string) ||
'Department of Science, Innovation & Technology (DSI)';
{/* Navigation Items */}
<nav className="flex-1 overflow-y-auto px-3 py-4 space-y-1.5">
{navItems.map((item) => {
const Icon = item.icon;
return (
<NavLink
key={item.path}
to={item.path}
className={({ isActive }) =>
`flex items-center gap-3 px-3.5 py-2.5 rounded-xl text-xs font-medium transition-all ${isActive
? 'bg-gradient-to-r from-blue-600 to-indigo-600 text-white shadow-md shadow-blue-600/25 font-semibold'
: 'text-slate-400 hover:text-slate-100 hover:bg-slate-800/60'
}`
}
>
<Icon className="w-4 h-4 shrink-0" />
{sidebarOpen && <span className="truncate">{item.name}</span>}
</NavLink>
);
})}
</nav>
{/* User Card with Token-derived info & Identity Server Logout */}
<div className="p-3 border-t border-slate-800/80 bg-[#0d121f]/90">
<div className="flex items-center gap-3">
<div className="h-9 w-9 shrink-0 rounded-full bg-blue-600/20 border border-blue-500/40 flex items-center justify-center font-bold text-xs text-blue-400">
{tokenUserName ? tokenUserName.slice(0, 2).toUpperCase() : 'AU'}
</div>
{sidebarOpen && (
<div className="flex-1 min-w-0">
<p className="text-xs font-semibold text-white truncate" title={tokenUserName}>
{tokenUserName}
</p>
<p className="text-[11px] text-slate-400 truncate font-mono" title={tokenUserEmail}>
{tokenUserEmail || 'STS Token User'}
</p>
</div>
)}
<button
onClick={handleLogout}
id="sidebar-logout-btn"
className="rounded-lg p-1.5 text-slate-400 hover:text-rose-400 hover:bg-rose-950/30 transition cursor-pointer"
title="Sign Out via Identity Server"
>
<LogOut className="w-4 h-4" />
</button>
</div>
</div>
</aside>
{/* Main Content Area */}
<div className="flex-1 flex flex-col min-w-0 overflow-hidden relative">
{/* Top Header */}
<header className="h-16 bg-[#0d121f]/90 border-b border-slate-800/80 backdrop-blur-md px-6 md:px-8 flex items-center justify-between shrink-0 z-20">
<div className="flex items-center gap-3">
{/* Clickable Home Link */}
<Link
to="/"
id="header-home-link"
className="flex items-center gap-1.5 text-xs font-semibold text-slate-300 hover:text-white bg-slate-900/80 hover:bg-slate-800 px-3 py-1.5 rounded-lg border border-slate-800 transition cursor-pointer shadow-xs"
title="Return to Auth-Aware Home page"
>
<Home className="w-3.5 h-3.5 text-blue-400" />
<span>Home</span>
</Link>
<ChevronRight className="w-4 h-4 text-slate-600" />
<div className="hidden sm:flex items-center gap-2 text-xs font-medium text-slate-300">
<span className="text-slate-400">Tenant:</span>
<span className="bg-slate-900/80 text-slate-200 px-2.5 py-1 rounded-lg border border-slate-800 flex items-center gap-1.5 font-medium shadow-xs">
<Database className="w-3.5 h-3.5 text-blue-400" />
Department of Science, Innovation & Technology (DSI)
</span>
</div>
<ChevronRight className="w-4 h-4 text-slate-600 hidden sm:block" />
<span className="text-xs font-medium text-emerald-400 bg-emerald-500/10 px-2.5 py-0.5 rounded-full border border-emerald-500/30 flex items-center gap-1.5 shadow-xs">
<ShieldCheck className="w-3.5 h-3.5 text-emerald-400" />
Authenticated Session
</span>
</div>
{/* User Name & Email derived from token, plus Identity Server signout */}
<div className="relative flex items-center gap-3">
<div className="text-right hidden sm:block">
<p className="text-xs font-semibold text-white truncate max-w-[200px]" title={tokenUserName}>
{tokenUserName}
</p>
<p className="text-[11px] text-slate-400 font-mono truncate max-w-[200px]" title={tokenUserEmail}>
{tokenUserEmail}
</p>
</div>
<button
onClick={() => setUserMenuOpen(!userMenuOpen)}
id="header-user-menu-btn"
className="h-9 w-9 rounded-full bg-blue-600/20 border border-blue-500/40 hover:border-blue-400 flex items-center justify-center font-bold text-xs text-blue-400 transition cursor-pointer shadow-md shadow-blue-500/10"
title="User Account"
>
{tokenUserName ? tokenUserName.slice(0, 2).toUpperCase() : <User className="w-4 h-4" />}
</button>
{/* Dropdown Menu */}
{userMenuOpen && (
<div
className="absolute right-0 top-12 w-64 bg-[#0f1523] border border-slate-800 rounded-2xl shadow-2xl p-3 z-50 space-y-2 animate-in fade-in slide-in-from-top-2 backdrop-blur-md"
onMouseLeave={() => setUserMenuOpen(false)}
>
<div className="p-2.5 border-b border-slate-800">
<p className="text-xs font-semibold text-white">{tokenUserName}</p>
<p className="text-[11px] text-slate-400 font-mono truncate">{tokenUserEmail}</p>
{sub && <p className="text-[10px] text-slate-500 font-mono mt-1">sub: {sub}</p>}
</div>
<Link
to="/"
onClick={() => setUserMenuOpen(false)}
className="flex items-center gap-2 px-3 py-2 text-xs text-slate-300 hover:text-white hover:bg-slate-800/60 rounded-xl transition"
>
<Home className="w-3.5 h-3.5 text-blue-400" />
<span>Go to Home Page</span>
</Link>
<button
onClick={handleLogout}
id="dropdown-logout-btn"
className="w-full flex items-center gap-2 px-3 py-2 text-xs text-rose-400 hover:bg-rose-950/30 rounded-xl transition cursor-pointer"
>
<LogOut className="w-3.5 h-3.5" />
<span>Sign Out via Identity Server</span>
</button>
</div>
)}
</div>
</header>
{/* Viewport with Landing Page ambient dot grid and glow */}
<main className="flex-1 overflow-y-auto p-6 md:p-8 bg-[#090d16] relative text-slate-100">
<div
className="absolute inset-0 pointer-events-none opacity-15"
style={{
backgroundImage: 'radial-gradient(circle at 1px 1px, rgba(255,255,255,0.15) 1px, transparent 0)',
backgroundSize: '32px 32px',
}}
/>
<div className="absolute -top-24 -left-24 w-80 h-80 bg-blue-600/10 rounded-full blur-3xl pointer-events-none" />
<div className="absolute top-1/2 -right-24 w-80 h-80 bg-indigo-600/10 rounded-full blur-3xl pointer-events-none" />
<div className="relative z-10">
<Outlet />
</div>
</main>
{/* Bottom Status Footer */}
<footer className="h-10 px-6 md:px-8 border-t border-slate-800/80 bg-[#0d121f]/90 flex items-center justify-between text-[11px] text-slate-400 shrink-0">
<span>Project Financial Management (PFM) System</span>
<span className="text-slate-400 font-medium">Duende STS OIDC Secure Session</span>
</footer>
</div>
return (
<div className="flex h-screen w-full overflow-hidden bg-[#090d16] font-sans text-slate-100 selection:bg-blue-600 selection:text-white">
{/* Sidebar */}
<aside
className={`${
sidebarOpen ? 'w-64' : 'w-20'
} shrink-0 bg-[#0b101b]/95 text-slate-200 border-r border-slate-800/80 transition-all duration-300 flex flex-col z-30 shadow-2xl backdrop-blur-md`}
>
{/* Brand Header — Clickable link navigating to auth-aware Home page */}
<div className="h-16 px-4 flex items-center justify-between border-b border-slate-800/80 bg-[#0d121f]/90">
<Link
to="/"
id="nav-brand-home-link"
title="Go to Home page"
className="flex items-center gap-3 overflow-hidden group cursor-pointer"
>
<BrandLogo size={36} showGlow animateOnHover />
{sidebarOpen && (
<div className="flex flex-col min-w-0">
<span className="font-bold text-sm tracking-tight text-white truncate group-hover:text-blue-400 transition">
PFM Console
</span>
<span className="text-[11px] text-blue-400 font-medium tracking-tight">Enterprise Management</span>
</div>
)}
</Link>
<button
onClick={() => setSidebarOpen(!sidebarOpen)}
className="rounded-lg p-1.5 text-slate-400 hover:text-white hover:bg-slate-800/60 transition cursor-pointer"
title={sidebarOpen ? 'Collapse sidebar' : 'Expand sidebar'}
>
{sidebarOpen ? <X className="w-4 h-4" /> : <Menu className="w-4 h-4" />}
</button>
</div>
);
{/* Navigation Items */}
<nav className="flex-1 overflow-y-auto px-3 py-4 space-y-1.5">
{navItems.map((item) => {
const Icon = item.icon;
return (
<NavLink
key={item.path}
to={item.path}
className={({ isActive }) =>
`flex items-center gap-3 px-3.5 py-2.5 rounded-xl text-xs font-medium transition-all ${
isActive
? 'bg-gradient-to-r from-blue-600 to-indigo-600 text-white shadow-md shadow-blue-600/25 font-semibold'
: 'text-slate-400 hover:text-slate-100 hover:bg-slate-800/60'
}`
}
>
<Icon className="w-4 h-4 shrink-0" />
{sidebarOpen && <span className="truncate">{item.name}</span>}
</NavLink>
);
})}
</nav>
{/* User Card with Token-derived info & Identity Server Logout */}
<div className="p-3 border-t border-slate-800/80 bg-[#0d121f]/90">
<div className="flex items-center gap-3">
<div className="h-9 w-9 shrink-0 rounded-full bg-blue-600/20 border border-blue-500/40 flex items-center justify-center font-bold text-xs text-blue-400">
{tokenUserName ? tokenUserName.slice(0, 2).toUpperCase() : 'AU'}
</div>
{sidebarOpen && (
<div className="flex-1 min-w-0">
<p className="text-xs font-semibold text-white truncate" title={tokenUserName}>
{tokenUserName}
</p>
<p className="text-[11px] text-slate-400 truncate font-mono" title={tokenUserEmail}>
{tokenUserEmail || 'Authenticated User'}
</p>
</div>
)}
<button
onClick={handleLogout}
id="sidebar-logout-btn"
className="rounded-lg p-1.5 text-slate-400 hover:text-rose-400 hover:bg-rose-950/30 transition cursor-pointer"
title="Sign Out of Session"
>
<LogOut className="w-4 h-4" />
</button>
</div>
</div>
</aside>
{/* Main Content Area */}
<div className="flex-1 flex flex-col min-w-0 overflow-hidden relative">
{/* Top Header */}
<header className="h-16 bg-[#0d121f]/90 border-b border-slate-800/80 backdrop-blur-md px-4 sm:px-6 md:px-8 flex items-center justify-between shrink-0 z-20">
<div className="flex items-center gap-3">
{/* Top Bar Brand Icon & Direct Portal Link */}
<Link
to="/"
id="header-brand-logo-link"
className="flex items-center gap-2 group cursor-pointer"
title="PFM Console Home"
>
<BrandLogo size={28} showGlow={false} animateOnHover />
<span className="font-bold text-xs tracking-tight text-white hidden md:inline-block group-hover:text-blue-400 transition">
PFM
</span>
</Link>
<span className="h-4 w-px bg-slate-800 hidden md:block" />
{/* Clickable Home Link */}
<Link
to="/"
id="header-home-link"
className="flex items-center gap-1.5 text-xs font-semibold text-slate-300 hover:text-white bg-slate-900/80 hover:bg-slate-800 px-3 py-1.5 rounded-lg border border-slate-800 transition cursor-pointer shadow-xs"
title="Return to Auth-Aware Home page"
>
<Home className="w-3.5 h-3.5 text-blue-400" />
<span>Home</span>
</Link>
<ChevronRight className="w-4 h-4 text-slate-600" />
<div className="hidden sm:flex items-center gap-2 text-xs font-medium text-slate-300">
<span className="text-slate-400">Tenant:</span>
<span
className="bg-slate-900/80 text-slate-200 px-2.5 py-1 rounded-lg border border-slate-800 flex items-center gap-1.5 font-medium shadow-xs max-w-[280px] truncate"
title={tenantName}
>
<Database className="w-3.5 h-3.5 text-blue-400 shrink-0" />
<span className="truncate">{tenantName}</span>
</span>
</div>
<ChevronRight className="w-4 h-4 text-slate-600 hidden sm:block" />
<span className="text-xs font-medium text-emerald-400 bg-emerald-500/10 px-2.5 py-0.5 rounded-full border border-emerald-500/30 flex items-center gap-1.5 shadow-xs">
<ShieldCheck className="w-3.5 h-3.5 text-emerald-400" />
Authenticated Session
</span>
</div>
{/* User Name & Email derived from token, plus Identity Server signout */}
<div className="relative flex items-center gap-3">
<div className="text-right hidden sm:block">
<p className="text-xs font-semibold text-white truncate max-w-[200px]" title={tokenUserName}>
{tokenUserName}
</p>
<p className="text-[11px] text-slate-400 font-mono truncate max-w-[200px]" title={tokenUserEmail}>
{tokenUserEmail}
</p>
</div>
<button
onClick={() => setUserMenuOpen(!userMenuOpen)}
id="header-user-menu-btn"
className="h-9 w-9 rounded-full bg-blue-600/20 border border-blue-500/40 hover:border-blue-400 flex items-center justify-center font-bold text-xs text-blue-400 transition cursor-pointer shadow-md shadow-blue-500/10"
title="User Account"
>
{tokenUserName ? tokenUserName.slice(0, 2).toUpperCase() : <User className="w-4 h-4" />}
</button>
{/* Dropdown Menu */}
{userMenuOpen && (
<div
className="absolute right-0 top-12 w-64 bg-[#0f1523] border border-slate-800 rounded-2xl shadow-2xl p-3 z-50 space-y-2 animate-in fade-in slide-in-from-top-2 backdrop-blur-md"
onMouseLeave={() => setUserMenuOpen(false)}
>
<div className="p-2.5 border-b border-slate-800">
<p className="text-xs font-semibold text-white">{tokenUserName}</p>
<p className="text-[11px] text-slate-400 font-mono truncate">{tokenUserEmail}</p>
{sub && <p className="text-[10px] text-slate-500 font-mono mt-1">sub: {sub}</p>}
</div>
<Link
to="/"
onClick={() => setUserMenuOpen(false)}
className="flex items-center gap-2 px-3 py-2 text-xs text-slate-300 hover:text-white hover:bg-slate-800/60 rounded-xl transition"
>
<Home className="w-3.5 h-3.5 text-blue-400" />
<span>Go to Home Page</span>
</Link>
<button
onClick={handleLogout}
id="dropdown-logout-btn"
className="w-full flex items-center gap-2 px-3 py-2 text-xs text-rose-400 hover:bg-rose-950/30 rounded-xl transition cursor-pointer"
>
<LogOut className="w-3.5 h-3.5" />
<span>Sign Out of Session</span>
</button>
</div>
)}
</div>
</header>
{/* Viewport with Landing Page ambient dot grid and glow */}
<main className="flex-1 overflow-y-auto p-6 md:p-8 bg-[#090d16] relative text-slate-100">
<div
className="absolute inset-0 pointer-events-none opacity-15"
style={{
backgroundImage: 'radial-gradient(circle at 1px 1px, rgba(255,255,255,0.15) 1px, transparent 0)',
backgroundSize: '32px 32px',
}}
/>
<div className="absolute -top-24 -left-24 w-80 h-80 bg-blue-600/10 rounded-full blur-3xl pointer-events-none" />
<div className="absolute top-1/2 -right-24 w-80 h-80 bg-indigo-600/10 rounded-full blur-3xl pointer-events-none" />
<div className="relative z-10">
<Outlet />
</div>
</main>
{/* Bottom Status Footer */}
<footer className="h-10 px-6 md:px-8 border-t border-slate-800/80 bg-[#0d121f]/90 flex items-center justify-between text-[11px] text-slate-400 shrink-0">
<span>Project Financial Management (PFM) System</span>
<span className="text-slate-400 font-medium flex items-center gap-1.5">
<span className="h-1.5 w-1.5 rounded-full bg-emerald-400 inline-block"></span>
Enterprise Secure Session
</span>
</footer>
</div>
</div>
);
};
@@ -0,0 +1,188 @@
import React, { useId } from 'react';
export interface BrandLogoProps {
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | number;
variant?: 'icon-only' | 'full';
showGlow?: boolean;
className?: string;
animateOnHover?: boolean;
}
const sizeMap = {
xs: 20,
sm: 28,
md: 36,
lg: 44,
xl: 56,
};
/**
* Modern, stylized SVG brand emblem representing Post Fund Management (PFM).
* Features an isometric kinetic nexus with three interlocking governance facets:
* 1. Top Canopy: Governance, Strategy & Portfolios (Radiant Indigo / Violet)
* 2. Left Vault: Capital, Grants & Disbursement Assurance (Electric Sapphire)
* 3. Right Wing: Milestones, Evidence & Impact Delivery (Cyan to Emerald)
* 4. Center Core: Luminous Floating Diamond Milestone Star
*/
export const BrandLogo: React.FC<BrandLogoProps> = ({
size = 'md',
variant = 'icon-only',
showGlow = true,
className = '',
animateOnHover = true,
}) => {
const uniqueId = useId().replace(/:/g, '');
const pixelSize = typeof size === 'number' ? size : sizeMap[size] || 36;
const glowId = `pfm-ambient-${uniqueId}`;
const topGradId = `pfm-top-${uniqueId}`;
const leftGradId = `pfm-left-${uniqueId}`;
const rightGradId = `pfm-right-${uniqueId}`;
const coreGradId = `pfm-core-${uniqueId}`;
const filterId = `pfm-filter-${uniqueId}`;
return (
<div
className={`inline-flex items-center gap-3 select-none ${
animateOnHover ? 'group cursor-pointer' : ''
} ${className}`}
>
<div
style={{ width: pixelSize, height: pixelSize }}
className={`relative shrink-0 flex items-center justify-center transition-transform duration-300 ${
animateOnHover ? 'group-hover:scale-105' : ''
}`}
>
{showGlow && (
<div
className="absolute inset-0 rounded-2xl bg-blue-500/20 blur-md pointer-events-none transition-opacity duration-300 group-hover:opacity-100 opacity-60"
/>
)}
<svg
viewBox="0 0 64 64"
width={pixelSize}
height={pixelSize}
fill="none"
xmlns="http://www.w3.org/2000/svg"
className="relative z-10 w-full h-full drop-shadow-sm"
>
<defs>
{/* Ambient Radial Glow */}
<radialGradient id={glowId} cx="50%" cy="50%" r="50%">
<stop offset="0%" stopColor="#38bdf8" stopOpacity="0.4" />
<stop offset="70%" stopColor="#2563eb" stopOpacity="0.12" />
<stop offset="100%" stopColor="#1e1b4b" stopOpacity="0" />
</radialGradient>
{/* Top facet: Governance & Portfolios (Indigo / Radiant Violet) */}
<linearGradient id={topGradId} x1="12" y1="8" x2="52" y2="26" gradientUnits="userSpaceOnUse">
<stop offset="0%" stopColor="#a5b4fc" />
<stop offset="35%" stopColor="#6366f1" />
<stop offset="100%" stopColor="#4338ca" />
</linearGradient>
{/* Left facet: Capital & Disbursement Vault (Electric Sapphire) */}
<linearGradient id={leftGradId} x1="10" y1="22" x2="30" y2="56" gradientUnits="userSpaceOnUse">
<stop offset="0%" stopColor="#38bdf8" />
<stop offset="45%" stopColor="#2563eb" />
<stop offset="100%" stopColor="#1e40af" />
</linearGradient>
{/* Right facet: Milestones, Evidence & Impact Delivery (Cyan to Emerald) */}
<linearGradient id={rightGradId} x1="34" y1="28" x2="54" y2="56" gradientUnits="userSpaceOnUse">
<stop offset="0%" stopColor="#22d3ee" />
<stop offset="50%" stopColor="#06b6d4" />
<stop offset="100%" stopColor="#10b981" />
</linearGradient>
{/* Center Radiant Diamond */}
<linearGradient id={coreGradId} x1="27" y1="27" x2="37" y2="37" gradientUnits="userSpaceOnUse">
<stop offset="0%" stopColor="#ffffff" />
<stop offset="40%" stopColor="#e0f2fe" />
<stop offset="100%" stopColor="#38bdf8" />
</linearGradient>
{/* Core luminous glow filter */}
<filter id={filterId} x="-20%" y="-20%" width="140%" height="140%">
<feGaussianBlur stdDeviation="1.5" result="blur" />
<feComposite in="SourceGraphic" in2="blur" operator="over" />
</filter>
</defs>
{/* Deep Contrast Foundation Disk */}
<circle cx="32" cy="32" r="31" fill="#090d16" />
<circle cx="32" cy="32" r="30" stroke="#1e293b" strokeWidth="1" />
<circle cx="32" cy="32" r="28" fill={`url(#${glowId})`} />
{/* Outer Hexagonal Structural Shield Outline */}
<path
d="M32 6.5 L53.5 19 C55 19.8 56 21.5 56 23.2 L56 40.8 C56 42.5 55 44.2 53.5 45 L32 57.5 C30.5 58.3 28.5 58.3 27 57.5 L5.5 45 C4 44.2 3 42.5 3 40.8 L3 23.2 C3 21.5 4 19.8 5.5 19 L27 6.5 C28.5 5.7 30.5 5.7 32 6.5 Z"
stroke="#3b82f6"
strokeOpacity="0.35"
strokeWidth="1.2"
fill="none"
/>
{/* Facet 1: Top Canopy (Governance / Oversight Architecture) */}
<path
d="M32 9 L51.5 20.2 L43 25.2 L32 18.8 L21 25.2 L12.5 20.2 Z"
fill={`url(#${topGradId})`}
/>
{/* Facet 2: Left Vault (Fund Management & Capital Allocation) */}
<path
d="M10 23 L19.2 28.4 L19.2 44.5 L30 50.8 L30 55.5 L10 43.8 Z"
fill={`url(#${leftGradId})`}
/>
{/* Facet 3: Right Wing (Milestone Performance & Impact Assurance) */}
<path
d="M54 23 L54 43.8 L34 55.5 L34 50.8 L44.8 44.5 L44.8 28.4 Z"
fill={`url(#${rightGradId})`}
/>
{/* Center Geometric Hub (The PFM Nexus Plate) */}
<path
d="M22 28.5 L32 22.8 L42 28.5 L42 35.5 L32 41.2 L22 35.5 Z"
fill="#0b1120"
stroke="#334155"
strokeWidth="1"
/>
{/* Kinetic Stepped Prisms */}
<path
d="M25 31.5 L32 27.5 L39 31.5 L32 35.5 Z"
fill={`url(#${topGradId})`}
opacity="0.9"
/>
<path
d="M25 37 L32 41 L39 37 L32 33 L25 37 Z"
fill={`url(#${rightGradId})`}
opacity="0.9"
/>
{/* Center Radiant Milestone Diamond */}
<polygon
points="32,27 36.5,32 32,37 27.5,32"
fill={`url(#${coreGradId})`}
filter={`url(#${filterId})`}
/>
{/* Center Pure White Optical Star Point */}
<circle cx="32" cy="32" r="1.5" fill="#ffffff" />
</svg>
</div>
{variant === 'full' && (
<div className="flex flex-col min-w-0">
<span className="font-bold text-sm tracking-tight text-white truncate group-hover:text-blue-400 transition">
PFM Console
</span>
<span className="text-[11px] text-blue-400 font-medium tracking-tight">
Post-Fund Governance
</span>
</div>
)}
</div>
);
};
@@ -2,66 +2,66 @@ import React, { ReactNode, useEffect } from 'react';
import { X } from 'lucide-react';
interface ModalProps {
isOpen: boolean;
onClose: () => void;
title: string;
subtitle?: string;
children: ReactNode;
maxWidth?: 'sm' | 'md' | 'lg' | 'xl' | '2xl';
isOpen: boolean;
onClose: () => void;
title: string;
subtitle?: string;
children: ReactNode;
maxWidth?: 'sm' | 'md' | 'lg' | 'xl' | '2xl';
}
export const Modal: React.FC<ModalProps> = ({
isOpen,
onClose,
title,
subtitle,
children,
maxWidth = 'lg',
isOpen,
onClose,
title,
subtitle,
children,
maxWidth = 'lg',
}) => {
useEffect(() => {
const handleKeyDown = (e: KeyboardEvent) => {
if (e.key === 'Escape') onClose();
};
if (isOpen) {
document.body.style.overflow = 'hidden';
window.addEventListener('keydown', handleKeyDown);
}
return () => {
document.body.style.overflow = 'unset';
window.removeEventListener('keydown', handleKeyDown);
};
}, [isOpen, onClose]);
useEffect(() => {
const handleKeyDown = (e: KeyboardEvent) => {
if (e.key === 'Escape') onClose();
};
if (isOpen) {
document.body.style.overflow = 'hidden';
window.addEventListener('keydown', handleKeyDown);
}
return () => {
document.body.style.overflow = 'unset';
window.removeEventListener('keydown', handleKeyDown);
};
}, [isOpen, onClose]);
if (!isOpen) return null;
if (!isOpen) return null;
const maxWidthClass = {
sm: 'max-w-sm',
md: 'max-w-md',
lg: 'max-w-lg',
xl: 'max-w-xl',
'2xl': 'max-w-2xl',
}[maxWidth];
const maxWidthClass = {
sm: 'max-w-sm',
md: 'max-w-md',
lg: 'max-w-lg',
xl: 'max-w-xl',
'2xl': 'max-w-2xl',
}[maxWidth];
return (
<div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/80 backdrop-blur-sm animate-in fade-in duration-150">
<div
className={`relative w-full ${maxWidthClass} bg-[#0f1523] rounded-2xl shadow-2xl border border-slate-800/90 overflow-hidden flex flex-col max-h-[90vh] text-slate-200`}
onClick={(e) => e.stopPropagation()}
>
<div className="flex items-start justify-between p-5 border-b border-slate-800/80 bg-[#0d121f]/90">
<div>
<h3 className="text-lg font-semibold text-white tracking-tight">{title}</h3>
{subtitle && <p className="text-xs text-slate-400 mt-0.5">{subtitle}</p>}
</div>
<button
onClick={onClose}
className="rounded-xl p-1.5 text-slate-400 hover:text-white hover:bg-slate-800/60 transition cursor-pointer"
>
<X className="w-5 h-5" />
</button>
</div>
<div className="p-6 overflow-y-auto flex-1 bg-[#0f1523]">{children}</div>
</div>
return (
<div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/80 backdrop-blur-sm animate-in fade-in duration-150">
<div
className={`relative w-full ${maxWidthClass} bg-[#0f1523] rounded-2xl shadow-2xl border border-slate-800/90 overflow-hidden flex flex-col max-h-[90vh] text-slate-200`}
onClick={(e) => e.stopPropagation()}
>
<div className="flex items-start justify-between p-5 border-b border-slate-800/80 bg-[#0d121f]/90">
<div>
<h3 className="text-lg font-semibold text-white tracking-tight">{title}</h3>
{subtitle && <p className="text-xs text-slate-400 mt-0.5">{subtitle}</p>}
</div>
<button
onClick={onClose}
className="rounded-xl p-1.5 text-slate-400 hover:text-white hover:bg-slate-800/60 transition cursor-pointer"
>
<X className="w-5 h-5" />
</button>
</div>
);
<div className="p-6 overflow-y-auto flex-1 bg-[#0f1523]">{children}</div>
</div>
</div>
);
};
@@ -4,76 +4,77 @@ import { CheckCircle2, AlertCircle, Info, X } from 'lucide-react';
export type ToastType = 'success' | 'error' | 'info';
interface ToastItem {
id: string;
type: ToastType;
title: string;
message?: string;
id: string;
type: ToastType;
title: string;
message?: string;
}
interface ToastContextType {
toast: (type: ToastType, title: string, message?: string) => void;
success: (title: string, message?: string) => void;
error: (title: string, message?: string) => void;
info: (title: string, message?: string) => void;
toast: (type: ToastType, title: string, message?: string) => void;
success: (title: string, message?: string) => void;
error: (title: string, message?: string) => void;
info: (title: string, message?: string) => void;
}
const ToastContext = createContext<ToastContextType | undefined>(undefined);
export const ToastProvider: React.FC<{ children: ReactNode }> = ({ children }) => {
const [toasts, setToasts] = useState<ToastItem[]>([]);
const [toasts, setToasts] = useState<ToastItem[]>([]);
const removeToast = (id: string) => {
setToasts((prev) => prev.filter((t) => t.id !== id));
};
const removeToast = (id: string) => {
setToasts((prev) => prev.filter((t) => t.id !== id));
};
const addToast = (type: ToastType, title: string, message?: string) => {
const id = Math.random().toString(36).substring(2, 9);
setToasts((prev) => [...prev, { id, type, title, message }]);
setTimeout(() => removeToast(id), 5000);
};
const addToast = (type: ToastType, title: string, message?: string) => {
const id = Math.random().toString(36).substring(2, 9);
setToasts((prev) => [...prev, { id, type, title, message }]);
setTimeout(() => removeToast(id), 5000);
};
const success = (title: string, message?: string) => addToast('success', title, message);
const error = (title: string, message?: string) => addToast('error', title, message);
const info = (title: string, message?: string) => addToast('info', title, message);
const success = (title: string, message?: string) => addToast('success', title, message);
const error = (title: string, message?: string) => addToast('error', title, message);
const info = (title: string, message?: string) => addToast('info', title, message);
return (
<ToastContext.Provider value={{ toast: addToast, success, error, info }}>
{children}
<div className="fixed bottom-4 right-4 z-50 flex flex-col gap-2 max-w-md w-full pointer-events-none p-2">
{toasts.map((t) => (
<div
key={t.id}
className={`pointer-events-auto flex items-start gap-3 p-4 rounded-xl border shadow-2xl transition-all duration-200 bg-[#141414] ${t.type === 'success'
? 'border-green-500/30 text-gray-200'
: t.type === 'error'
? 'border-rose-500/30 text-gray-200'
: 'border-indigo-500/30 text-gray-200'
}`}
>
{t.type === 'success' && <CheckCircle2 className="w-5 h-5 text-green-400 shrink-0 mt-0.5" />}
{t.type === 'error' && <AlertCircle className="w-5 h-5 text-rose-400 shrink-0 mt-0.5" />}
{t.type === 'info' && <Info className="w-5 h-5 text-indigo-400 shrink-0 mt-0.5" />}
<div className="flex-1">
<h4 className="text-sm font-semibold text-white">{t.title}</h4>
{t.message && <p className="text-xs mt-0.5 text-gray-400 leading-relaxed">{t.message}</p>}
</div>
<button
onClick={() => removeToast(t.id)}
className="text-gray-400 hover:text-white p-0.5 rounded transition-colors"
>
<X className="w-4 h-4" />
</button>
</div>
))}
return (
<ToastContext.Provider value={{ toast: addToast, success, error, info }}>
{children}
<div className="fixed bottom-4 right-4 z-50 flex flex-col gap-2 max-w-md w-full pointer-events-none p-2">
{toasts.map((t) => (
<div
key={t.id}
className={`pointer-events-auto flex items-start gap-3 p-4 rounded-xl border shadow-2xl transition-all duration-200 bg-[#141414] ${
t.type === 'success'
? 'border-green-500/30 text-gray-200'
: t.type === 'error'
? 'border-rose-500/30 text-gray-200'
: 'border-indigo-500/30 text-gray-200'
}`}
>
{t.type === 'success' && <CheckCircle2 className="w-5 h-5 text-green-400 shrink-0 mt-0.5" />}
{t.type === 'error' && <AlertCircle className="w-5 h-5 text-rose-400 shrink-0 mt-0.5" />}
{t.type === 'info' && <Info className="w-5 h-5 text-indigo-400 shrink-0 mt-0.5" />}
<div className="flex-1">
<h4 className="text-sm font-semibold text-white">{t.title}</h4>
{t.message && <p className="text-xs mt-0.5 text-gray-400 leading-relaxed">{t.message}</p>}
</div>
</ToastContext.Provider>
);
<button
onClick={() => removeToast(t.id)}
className="text-gray-400 hover:text-white p-0.5 rounded transition-colors"
>
<X className="w-4 h-4" />
</button>
</div>
))}
</div>
</ToastContext.Provider>
);
};
export const useToast = () => {
const context = useContext(ToastContext);
if (!context) {
throw new Error('useToast must be used within a ToastProvider');
}
return context;
const context = useContext(ToastContext);
if (!context) {
throw new Error('useToast must be used within a ToastProvider');
}
return context;
};