From 563ae6db2e33cd84e6e3f1ad2aeba34b353cba16 Mon Sep 17 00:00:00 2001 From: Hossein Mehrabi Date: Thu, 24 Aug 2023 20:55:50 +0330 Subject: [PATCH] fix: hide the year of most recent posts on the landing page --- src/components/PostCard/PostCard.Label.tsx | 14 ++++++++++++-- src/components/PostCard/PostCard.tsx | 3 +++ src/components/PostsGrid/PostsGrid.tsx | 3 +++ src/containers/HomePage/HomePage.tsx | 1 + 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/components/PostCard/PostCard.Label.tsx b/src/components/PostCard/PostCard.Label.tsx index f614260..d801842 100644 --- a/src/components/PostCard/PostCard.Label.tsx +++ b/src/components/PostCard/PostCard.Label.tsx @@ -7,9 +7,15 @@ import PostType = LPE.PostType export type Props = React.ComponentProps & { contentType: PostType date: Date | null + displayYear?: boolean } -export const PostCardLabel: FC = ({ contentType, date, ...props }) => { +export const PostCardLabel: FC = ({ + displayYear = true, + contentType, + date, + ...props +}) => { return ( @@ -23,7 +29,11 @@ export const PostCardLabel: FC = ({ contentType, date, ...props }) => { date.toLocaleString('en-GB', { day: 'numeric', month: 'long', // TODO: Should be uppercase - year: 'numeric', + ...(displayYear + ? { + year: 'numeric', + } + : {}), })} diff --git a/src/components/PostCard/PostCard.tsx b/src/components/PostCard/PostCard.tsx index 7ac509a..7d66e7d 100644 --- a/src/components/PostCard/PostCard.tsx +++ b/src/components/PostCard/PostCard.tsx @@ -41,6 +41,7 @@ export type PostCardProps = CommonProps & size?: 'xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' applySizeStyles?: boolean displayPodcastShow?: boolean + displayYear?: boolean } export const PostCard = (_props: PostCardProps) => { @@ -60,6 +61,7 @@ export const PostCard = (_props: PostCardProps) => { contentType, applySizeStyles = true, displayPodcastShow = true, + displayYear = true, ...props } = _props @@ -81,6 +83,7 @@ export const PostCard = (_props: PostCardProps) => { ) diff --git a/src/components/PostsGrid/PostsGrid.tsx b/src/components/PostsGrid/PostsGrid.tsx index 1b43732..aa52cfc 100644 --- a/src/components/PostsGrid/PostsGrid.tsx +++ b/src/components/PostsGrid/PostsGrid.tsx @@ -13,6 +13,7 @@ export type PostsGridProps = Partial> & { shows?: LPE.Podcast.Show[] posts?: LPE.Post.Document[] displayPodcastShow?: boolean + displayYear?: boolean } export const PostsGrid: React.FC = ({ @@ -23,6 +24,7 @@ export const PostsGrid: React.FC = ({ bordered = false, horizontal = false, displayPodcastShow = true, + displayYear = true, ...props }) => { const theme = useTheme() @@ -69,6 +71,7 @@ export const PostsGrid: React.FC = ({ applySizeStyles={false} className="post-card" contentType={post.type} + displayYear={displayYear} displayPodcastShow={displayPodcastShow} data={PostCard.toData(post, shows)} /> diff --git a/src/containers/HomePage/HomePage.tsx b/src/containers/HomePage/HomePage.tsx index 08920a3..59fe67a 100644 --- a/src/containers/HomePage/HomePage.tsx +++ b/src/containers/HomePage/HomePage.tsx @@ -37,6 +37,7 @@ export const HomePage: React.FC = ({