feat(01-02): portal layout with header, sidebar, theme toggle, locale switcher

- Zustand sidebar store with persist middleware (collapse/expand, mobile open)
- Sticky header with logo, breadcrumb, theme toggle, locale switcher, user avatar
- Collapsible sidebar with Dashboard/Marketplace nav, accordion categories, footer
- Mobile responsive: hamburger menu with overlay sidebar on small screens
- Theme toggle cycling light/dark/system with mounted guard
- Locale switcher setting NEXT_LOCALE cookie with router.refresh
- Empty dashboard state with grid icon, "Keine Widgets aktiv" text, add button
- AppShell composing header + sidebar + responsive main content area
- All user-visible strings via useTranslations (UI-03 compliance)
This commit is contained in:
2026-06-18 10:27:46 +02:00
parent f3791c6cdd
commit 6039387857
12 changed files with 577 additions and 9 deletions
+193
View File
@@ -0,0 +1,193 @@
'use client';
import { useState } from 'react';
import { useTranslations } from 'next-intl';
import { useSidebarStore } from '@/lib/stores/sidebar-store';
import { SidebarFooter } from '@/components/layout/sidebar-footer';
export function Sidebar() {
const t = useTranslations('sidebar');
const tCommon = useTranslations('common');
const { isCollapsed, isMobileOpen, toggle, setMobileOpen } = useSidebarStore();
const [categoriesOpen, setCategoriesOpen] = useState(false);
const sidebarContent = (
<div className="flex h-full flex-col bg-sidebar">
{/* Navigation items */}
<nav className="flex-1 overflow-y-auto p-3">
<ul className="flex flex-col gap-1">
{/* Dashboard - active by default (D-15) */}
<li>
<a
href="/"
className="flex items-center gap-3 rounded-md px-2 py-2 text-sm font-medium bg-sidebar-accent text-sidebar-accent-foreground transition-colors"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="18"
height="18"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
className="shrink-0"
>
<rect x="3" y="3" width="7" height="7" />
<rect x="14" y="3" width="7" height="7" />
<rect x="14" y="14" width="7" height="7" />
<rect x="3" y="14" width="7" height="7" />
</svg>
{!isCollapsed && <span className="truncate">{t('dashboard')}</span>}
</a>
</li>
{/* Marketplace */}
<li>
<a
href="/marketplace"
className="flex items-center gap-3 rounded-md px-2 py-2 text-sm text-sidebar-foreground hover:bg-muted transition-colors"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="18"
height="18"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
className="shrink-0"
>
<circle cx="9" cy="21" r="1" />
<circle cx="20" cy="21" r="1" />
<path d="M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6" />
</svg>
{!isCollapsed && <span className="truncate">{t('marketplace')}</span>}
</a>
</li>
</ul>
{/* Categories accordion (D-05) */}
{!isCollapsed && (
<div className="mt-6">
<button
onClick={() => setCategoriesOpen(!categoriesOpen)}
className="flex w-full items-center justify-between rounded-md px-2 py-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground hover:text-foreground transition-colors"
>
<span>{t('categories.label')}</span>
<svg
xmlns="http://www.w3.org/2000/svg"
width="14"
height="14"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
className={`transition-transform duration-200 ${categoriesOpen ? 'rotate-180' : ''}`}
>
<polyline points="6 9 12 15 18 9" />
</svg>
</button>
{categoriesOpen && (
<div className="mt-1 px-2 py-2 text-sm text-muted-foreground">
{t('categories.empty')}
</div>
)}
</div>
)}
</nav>
{/* Collapse/Expand toggle */}
<div className="hidden md:block border-t border-sidebar-border p-2">
<button
onClick={toggle}
className="flex w-full items-center gap-3 rounded-md px-2 py-1.5 text-sm text-sidebar-foreground hover:bg-muted transition-colors"
aria-label={isCollapsed ? t('expand') : t('collapse')}
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="18"
height="18"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
className={`shrink-0 transition-transform duration-200 ${isCollapsed ? 'rotate-180' : ''}`}
>
<polyline points="15 18 9 12 15 6" />
</svg>
{!isCollapsed && (
<span className="truncate">{t('collapse')}</span>
)}
</button>
</div>
{/* Sidebar footer (D-06) */}
<SidebarFooter />
</div>
);
return (
<>
{/* Desktop sidebar */}
<aside
className="fixed left-0 top-[var(--header-height)] z-30 hidden h-[calc(100vh-var(--header-height))] border-r border-sidebar-border transition-all duration-200 md:block"
style={{
width: isCollapsed
? 'var(--sidebar-width-collapsed)'
: 'var(--sidebar-width)',
}}
>
{sidebarContent}
</aside>
{/* Mobile sidebar overlay (D-03) */}
{isMobileOpen && (
<div className="fixed inset-0 z-40 md:hidden">
{/* Backdrop */}
<div
className="fixed inset-0 bg-black/50"
onClick={() => setMobileOpen(false)}
aria-hidden="true"
/>
{/* Sidebar panel */}
<aside className="fixed left-0 top-0 z-50 h-full w-[var(--sidebar-width)] bg-sidebar shadow-lg">
{/* Mobile close button */}
<div className="flex h-[var(--header-height)] items-center justify-between border-b border-sidebar-border px-4">
<span className="text-lg font-bold text-primary">
{tCommon('appName')}
</span>
<button
onClick={() => setMobileOpen(false)}
className="rounded-md p-2 text-muted-foreground hover:bg-muted hover:text-foreground transition-colors"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="20"
height="20"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
>
<line x1="18" y1="6" x2="6" y2="18" />
<line x1="6" y1="6" x2="18" y2="18" />
</svg>
</button>
</div>
{sidebarContent}
</aside>
</div>
)}
</>
);
}