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

ComposerContextLabel.tsx

35 lines925 Bytes

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