Components: - DashboardShell — main layout combining sidebar + topbar + content area - Sidebar — collapsible nav with sections, badges, active state, auto-settings link - TopBar — user avatar/menu, notifications bell, sign out, custom actions - ProfilePage — avatar, name/email form, loading/error/success states - BillingPage — current plan card, status badge, trial info, plan comparison grid - SettingsPage — section-based layout with empty state Features: - NavItem[] or NavSection[] for flat or grouped navigation - ShellFeatures toggle: profile, billing, settings, notifications, themeToggle - ShellUser with avatar, role, initials fallback - onNavigate callback for SPA routers (Next.js, etc.) - Collapsible sidebar with toggle button - All styled via --bl-shell-* CSS custom properties with fallbacks - 41 tests covering all components
74 lines
1.7 KiB
TypeScript
74 lines
1.7 KiB
TypeScript
import { useState, type ReactNode } from 'react';
|
|
import type { DashboardShellProps } from './types.js';
|
|
import { Sidebar } from './Sidebar.js';
|
|
import { TopBar } from './TopBar.js';
|
|
|
|
export function DashboardShell({
|
|
productName,
|
|
logo,
|
|
version,
|
|
nav,
|
|
pathname: externalPathname,
|
|
user,
|
|
features = {},
|
|
onSignOut,
|
|
onNavigate,
|
|
sidebarFooter,
|
|
topBarActions,
|
|
children,
|
|
}: DashboardShellProps): ReactNode {
|
|
const [sidebarCollapsed, setSidebarCollapsed] = useState(false);
|
|
|
|
// Use external pathname or default to '/'
|
|
const pathname = externalPathname ?? '/';
|
|
|
|
return (
|
|
<div
|
|
data-testid="bl-dashboard-shell"
|
|
style={{
|
|
display: 'flex',
|
|
minHeight: '100vh',
|
|
background: 'var(--bl-shell-bg, var(--color-background, #f9fafb))',
|
|
}}
|
|
>
|
|
{/* Sidebar */}
|
|
<Sidebar
|
|
productName={productName}
|
|
logo={logo}
|
|
version={version}
|
|
nav={nav}
|
|
pathname={pathname}
|
|
features={features}
|
|
onNavigate={onNavigate}
|
|
footer={sidebarFooter}
|
|
collapsed={sidebarCollapsed}
|
|
onToggleCollapse={() => setSidebarCollapsed(!sidebarCollapsed)}
|
|
/>
|
|
|
|
{/* Main content area */}
|
|
<div style={{ flex: 1, display: 'flex', flexDirection: 'column', overflow: 'hidden' }}>
|
|
{/* Top bar */}
|
|
<TopBar
|
|
user={user}
|
|
features={features}
|
|
onSignOut={onSignOut}
|
|
onNavigate={onNavigate}
|
|
actions={topBarActions}
|
|
/>
|
|
|
|
{/* Page content */}
|
|
<main
|
|
data-testid="bl-shell-main"
|
|
style={{
|
|
flex: 1,
|
|
padding: '24px 32px',
|
|
overflow: 'auto',
|
|
}}
|
|
>
|
|
{children}
|
|
</main>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|