| 1 | import { PanelLeftOpen } from "lucide-react"; |
| 2 | import { useTranslation } from "react-i18next"; |
| 3 | |
| 4 | import { PeSelector } from "@/components/PeSelector"; |
| 5 | import { Button } from "@/components/ui/button"; |
| 6 | import { cn } from "@/lib/utils"; |
| 7 | |
| 8 | interface ThreadHeaderProps { |
| 9 | title: string; |
| 10 | onToggleSidebar: () => void; |
| 11 | onGoHome: () => void; |
| 12 | hideSidebarToggleOnDesktop?: boolean; |
| 13 | chatId?: string; |
| 14 | } |
| 15 | |
| 16 | export function ThreadHeader({ |
| 17 | title, |
| 18 | onToggleSidebar, |
| 19 | onGoHome, |
| 20 | hideSidebarToggleOnDesktop = false, |
| 21 | chatId, |
| 22 | }: ThreadHeaderProps) { |
| 23 | const { t } = useTranslation(); |
| 24 | return ( |
| 25 | <div className="relative z-10 flex items-center justify-between gap-3 px-3 py-2"> |
| 26 | <div className="relative flex min-w-0 items-center gap-2"> |
| 27 | <Button |
| 28 | variant="ghost" |
| 29 | size="icon" |
| 30 | aria-label={t("thread.header.toggleSidebar")} |
| 31 | onClick={onToggleSidebar} |
| 32 | className={cn( |
| 33 | "h-7 w-7 rounded-md text-muted-foreground hover:bg-accent/35 hover:text-foreground", |
| 34 | hideSidebarToggleOnDesktop && "lg:pointer-events-none lg:opacity-0", |
| 35 | )} |
| 36 | > |
| 37 | <PanelLeftOpen className="h-3.5 w-3.5" /> |
| 38 | </Button> |
| 39 | <button |
| 40 | type="button" |
| 41 | onClick={onGoHome} |
| 42 | className="flex min-w-0 items-center gap-2 rounded-md px-1.5 py-1 text-[12px] font-medium text-muted-foreground transition-colors hover:bg-accent/35 hover:text-foreground" |
| 43 | > |
| 44 | <span className="max-w-[min(60vw,32rem)] truncate">{title}</span> |
| 45 | </button> |
| 46 | </div> |
| 47 | |
| 48 | <PeSelector chatId={chatId} /> |
| 49 | |
| 50 | <div aria-hidden className="pointer-events-none absolute inset-x-0 top-full h-4" /> |
| 51 | </div> |
| 52 | ); |
| 53 | } |
| 54 |