MCPcopy Create free account
hub / github.com/dailydotdev/apps / ProfileHeader

Function ProfileHeader

packages/shared/src/components/profile/ProfileHeader.tsx:60–175  ·  view source on GitHub ↗
({
  user,
  userStats,
  isSameUser: propIsSameUser,
  isPreviewMode,
  actions,
}: ProfileHeaderProps)

Source from the content-addressed store, hash-verified

58};
59
60const ProfileHeader = ({
61 user,
62 userStats,
63 isSameUser: propIsSameUser,
64 isPreviewMode,
65 actions,
66}: ProfileHeaderProps) => {
67 const { name, username, bio, image, cover, isPlus } = user;
68 const { user: loggedUser } = useAuthContext();
69 const isSameUser = propIsSameUser ?? loggedUser?.id === user.id;
70
71 return (
72 <div className="relative w-full overflow-hidden laptop:rounded-t-16">
73 <ProfileDesktopPwaBackButton className="absolute left-4 top-4 z-1" />
74 <div className="h-36">
75 <Image src={cover} alt="Cover" className="h-full w-full object-cover" />
76 </div>
77 <Image
78 src={image}
79 fallbackSrc={fallbackImages.avatar}
80 alt="Avatar"
81 className="absolute left-6 top-16 h-[7.5rem] w-[7.5rem] rounded-16 object-cover"
82 />
83 <div className="flex flex-col gap-3 px-6">
84 {/* Edit leads and `actions` trails, because edit is only hidden, not
85 removed: it holds its width so the row keeps its height for a
86 visitor. Trailing, that reserved width sat between the actions and
87 the right edge and left them looking short of it; leading, it falls
88 on the inside and whatever trails stays flush either way. */}
89 <div className="mb-4 ml-auto mt-2 flex items-center gap-2">
90 <Link passHref href={`${webappUrl}settings/profile`}>
91 <Button
92 className={classNames(
93 'text-text-secondary',
94 !isSameUser && 'invisible',
95 )}
96 tag="a"
97 disabled={!isSameUser}
98 variant={ButtonVariant.Float}
99 icon={<EditIcon />}
100 aria-label="Edit profile"
101 />
102 </Link>
103 {actions}
104 </div>
105 <div className="flex items-center gap-1">
106 <Typography type={TypographyType.Title2} bold>
107 {name}
108 </Typography>
109 {isPlus && (
110 <DevPlusIcon
111 className="text-action-plus-default"
112 size={IconSize.Size16}
113 />
114 )}
115 </div>
116 <div className="flex flex-col gap-2">
117 {bio && <Typography type={TypographyType.Body}>{bio}</Typography>}

Callers

nothing calls this directly

Calls 2

useAuthContextFunction · 0.90
locationToStringFunction · 0.90

Tested by

no test coverage detected