-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Broke Post out and added granular arguments. (#6)
* Broke Post out and added granular arguments. * Removed unused arguments * Fixed eslint issues
- Loading branch information
Showing
4 changed files
with
200 additions
and
47 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import React from 'react'; | ||
import Link from 'next/link'; | ||
|
||
import { getCommunitySlugFromUrl } from '@/utils/communities'; | ||
import { | ||
Post, Community, PostAggregates | ||
} from 'sublinks-js-client'; | ||
import { | ||
BodyText, BodyTitle, PaleBodyText | ||
} from '../text'; | ||
import PostVotes from '../post-votes'; | ||
import PostThumbnail from '../post-thumbnail'; | ||
|
||
interface PostCardProps { | ||
post: Post; | ||
community: Community; | ||
counts: PostAggregates | ||
} | ||
|
||
export const PostCard = ({ | ||
post, | ||
community, | ||
counts | ||
}: PostCardProps) => { | ||
const { | ||
id, body, name: title, thumbnail_url: thumbnailUrl | ||
} = post; | ||
const { actor_id: communityUrl } = community; | ||
const { score } = counts; | ||
const communitySlug = getCommunitySlugFromUrl(communityUrl); | ||
const postUrl = `/p/${communitySlug}/${id}`; | ||
|
||
return ( | ||
<div key={id}> | ||
<div className="flex"> | ||
<div className="flex items-center ml-8"> | ||
<PostVotes points={score} /> | ||
</div> | ||
<Link href={postUrl} className="w-full group"> | ||
<div className="flex h-100 relative"> | ||
<div className="h-full flex gap-12 px-12 py-6 items-start"> | ||
<div className="h-80 w-80 mt-8 flex flex-shrink-0 relative"> | ||
<PostThumbnail postThumbnailUrl={thumbnailUrl} /> | ||
</div> | ||
<div className="h-full w-full flex"> | ||
<div className="h-full flex flex-col"> | ||
<BodyTitle | ||
className="text-sm font-semibold line-clamp-2 group-hover:text-brand dark:group-hover:text-brand-dark group-visited:text-gray-500 group-visited:dark:text-gray-400" | ||
> | ||
{title} | ||
|
||
</BodyTitle> | ||
<div className="mb-8 flex max-md:flex-col"> | ||
<PaleBodyText className="text-xs"> | ||
{`Posted to ${communitySlug}`} | ||
</PaleBodyText> | ||
</div> | ||
{body && <BodyText className="text-xs max-md:hidden line-clamp-2 group-visited:text-gray-500 group-visited:dark:text-gray-400">{body}</BodyText>} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</Link> | ||
</div> | ||
<div className="border-b-2 border-secondary dark:border-secondary-dark" /> | ||
</div> | ||
); | ||
}; |