diff --git a/src/views/communities/components/community-card.tsx b/src/views/communities/components/community-card.tsx index 16d75aad6..9cba7d979 100644 --- a/src/views/communities/components/community-card.tsx +++ b/src/views/communities/components/community-card.tsx @@ -26,7 +26,7 @@ function CommunityCard({ community, ...props }: Omit & { diff --git a/src/views/communities/components/community-description.tsx b/src/views/communities/components/community-description.tsx index 2e295272c..b07a292c2 100644 --- a/src/views/communities/components/community-description.tsx +++ b/src/views/communities/components/community-description.tsx @@ -1,4 +1,6 @@ -import { Box, BoxProps } from "@chakra-ui/react"; +import { useState } from "react"; +import { Box, BoxProps, Button } from "@chakra-ui/react"; + import { NostrEvent } from "../../../types/nostr-event"; import { getCommunityDescription } from "../../../helpers/nostr/communities"; import { EmbedableContent, embedUrls, truncateEmbedableContent } from "../../../helpers/embeds"; @@ -7,19 +9,28 @@ import { renderGenericUrl } from "../../../components/embed-types"; export default function CommunityDescription({ community, maxLength, + showExpand, ...props -}: Omit & { community: NostrEvent; maxLength?: number }) { +}: Omit & { community: NostrEvent; maxLength?: number; showExpand?: boolean }) { const description = getCommunityDescription(community); let content: EmbedableContent = description ? [description] : []; + const [showAll, setShowAll] = useState(false); content = embedUrls(content, [renderGenericUrl]); - if (maxLength !== undefined) { + if (maxLength !== undefined && !showAll) { content = truncateEmbedableContent(content, maxLength); } return ( - - {content} - + <> + + {content} + + {maxLength !== undefined && showExpand && !showAll && (description?.length ?? 0) > maxLength && ( + + )} + ); } diff --git a/src/views/community/community-home.tsx b/src/views/community/community-home.tsx index e4b3b5bb6..4f1f4cd85 100644 --- a/src/views/community/community-home.tsx +++ b/src/views/community/community-home.tsx @@ -1,5 +1,5 @@ import { useRef } from "react"; -import { Box, Flex, Heading, Text } from "@chakra-ui/react"; +import { Box, Button, Card, Flex, Heading, Text } from "@chakra-ui/react"; import { COMMUNITY_APPROVAL_KIND, @@ -8,6 +8,7 @@ import { getCommunityImage, getCommunityMods, getCommunityName, + getCommunityDescription, } from "../../helpers/nostr/communities"; import { NostrEvent, isETag } from "../../types/nostr-event"; import VerticalPageLayout from "../../components/vertical-page-layout"; @@ -48,6 +49,44 @@ function ApprovedEvent({ approval }: { approval: NostrEvent }) { ); } +function CommunityDetails({ community }: { community: NostrEvent }) { + const communityRelays = getCommunityRelays(community); + const mods = getCommunityMods(community); + const description = getCommunityDescription(community); + + return ( + + {description && ( + <> + Description: + + + )} + + Moderators: + + + {mods.map((pubkey) => ( + + + + + ))} + + {communityRelays.length > 0 && ( + <> + + Relays: + + + + + + )} + + ); +} + export default function CommunityHomePage({ community }: { community: NostrEvent }) { const mods = getCommunityMods(community); const image = getCommunityImage(community); @@ -70,9 +109,9 @@ export default function CommunityHomePage({ community }: { community: NostrEvent )} @@ -84,28 +123,18 @@ export default function CommunityHomePage({ community }: { community: NostrEvent - - - Moderators: - {mods.map((pubkey) => ( - - - - - ))} - - {communityRelays.length > 0 && ( - - Relays: - - - )} - - {approvals.map((approval) => ( - - ))} - + + + + {approvals.map((approval) => ( + + ))} + + + + + );