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

Function ProfileHeader

packages/shared/src/components/profile/ProfileHeader.tsx:87–284  ·  view source on GitHub ↗
({
  user,
  userStats,
  isSameUser: propIsSameUser,
  isPreviewMode,
  coversBlock = false,
  avatarBadge,
  coverRef,
  nameRef,
}: ProfileHeaderProps)

Source from the content-addressed store, hash-verified

85};
86
87const ProfileHeader = ({
88 user,
89 userStats,
90 isSameUser: propIsSameUser,
91 isPreviewMode,
92 coversBlock = false,
93 avatarBadge,
94 coverRef,
95 nameRef,
96}: ProfileHeaderProps) => {
97 const { name, username, bio, image, cover, isPlus } = user;
98 const { user: loggedUser } = useAuthContext();
99 const isSameUser = propIsSameUser ?? loggedUser?.id === user.id;
100 const { logEvent } = useLogContext();
101 const [isCopying, copyLink] = useCopyLink();
102 const { getTrackedUrl } = useGetShortUrl();
103 const isPhone = useIsPhone();
104 const showsTopActions = isPhone && !isSameUser && !isPreviewMode;
105
106 const onCopyLink = () => {
107 logEvent({
108 event_name: LogEvent.ShareProfile,
109 target_type: TargetType.ProfilePage,
110 target_id: user.id,
111 extra: JSON.stringify({
112 provider: ShareProvider.CopyLink,
113 origin: Origin.ProfileHeader,
114 }),
115 });
116 copyLink({
117 link: getTrackedUrl(user.permalink, ReferralCampaignKey.ShareProfile),
118 shorten: true,
119 });
120 };
121
122 const avatarTopClassName = coversBlock
123 ? 'top-[calc(8.5rem+var(--safe-area-top,0px))] tablet:top-16'
124 : 'top-28 tablet:top-16';
125
126 return (
127 <div
128 className={classNames(
129 'relative -mt-[var(--cover-lift)] w-full overflow-hidden [--cover-lift:0px] laptop:rounded-t-16',
130 coversBlock &&
131 '[--cover-lift:calc(var(--shell-top,var(--shell-top-rest,0px))+var(--safe-area-top,0px))] tablet:[--cover-lift:0px]',
132 )}
133 >
134 <ProfileDesktopPwaBackButton className="absolute left-4 top-4 z-1" />
135 <div
136 ref={coverRef}
137 className={classNames(
138 'shell-cover relative overflow-hidden',
139 coversBlock
140 ? 'h-[calc(10.5rem+var(--safe-area-top,0px))] tablet:h-36'
141 : 'h-36',
142 )}
143 >
144 <Image src={cover} alt="Cover" className="h-full w-full object-cover" />

Callers

nothing calls this directly

Calls 6

useAuthContextFunction · 0.90
useLogContextFunction · 0.90
useCopyLinkFunction · 0.90
useGetShortUrlFunction · 0.90
useIsPhoneFunction · 0.90
locationToStringFunction · 0.90

Tested by

no test coverage detected