Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 | 3x 13x 13x 13x 13x 20x | import { Hash, Lock, Menu, Search } from 'lucide-react'
import type { ReactElement } from 'react'
import { Avatar, AvatarFallback, AvatarGroup } from '@/components/Avatar'
import { Button } from '@/components/Button'
import { IconButton } from '@/components/IconButton'
import { useShellDrawer } from '@/features/shell'
import { toneClass } from '@/helpers/tone'
import { initials } from '@chattra/utils/string'
import type { ConversationSummary, Person } from '../../types'
interface ConversationHeaderProps {
conversation: ConversationSummary
/** The first few members, shown as stacked avatars in the member button. */
members: Person[]
}
export const ConversationHeader = ({
conversation,
members,
}: ConversationHeaderProps): ReactElement => {
const drawer = useShellDrawer()
const Icon = conversation.kind === 'private' ? Lock : Hash
const isChannel = conversation.kind === 'channel' || conversation.kind === 'private'
return (
<header className="flex min-h-14.5 items-center gap-2.5 border-b px-4 py-2.5">
<Button
variant="ghost"
size="icon"
aria-label="Open menu"
onClick={drawer.open}
className="-ml-2 md:hidden"
>
<Menu />
</Button>
<div className="min-w-0 flex-1">
<h1 className="flex items-center gap-1.5 text-lg font-bold">
{isChannel ? <Icon aria-hidden="true" className="size-4 text-muted-foreground" /> : null}
<span className="truncate">{conversation.name}</span>
</h1>
{conversation.topic ? (
<p className="truncate text-sm text-muted-foreground">{conversation.topic}</p>
) : null}
</div>
{/* shortcut: search and members open nothing yet; members are M2, search M4. */}
<IconButton label="Search" size="icon">
<Search />
</IconButton>
<Button variant="outline" size="sm" className="h-8 shrink-0 gap-2 rounded-xl px-2 text-sm">
<AvatarGroup aria-hidden="true" className="-space-x-1.5">
{members.map((member) => (
<Avatar key={member.id} size="sm">
<AvatarFallback className={toneClass(member.name)}>
{initials(member.name)}
</AvatarFallback>
</Avatar>
))}
</AvatarGroup>
{/* Named by the visible count, not an aria-label, so the name keeps what is shown (WCAG 2.5.3). */}
{conversation.memberCount}{' '}
<span className="sr-only">{conversation.memberCount === 1 ? 'member' : 'members'}</span>
</Button>
</header>
)
}
|