| 1 | import type { ReactNode } from "react"; |
| 2 | |
| 3 | import { cn } from "../lib/utils"; |
| 4 | import { THREAD_DETAILS_PANEL_LABEL_CLASS } from "./chat/threadDetailsPanelStyles"; |
| 5 | |
| 6 | /** Keeps text measurable while the composer's outer label box collapses. */ |
| 7 | export function ComposerContextLabel({ |
| 8 | children, |
| 9 | displayMode = "toolbar", |
| 10 | }: { |
| 11 | children: ReactNode; |
| 12 | displayMode?: "toolbar" | "panel"; |
| 13 | }) { |
| 14 | return ( |
| 15 | <span |
| 16 | data-composer-label |
| 17 | className={cn( |
| 18 | "min-w-0", |
| 19 | displayMode === "panel" |
| 20 | ? "flex-1 overflow-x-clip overflow-y-visible text-left" |
| 21 | : "max-w-[240px] group-data-[compact]/composer-context:max-w-0", |
| 22 | )} |
| 23 | > |
| 24 | <span |
| 25 | data-composer-label-motion |
| 26 | className={cn( |
| 27 | "block w-full min-w-0 truncate", |
| 28 | displayMode === "panel" && THREAD_DETAILS_PANEL_LABEL_CLASS, |
| 29 | displayMode === "toolbar" && |
| 30 | "max-w-[240px] transition-opacity duration-180 ease-drawer group-data-[compact]/composer-context:opacity-0 motion-reduce:transition-none", |
| 31 | )} |
| 32 | > |
| 33 | {children} |
| 34 | </span> |
| 35 | </span> |
| 36 | ); |
| 37 | } |