tangled
alpha
login
or
join now
leaflet.pub
/
leaflet
289
fork
atom
a tool for shared writing and social publishing
289
fork
atom
overview
issues
28
pulls
pipelines
small updates to the profile popover styling
cozylittle.house
3 months ago
cb464682
a6f5e830
+77
-26
2 changed files
expand all
collapse all
unified
split
app
(home-pages)
p
[didOrHandle]
ProfileHeader.tsx
components
ProfilePopover.tsx
+61
-20
app/(home-pages)/p/[didOrHandle]/ProfileHeader.tsx
···
15
export const ProfileHeader = (props: {
16
profile: ProfileViewDetailed;
17
publications: { record: Json; uri: string }[];
0
18
}) => {
19
let profileRecord = props.profile;
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
20
21
return (
22
-
<div className="flex flex-col relative" id="profile-header">
23
-
<Avatar
24
-
src={profileRecord.avatar}
25
-
displayName={profileRecord.displayName}
26
-
className="mx-auto mt-3 sm:mt-4"
27
-
giant
28
-
/>
29
<ProfileLinks handle={props.profile.handle || ""} />
30
<div className="flex flex-col">
31
-
<h3 className=" px-3 sm:px-4 pt-2 leading-tight">
32
-
{profileRecord.displayName
33
-
? profileRecord.displayName
34
-
: `@${props.profile.handle}`}
35
-
</h3>
36
-
{profileRecord.displayName && (
37
-
<div className="text-tertiary text-sm pb-1 italic px-3 sm:px-4 truncate">
38
-
@{props.profile.handle}
39
-
</div>
40
-
)}
41
-
<pre className="text-secondary px-3 sm:px-4 ">
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
42
{profileRecord.description
43
? parseDescription(profileRecord.description)
44
: null}
45
</pre>
46
<div className=" w-full overflow-x-scroll mt-3 mb-6 ">
47
-
<div className="grid grid-flow-col auto-cols-[164px] sm:auto-cols-[240px] gap-2 mx-auto w-fit px-3 sm:px-4 ">
48
-
{/*<div className="spacer "/>*/}
0
49
{props.publications.map((p) => (
50
<PublicationCard
51
key={p.uri}
···
15
export const ProfileHeader = (props: {
16
profile: ProfileViewDetailed;
17
publications: { record: Json; uri: string }[];
18
+
popover?: boolean;
19
}) => {
20
let profileRecord = props.profile;
21
+
const profileUrl = `/p/${props.profile.handle}`;
22
+
23
+
const avatarElement = (
24
+
<Avatar
25
+
src={profileRecord.avatar}
26
+
displayName={profileRecord.displayName}
27
+
className="mx-auto mt-3 sm:mt-4"
28
+
giant
29
+
/>
30
+
);
31
+
32
+
const displayNameElement = (
33
+
<h3 className=" px-3 sm:px-4 pt-2 leading-tight">
34
+
{profileRecord.displayName
35
+
? profileRecord.displayName
36
+
: `@${props.profile.handle}`}
37
+
</h3>
38
+
);
39
+
40
+
const handleElement = profileRecord.displayName && (
41
+
<div
42
+
className={`text-tertiary ${props.popover ? "text-xs" : "text-sm"} pb-1 italic px-3 sm:px-4 truncate`}
43
+
>
44
+
@{props.profile.handle}
45
+
</div>
46
+
);
47
48
return (
49
+
<div
50
+
className={`flex flex-col relative ${props.popover && "text-sm"}`}
51
+
id="profile-header"
52
+
>
0
0
0
53
<ProfileLinks handle={props.profile.handle || ""} />
54
<div className="flex flex-col">
55
+
<div className="flex flex-col group">
56
+
{props.popover ? (
57
+
<SpeedyLink className={"hover:no-underline!"} href={profileUrl}>
58
+
{avatarElement}
59
+
</SpeedyLink>
60
+
) : (
61
+
avatarElement
62
+
)}
63
+
{props.popover ? (
64
+
<SpeedyLink
65
+
className={" text-primary group-hover:underline"}
66
+
href={profileUrl}
67
+
>
68
+
{displayNameElement}
69
+
</SpeedyLink>
70
+
) : (
71
+
displayNameElement
72
+
)}
73
+
{props.popover && handleElement ? (
74
+
<SpeedyLink className={"group-hover:underline"} href={profileUrl}>
75
+
{handleElement}
76
+
</SpeedyLink>
77
+
) : (
78
+
handleElement
79
+
)}
80
+
</div>
81
+
<pre className="text-secondary px-3 sm:px-4 whitespace-pre-wrap">
82
{profileRecord.description
83
? parseDescription(profileRecord.description)
84
: null}
85
</pre>
86
<div className=" w-full overflow-x-scroll mt-3 mb-6 ">
87
+
<div
88
+
className={`grid grid-flow-col gap-2 mx-auto w-fit px-3 sm:px-4 ${props.popover ? "auto-cols-[164px]" : "auto-cols-[164px] sm:auto-cols-[240px]"}`}
89
+
>
90
{props.publications.map((p) => (
91
<PublicationCard
92
key={p.uri}
+16
-6
components/ProfilePopover.tsx
···
4
import { callRPC } from "app/api/rpc/client";
5
import { useState } from "react";
6
import { ProfileHeader } from "app/(home-pages)/p/[didOrHandle]/ProfileHeader";
0
0
7
8
export const ProfilePopover = (props: {
9
trigger: React.ReactNode;
···
22
);
23
24
return (
25
-
<Popover
26
className="max-w-sm p-0! text-center"
27
trigger={props.trigger}
28
onOpenChange={setIsOpen}
···
30
{isLoading ? (
31
<div className="text-secondary p-4">Loading...</div>
32
) : data ? (
33
-
<ProfileHeader
34
-
profile={data.profile}
35
-
publications={data.publications}
36
-
/>
0
0
0
0
0
0
0
0
37
) : (
38
<div className="text-secondary p-4">Profile not found</div>
39
)}
40
-
</Popover>
41
);
42
};
···
4
import { callRPC } from "app/api/rpc/client";
5
import { useState } from "react";
6
import { ProfileHeader } from "app/(home-pages)/p/[didOrHandle]/ProfileHeader";
7
+
import { SpeedyLink } from "./SpeedyLink";
8
+
import { Tooltip } from "./Tooltip";
9
10
export const ProfilePopover = (props: {
11
trigger: React.ReactNode;
···
24
);
25
26
return (
27
+
<Tooltip
28
className="max-w-sm p-0! text-center"
29
trigger={props.trigger}
30
onOpenChange={setIsOpen}
···
32
{isLoading ? (
33
<div className="text-secondary p-4">Loading...</div>
34
) : data ? (
35
+
<div>
36
+
<ProfileHeader
37
+
profile={data.profile}
38
+
publications={data.publications}
39
+
popover
40
+
/>
41
+
<hr className="border-border" />
42
+
<div className="py-2 text-sm text-tertiary">
43
+
Followed by{" "}
44
+
<button className="hover:underline">celine and 4 others</button>
45
+
</div>
46
+
</div>
47
) : (
48
<div className="text-secondary p-4">Profile not found</div>
49
)}
50
+
</Tooltip>
51
);
52
};