Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

ThreadDetailsSection.tsx

44 lines1.1 KB

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