From 320466af802f74705f003518f46adc9217cf648c Mon Sep 17 00:00:00 2001 From: lauchaves Date: Wed, 24 Jul 2024 23:37:55 -0600 Subject: [PATCH] #249: Long posts should have the see more feature --- JoyboyCommunity/src/modules/Post/index.tsx | 16 +++++++++++++++- JoyboyCommunity/src/modules/Post/styles.ts | 5 +++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/JoyboyCommunity/src/modules/Post/index.tsx b/JoyboyCommunity/src/modules/Post/index.tsx index dfff4ae4..27898797 100644 --- a/JoyboyCommunity/src/modules/Post/index.tsx +++ b/JoyboyCommunity/src/modules/Post/index.tsx @@ -45,6 +45,11 @@ export const Post: React.FC = ({asComment, event}) => { const queryClient = useQueryClient(); const [menuOpen, setMenuOpen] = useState(false); + const [isContentExpanded, setIsContentExpanded] = useState(false); + + const toggleExpandedContent = () => { + setIsContentExpanded((prev) => !prev); + }; const scale = useSharedValue(1); @@ -107,6 +112,9 @@ export const Post: React.FC = ({asComment, event}) => { ); }; + const content = event?.content || ''; + const truncatedContent = content.length > 200 ? `${content.slice(0, 200)}...` : content; + return ( {repostedEvent && ( @@ -188,9 +196,15 @@ export const Post: React.FC = ({asComment, event}) => { - {event?.content} + {isContentExpanded ? content : truncatedContent} + {content.length > 200 && ( + + {isContentExpanded ? 'See less' : 'See more...'} + + )} + {postSource && ( ({ alignItems: 'center', gap: Spacing.xxxsmall, }, + seeMore: { + color: theme.colors.primary, + fontSize: 13, + marginTop: Spacing.xsmall, + }, }));