From 448c443e2e1b32b4bb9f3f8fd1079b5aea4e6f0f Mon Sep 17 00:00:00 2001 From: Max Leiter Date: Thu, 24 Mar 2022 19:32:24 -0700 Subject: [PATCH] client: misc style improvements --- client/components/post-page/index.tsx | 13 ++++-- .../components/post-page/post-page.module.css | 44 ++++++++++++------- client/lib/types.d.ts | 2 + 3 files changed, 40 insertions(+), 19 deletions(-) diff --git a/client/components/post-page/index.tsx b/client/components/post-page/index.tsx index a6b0425..ca79e58 100644 --- a/client/components/post-page/index.tsx +++ b/client/components/post-page/index.tsx @@ -6,8 +6,10 @@ import styles from './post-page.module.css' import homeStyles from '@styles/Home.module.css' import type { File, Post } from "@lib/types" -import { Page, Button, Text } from "@geist-ui/core" +import { Page, Button, Text, Badge, Tooltip, Spacer } from "@geist-ui/core" import ShiftBy from "@components/shift-by" +import { useMemo, useState } from "react" +import timeAgo from "@lib/time-ago" type Props = { post: Post @@ -29,6 +31,10 @@ const PostPage = ({ post }: Props) => { link.click() link.remove() } + const createdDate = useMemo(() => new Date(post.createdAt), [post.createdAt]) + const [time, setTimeAgo] = useState(timeAgo(createdDate)) + + const formattedTime = `${createdDate.toLocaleDateString()} ${createdDate.toLocaleTimeString()}` return ( @@ -46,9 +52,10 @@ const PostPage = ({ post }: Props) => {
{post.title} - + - + {time} +