FrostByte/client-solid/src/Components/PostSegment.tsx

47 lines
1.7 KiB
TypeScript
Raw Normal View History

2024-03-24 21:40:57 +01:00
import { JSXElement, Show, splitProps } from "solid-js";
2024-03-23 00:10:42 +01:00
import { Post } from "../Util/api";
import CommentsButton from "./Buttons/CommentsButton";
import EngagementButton from "./Buttons/Engegament";
import RemovePostButton from "./Buttons/RemovePostButton";
import ReportButton from "./Buttons/Report";
import ToPostButton from "./Buttons/ToPost";
export function PostSegment(props: { post: Post }): JSXElement {
2024-03-24 21:40:57 +01:00
const [local] = splitProps(props, ["post"]);
const dateOfCreation = new Date(local.post.createdAt).toDateString();
const isEdited = !(local.post.createdAt == local.post.updatedAt);
return (
<div class="card compact w-full flex-grow border-b-2 border-b-primary bg-base-200 text-base-content transition-all hover:bg-base-300">
<div class="card-body md:mx-6">
<div class="flex flex-row justify-between">
<p class="text-xs italic">{dateOfCreation}</p>
<details class="dropdown">
<summary class="btn btn-sm">...</summary>
<ul class="w-26 menu dropdown-content z-[1] rounded-box bg-base-100 p-2 shadow">
<li>
<ReportButton />
</li>
<li>
2024-03-24 21:40:57 +01:00
<RemovePostButton postId={local.post.id} />
</li>
</ul>
</details>
</div>
<Show when={isEdited}>
<p>This post has been edited</p>
</Show>
2024-03-24 21:40:57 +01:00
<p class="my-1 text-base">{local.post.content}</p>
<div class="card-actions justify-between">
<div class="flex">
2024-03-24 21:40:57 +01:00
<EngagementButton postId={local.post.id} />
<CommentsButton postId={local.post.id} />
</div>
2024-03-24 21:40:57 +01:00
<ToPostButton post={local.post} />
</div>
</div>
</div>
);
}