From 8671b768d1ce475ac103b24bbe2c826ae482109a Mon Sep 17 00:00:00 2001 From: Damein Sedgwick Date: Sun, 17 Nov 2024 17:13:12 +0000 Subject: [PATCH] styled post card according to figma --- .../app/(app)/_components/post-card.tsx | 111 +++++++++++++++++- .../app/(app)/_components/vote-button.tsx | 7 +- 2 files changed, 111 insertions(+), 7 deletions(-) diff --git a/packages/frontpage/app/(app)/_components/post-card.tsx b/packages/frontpage/app/(app)/_components/post-card.tsx index c0720e5b..063e299b 100644 --- a/packages/frontpage/app/(app)/_components/post-card.tsx +++ b/packages/frontpage/app/(app)/_components/post-card.tsx @@ -5,7 +5,10 @@ import { ensureUser, getUser } from "@/lib/data/user"; import { TimeAgo } from "@/lib/components/time-ago"; import { VoteButton } from "./vote-button"; import { PostCollection, deletePost } from "@/lib/data/atproto/post"; -import { getVerifiedHandle } from "@/lib/data/atproto/identity"; +import { + getDidFromHandleOrDid, + getVerifiedHandle, +} from "@/lib/data/atproto/identity"; import { UserHoverCard } from "@/lib/components/user-hover-card"; import type { DID } from "@/lib/data/atproto/did"; import { parseReportForm } from "@/lib/data/db/report-shared"; @@ -15,6 +18,9 @@ import { revalidatePath } from "next/cache"; import { ReportDialogDropdownButton } from "./report-dialog"; import { DeleteButton } from "./delete-button"; import { ShareDropdownButton } from "./share-button"; +import { Separator } from "@/lib/components/ui/separator"; +import { ChatBubbleIcon } from "@radix-ui/react-icons"; +import { UserAvatar } from "@/lib/components/user-avatar"; type PostProps = { id: number; @@ -46,11 +52,108 @@ export async function PostCard({ getUser(), ]); const postHref = `/post/${handle}/${rkey}`; + const did = await getDidFromHandleOrDid(handle ?? ""); return ( // TODO: Make article route to postHref via onClick on card except innser links or buttons -
-
+
+
+

+ + {title}{" "} + + ({new URL(url).host}) + + +

+
+ +
+ + + {did ? : null} + + {handle} + + + + + +
+ + + +
+
+ { + "use server"; + await ensureUser(); + await createVote({ + subjectAuthorDid: author, + subjectCid: cid, + subjectRkey: rkey, + subjectCollection: PostCollection, + }); + }} + unvoteAction={async () => { + "use server"; + await ensureUser(); + const vote = await getVoteForPost(id); + if (!vote) { + // TODO: Show error notification + console.error("Vote not found for post", id); + return; + } + await deleteVote(vote.rkey); + }} + initialState={ + (await getUser())?.did === author + ? "authored" + : isUpvoted + ? "voted" + : "unvoted" + } + votes={votes} + /> + + + {commentCount} + +
+
+ {user ? ( +
+ + + + {user?.did === author ? ( + + ) : null} + +
+ ) : null} +
+
+ + {/*
{ "use server"; @@ -139,7 +242,7 @@ export async function PostCard({
) : null}
- + */}
); } diff --git a/packages/frontpage/app/(app)/_components/vote-button.tsx b/packages/frontpage/app/(app)/_components/vote-button.tsx index c0d79532..3f4c3ccc 100644 --- a/packages/frontpage/app/(app)/_components/vote-button.tsx +++ b/packages/frontpage/app/(app)/_components/vote-button.tsx @@ -73,6 +73,7 @@ export function VoteButton({ size="icon" disabled={initialState === "authored"} name={hasVoted ? "unvote" : "vote"} + className="h-6 flex items-center gap-1 group" > + {votes === undefined ? null : ( + {actualVotes} + )} - {votes === undefined ? null : ( - {actualVotes} - )} ); }