|
| 1 | +import { FollowButton } from '@/features/follow-user/ui/FollowButton' |
| 2 | +import { cn } from '@/shared/lib/utils' |
| 3 | +import { PROFILE_CONTAINER_CLASSNAME } from './constants' |
| 4 | +import { ProfileAvatar } from './ProfileAvatar' |
| 5 | +import { ProfileStat } from './ProfileStat' |
| 6 | + |
| 7 | +interface ProfileHeaderProps { |
| 8 | + className?: string |
| 9 | + avatarUrl?: string | null |
| 10 | + nickname: string |
| 11 | + bio?: string | null |
| 12 | + postsCount: number |
| 13 | + followersCount: number |
| 14 | + followingCount: number |
| 15 | + defaultIsFollowing?: boolean |
| 16 | + onFollowToggle?: (nextIsFollowing: boolean) => Promise<void> | void |
| 17 | +} |
| 18 | + |
| 19 | +export function ProfileHeader({ |
| 20 | + className, |
| 21 | + avatarUrl, |
| 22 | + nickname, |
| 23 | + bio, |
| 24 | + postsCount, |
| 25 | + followersCount, |
| 26 | + followingCount, |
| 27 | + defaultIsFollowing = false, |
| 28 | + onFollowToggle, |
| 29 | +}: ProfileHeaderProps) { |
| 30 | + return ( |
| 31 | + <section className={cn(PROFILE_CONTAINER_CLASSNAME, className)}> |
| 32 | + <div className="flex gap-8 md:gap-16"> |
| 33 | + <div className="flex w-[180px] justify-center"> |
| 34 | + <ProfileAvatar avatarUrl={avatarUrl} nickname={nickname} /> |
| 35 | + </div> |
| 36 | + |
| 37 | + <div className="min-w-0 flex-1"> |
| 38 | + <div className="flex flex-wrap items-center gap-4"> |
| 39 | + <h1 className="text-xl font-normal text-gray-900">{nickname}</h1> |
| 40 | + <FollowButton |
| 41 | + defaultIsFollowing={defaultIsFollowing} |
| 42 | + onToggle={onFollowToggle} |
| 43 | + /> |
| 44 | + </div> |
| 45 | + |
| 46 | + <div className="mt-6 flex gap-10 text-base"> |
| 47 | + <ProfileStat label="게시물" value={postsCount} /> |
| 48 | + <ProfileStat label="팔로워" value={followersCount} /> |
| 49 | + <ProfileStat label="팔로잉" value={followingCount} /> |
| 50 | + </div> |
| 51 | + |
| 52 | + {bio ? ( |
| 53 | + <p className="mt-5 text-sm leading-relaxed whitespace-pre-line text-gray-900"> |
| 54 | + {bio} |
| 55 | + </p> |
| 56 | + ) : null} |
| 57 | + </div> |
| 58 | + </div> |
| 59 | + </section> |
| 60 | + ) |
| 61 | +} |
0 commit comments