From 65cfe943b08c559f0907fabd789a30a827960f3e Mon Sep 17 00:00:00 2001 From: Saul Dominguez Date: Fri, 3 Jan 2025 11:54:32 +0100 Subject: [PATCH] format ago using F1 --- .../Communities/Post/CommunityPost/index.stories.tsx | 3 ++- .../Information/Communities/Post/CommunityPost/index.tsx | 7 +++++-- lib/lib/date.ts | 6 +++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/experimental/Information/Communities/Post/CommunityPost/index.stories.tsx b/lib/experimental/Information/Communities/Post/CommunityPost/index.stories.tsx index 6f3babe7..f7b77501 100644 --- a/lib/experimental/Information/Communities/Post/CommunityPost/index.stories.tsx +++ b/lib/experimental/Information/Communities/Post/CommunityPost/index.stories.tsx @@ -1,4 +1,5 @@ import type { Meta, StoryObj } from "@storybook/react" +import { subMonths } from "date-fns" import { CommunityPost } from "." const meta: Meta = { @@ -31,7 +32,7 @@ export const Default: Story = { title: "All company", url: "https://google.com/", }, - ago: "a month ago", + createdAt: subMonths(new Date(), 1), title: "Title", description: "Description with a maximum of two lines visible.
Like this one :)
This shouldn't be visible", diff --git a/lib/experimental/Information/Communities/Post/CommunityPost/index.tsx b/lib/experimental/Information/Communities/Post/CommunityPost/index.tsx index e2aa8a2c..601566f1 100644 --- a/lib/experimental/Information/Communities/Post/CommunityPost/index.tsx +++ b/lib/experimental/Information/Communities/Post/CommunityPost/index.tsx @@ -4,6 +4,7 @@ import { PersonAvatar } from "@/experimental/Information/Avatars/PersonAvatar" import { Reactions, ReactionsProps } from "@/experimental/Information/Reactions" import { Dropdown } from "@/experimental/Navigation/Dropdown" import { EllipsisHorizontal } from "@/icons/app" +import { getAgo } from "@/lib/date" import { withSkeleton } from "@/lib/skeleton" import { Skeleton } from "@/ui/skeleton" import { PostEvent, PostEventProps } from "../PostEvent" @@ -19,7 +20,7 @@ type CommunityPostProps = { title: string url: string } - ago: string + createdAt: Date title: string description?: string @@ -45,7 +46,7 @@ type CommunityPostProps = { export const BaseCommunityPost = ({ author, group, - ago, + createdAt, title, description, onClick, @@ -60,6 +61,8 @@ export const BaseCommunityPost = ({ .filter(Boolean) .join(" ยท ") + const ago = getAgo(createdAt) + return (