2026-07-05 17:39:18 +02:00
|
|
|
import { useState } from 'react'
|
|
|
|
|
|
2026-07-27 18:05:15 +02:00
|
|
|
/**
|
|
|
|
|
* Generischer Drill-down-Container — AP1.9d Anti-Todo-Wand.
|
|
|
|
|
* Bewusst layout-neutral für späteres UI-Redesign.
|
|
|
|
|
*/
|
2026-07-05 17:39:18 +02:00
|
|
|
export function CollapsibleSection({
|
|
|
|
|
title,
|
2026-07-27 18:05:15 +02:00
|
|
|
lead,
|
|
|
|
|
defaultCollapsed = true,
|
|
|
|
|
expandLabel = 'Alle anzeigen',
|
|
|
|
|
collapseLabel = 'Einklappen',
|
|
|
|
|
headerActions = null,
|
|
|
|
|
className = 'card',
|
2026-07-05 17:39:18 +02:00
|
|
|
children,
|
|
|
|
|
}) {
|
2026-07-27 18:05:15 +02:00
|
|
|
const [expanded, setExpanded] = useState(!defaultCollapsed)
|
2026-07-05 17:39:18 +02:00
|
|
|
|
|
|
|
|
return (
|
2026-07-27 18:05:15 +02:00
|
|
|
<section className={className}>
|
|
|
|
|
<div className="section-header">
|
|
|
|
|
<div>
|
|
|
|
|
{title && <h2>{title}</h2>}
|
|
|
|
|
{lead && <p className="section-lead muted">{lead}</p>}
|
|
|
|
|
</div>
|
|
|
|
|
{headerActions}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{expanded ? (
|
|
|
|
|
<>
|
|
|
|
|
{children}
|
|
|
|
|
<p className="collapsible-section__toggle">
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
className="btn btn-ghost btn-sm"
|
|
|
|
|
onClick={() => setExpanded(false)}
|
|
|
|
|
>
|
|
|
|
|
{collapseLabel}
|
|
|
|
|
</button>
|
|
|
|
|
</p>
|
|
|
|
|
</>
|
|
|
|
|
) : (
|
|
|
|
|
<p className="collapsible-section__toggle">
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
className="btn btn-secondary btn-sm"
|
|
|
|
|
onClick={() => setExpanded(true)}
|
|
|
|
|
>
|
|
|
|
|
{expandLabel}
|
|
|
|
|
</button>
|
|
|
|
|
</p>
|
|
|
|
|
)}
|
2026-07-05 17:39:18 +02:00
|
|
|
</section>
|
|
|
|
|
)
|
|
|
|
|
}
|