Making linterbro happy
This commit is contained in:
parent
a51d397ded
commit
e3162a6973
1 changed files with 18 additions and 5 deletions
|
@ -1,4 +1,10 @@
|
||||||
import { JSXElement, Show, splitProps } from "solid-js";
|
import {
|
||||||
|
JSXElement,
|
||||||
|
Show,
|
||||||
|
createEffect,
|
||||||
|
createSignal,
|
||||||
|
splitProps,
|
||||||
|
} from "solid-js";
|
||||||
|
|
||||||
import { Post } from "../Util/api";
|
import { Post } from "../Util/api";
|
||||||
import CommentsButton from "./Buttons/CommentsButton";
|
import CommentsButton from "./Buttons/CommentsButton";
|
||||||
|
@ -9,14 +15,21 @@ import ToPostButton from "./Buttons/ToPost";
|
||||||
|
|
||||||
export function PostSegment(props: { post: Post }): JSXElement {
|
export function PostSegment(props: { post: Post }): JSXElement {
|
||||||
const [local] = splitProps(props, ["post"]);
|
const [local] = splitProps(props, ["post"]);
|
||||||
const dateOfCreation = new Date(local.post.createdAt).toDateString();
|
const [updatedAt, setUpdatedAt] = createSignal<string>("");
|
||||||
const isEdited = !(local.post.createdAt == local.post.updatedAt);
|
const [createdAt, setCreatedAT] = createSignal<string>("");
|
||||||
|
const [edited, setEdited] = createSignal<boolean>(false);
|
||||||
|
|
||||||
|
createEffect((): void => {
|
||||||
|
setUpdatedAt(new Date(local.post.createdAt).toDateString());
|
||||||
|
setCreatedAT(new Date(local.post.updatedAt).toDateString());
|
||||||
|
setEdited(updatedAt() === createdAt());
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
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 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="card-body md:mx-6">
|
||||||
<div class="flex flex-row justify-between">
|
<div class="flex flex-row justify-between">
|
||||||
<p class="text-xs">{dateOfCreation}</p>
|
<p class="text-xs">{createdAt()}</p>
|
||||||
<details class="dropdown">
|
<details class="dropdown">
|
||||||
<summary class="btn btn-sm">...</summary>
|
<summary class="btn btn-sm">...</summary>
|
||||||
<ul class="w-26 menu dropdown-content z-[1] rounded-box bg-base-100 p-2 shadow">
|
<ul class="w-26 menu dropdown-content z-[1] rounded-box bg-base-100 p-2 shadow">
|
||||||
|
@ -29,7 +42,7 @@ export function PostSegment(props: { post: Post }): JSXElement {
|
||||||
</ul>
|
</ul>
|
||||||
</details>
|
</details>
|
||||||
</div>
|
</div>
|
||||||
<Show when={isEdited}>
|
<Show when={edited()}>
|
||||||
<p>This post has been edited</p>
|
<p>This post has been edited</p>
|
||||||
</Show>
|
</Show>
|
||||||
<p class="my-1 text-base">{local.post.content}</p>
|
<p class="my-1 text-base">{local.post.content}</p>
|
||||||
|
|
Loading…
Reference in a new issue