-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Expand file tree
/
Copy pathChatHeader.tsx
More file actions
67 lines (59 loc) · 1.56 KB
/
Copy pathChatHeader.tsx
File metadata and controls
67 lines (59 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import { CircleDot, FileText, Hash, Home } from "lucide-react";
import type { ChannelType } from "@/shared/api/types";
import { SidebarTrigger } from "@/shared/ui/sidebar";
type ChatHeaderProps = {
title: string;
description: string;
channelType?: ChannelType;
mode?: "home" | "channel";
};
function ChannelIcon({
channelType,
mode = "channel",
}: {
channelType?: ChannelType;
mode?: "home" | "channel";
}) {
if (mode === "home") {
return <Home className="h-5 w-5 text-primary" />;
}
if (channelType === "dm") {
return <CircleDot className="h-5 w-5 text-primary" />;
}
if (channelType === "forum") {
return <FileText className="h-5 w-5 text-primary" />;
}
return <Hash className="h-5 w-5 text-primary" />;
}
export function ChatHeader({
title,
description,
channelType,
mode = "channel",
}: ChatHeaderProps) {
return (
<header
className="flex min-w-0 items-center gap-3 border-b border-border/80 bg-background px-4 py-3 sm:px-6"
data-testid="chat-header"
>
<SidebarTrigger />
<div className="min-w-0 flex-1">
<div className="flex min-w-0 items-center gap-2">
<ChannelIcon channelType={channelType} mode={mode} />
<h1
className="truncate text-lg font-semibold tracking-tight"
data-testid="chat-title"
>
{title}
</h1>
</div>
<p
className="truncate text-sm text-muted-foreground"
data-testid="chat-description"
>
{description}
</p>
</div>
</header>
);
}