| 1 | import type { ComponentProps, ReactNode } from "react"; |
| 2 | |
| 3 | import { cn } from "../../lib/utils"; |
| 4 | |
| 5 | /** Sections share header and content insets in both the sidebar and popover. */ |
| 6 | export function ThreadDetailsSection({ |
| 7 | headingId, |
| 8 | title, |
| 9 | actions, |
| 10 | separated = true, |
| 11 | showHeading = true, |
| 12 | children, |
| 13 | ...props |
| 14 | }: Omit<ComponentProps<"section">, "className" | "style" | "title" | "aria-labelledby"> & { |
| 15 | headingId: string; |
| 16 | title: string; |
| 17 | actions?: ReactNode; |
| 18 | separated?: boolean; |
| 19 | showHeading?: boolean; |
| 20 | }) { |
| 21 | return ( |
| 22 | <section |
| 23 | {...props} |
| 24 | aria-labelledby={showHeading ? headingId : undefined} |
| 25 | aria-label={showHeading ? undefined : title} |
| 26 | className={cn("px-2 pt-2 pb-2.5", separated && "border-t border-border/65")} |
| 27 | > |
| 28 | <div |
| 29 | className={cn( |
| 30 | "mb-1 flex min-h-8 min-w-0 items-center justify-between gap-2 px-1.5", |
| 31 | !showHeading && "hidden", |
| 32 | )} |
| 33 | > |
| 34 | <h3 |
| 35 | id={headingId} |
| 36 | className="min-w-0 truncate text-2xs font-medium text-muted-foreground select-none" |
| 37 | > |
| 38 | {title} |
| 39 | </h3> |
| 40 | {actions ? <div className="flex shrink-0 items-center gap-1">{actions}</div> : null} |
| 41 | </div> |
| 42 | {children} |
| 43 | </section> |
| 44 | ); |
| 45 | } |