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
27
pulls
pipelines
add publications
awarm.space
3 months ago
1bb5c4b7
16b6fa89
+52
-5
2 changed files
expand all
collapse all
unified
split
app
p
[didOrHandle]
ProfilePageLayout.tsx
page.tsx
+47
-4
app/p/[didOrHandle]/ProfilePageLayout.tsx
···
6
6
import { Json } from "supabase/database.types";
7
7
import { ProfileViewDetailed } from "@atproto/api/dist/client/types/app/bsky/actor/defs";
8
8
import { Avatar } from "components/Avatar";
9
9
-
import { AppBskyActorProfile } from "lexicons/api";
9
9
+
import { AppBskyActorProfile, PubLeafletPublication } from "lexicons/api";
10
10
import { blobRefToSrc } from "src/utils/blobRefToSrc";
11
11
+
import { PubIcon } from "components/ActionBar/Publications";
12
12
+
import { usePubTheme } from "components/ThemeManager/PublicationThemeProvider";
13
13
+
import { colorToString } from "components/ThemeManager/useColorAttribute";
11
14
12
15
export const ProfilePageLayout = (props: {
16
16
+
publications: { record: Json; uri: string }[];
13
17
profile: {
14
18
did: string;
15
19
handle: string | null;
···
29
33
defaultTab="home"
30
34
tabs={{
31
35
home: {
32
32
-
content: <ProfilePageContent profile={props.profile} />,
36
36
+
content: (
37
37
+
<ProfilePageContent
38
38
+
profile={props.profile}
39
39
+
publications={props.publications}
40
40
+
/>
41
41
+
),
33
42
controls: null,
34
43
},
35
44
}}
···
41
50
42
51
export type profileTabsType = "posts" | "comments" | "subscriptions";
43
52
const ProfilePageContent = (props: {
53
53
+
publications: { record: Json; uri: string }[];
44
54
profile: {
45
55
did: string;
46
56
handle: string | null;
···
83
93
)}
84
94
<div className="text-secondary">{profileRecord.description}</div>
85
95
<div className="flex flex-row gap-2 mx-auto my-3">
86
86
-
<div>pub 1</div>
87
87
-
<div>pub 2</div>
96
96
+
{props.publications.map((p) => (
97
97
+
<PublicationCard
98
98
+
key={p.uri}
99
99
+
record={p.record as PubLeafletPublication.Record}
100
100
+
uri={p.uri}
101
101
+
/>
102
102
+
))}
88
103
</div>
89
104
<ProfileTabs tab={tab} setTab={setTab} />
90
105
<TabContent tab={tab} />
···
95
110
const PubListingCompact = () => {
96
111
return <div></div>;
97
112
};
113
113
+
114
114
+
const PublicationCard = (props: {
115
115
+
record: PubLeafletPublication.Record;
116
116
+
uri: string;
117
117
+
}) => {
118
118
+
const { record, uri } = props;
119
119
+
const { bgLeaflet, bgPage } = usePubTheme(record.theme);
120
120
+
121
121
+
return (
122
122
+
<a
123
123
+
href={`https://${record.base_path}`}
124
124
+
className="border border-border p-2 rounded-lg hover:no-underline!"
125
125
+
style={{ backgroundColor: `rgb(${colorToString(bgLeaflet, "rgb")})` }}
126
126
+
>
127
127
+
<div
128
128
+
className="rounded-md p-2 flex flex-row gap-2"
129
129
+
style={{
130
130
+
backgroundColor: record.theme?.showPageBackground
131
131
+
? `rgb(${colorToString(bgPage, "rgb")})`
132
132
+
: undefined,
133
133
+
}}
134
134
+
>
135
135
+
<PubIcon record={record} uri={uri} />
136
136
+
<h4>{record.name}</h4>
137
137
+
</div>
138
138
+
</a>
139
139
+
);
140
140
+
};
+5
-1
app/p/[didOrHandle]/page.tsx
···
31
31
.select(`*`)
32
32
.eq("did", did)
33
33
.single();
34
34
+
let { data: pubs } = await supabaseServerClient
35
35
+
.from("publications")
36
36
+
.select("*")
37
37
+
.eq("identity_did", did);
34
38
35
35
-
return <ProfilePageLayout profile={profile} />;
39
39
+
return <ProfilePageLayout profile={profile} publications={pubs || []} />;
36
40
}