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