diff --git a/frontend/__tests__/unit/pages/Contribute.test.tsx b/frontend/__tests__/unit/pages/Contribute.test.tsx index 5ed39a6ae6..b70a8b786d 100644 --- a/frontend/__tests__/unit/pages/Contribute.test.tsx +++ b/frontend/__tests__/unit/pages/Contribute.test.tsx @@ -71,10 +71,9 @@ describe('Contribute Component', () => { totalPages: 4, }) render() - await waitFor(() => { - const nextPageButton = screen.getByText('Next Page') - fireEvent.click(nextPageButton) - }) + const nextPageButton = await screen.findByText('Next Page') + expect(nextPageButton).toBeInTheDocument() + fireEvent.click(nextPageButton) expect(window.scrollTo).toHaveBeenCalledWith({ top: 0, behavior: 'auto', @@ -155,10 +154,8 @@ describe('Contribute Component', () => { }) render() - await waitFor(() => { - const readMoreButton = screen.getByText('Read More') - expect(readMoreButton).toBeInTheDocument() - }) + const submitButton = await screen.findByRole('button', { name: /submit/i }) + expect(submitButton).toBeInTheDocument() }) test('opens modal when SubmitButton is clicked', async () => { @@ -169,10 +166,8 @@ describe('Contribute Component', () => { }) render() - await waitFor(() => { - const readMoreButton = screen.getByText('Read More') - fireEvent.click(readMoreButton) - }) + const readMoreButton = await screen.findByText('Read More') + fireEvent.click(readMoreButton) await waitFor(() => { const modalTitle = screen.getByText('Close') @@ -188,10 +183,8 @@ describe('Contribute Component', () => { }) render() - await waitFor(() => { - const readMoreButton = screen.getByText('Read More') - fireEvent.click(readMoreButton) - }) + const readMoreButton = await screen.findByText('Read More') + fireEvent.click(readMoreButton) await waitFor(() => { const closeButton = screen.getByText('Close') diff --git a/frontend/src/components/Card.tsx b/frontend/src/components/Card.tsx index 38ede1d9a7..d14180eebb 100644 --- a/frontend/src/components/Card.tsx +++ b/frontend/src/components/Card.tsx @@ -1,8 +1,6 @@ import { HStack, Link } from '@chakra-ui/react' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' -import { useState, useEffect } from 'react' import { CardProps } from 'types/card' -import { desktopViewMinWidth } from 'utils/constants' import { Icons } from 'utils/data' import { TooltipRecipe } from 'utils/theme' import { getSocialIcon } from 'utils/urlIconMappings' @@ -14,9 +12,6 @@ import DisplayIcon from 'components/DisplayIcon' import Markdown from 'components/MarkdownWrapper' import { Tooltip } from 'components/ui/tooltip' -// Initial check for mobile screen size -const isMobileInitial = typeof window !== 'undefined' && window.innerWidth < desktopViewMinWidth - const Card = ({ title, url, @@ -30,23 +25,17 @@ const Card = ({ social, tooltipLabel, }: CardProps) => { - const [isMobile, setIsMobile] = useState(isMobileInitial) - - // Resize listener to adjust display based on screen width - useEffect(() => { - const checkMobile = () => { - const mobile = window.innerWidth < desktopViewMinWidth - setIsMobile(mobile) - } - window.addEventListener('resize', checkMobile) - return () => window.removeEventListener('resize', checkMobile) - }, []) + const hasSocial = social && social.length > 0 + const hasContributors = topContributors && topContributors.length > 0 return ( -
-
-
- {/* Display project level badge (if available) */} +
+
+
{level && ( @@ -67,21 +56,34 @@ const Card = ({ )} - {/* Project title and link */} - -

+ + {/* Project Title */} + +

{title}

- {/* Icons associated with the project */} - {icons && Object.keys(Icons).some((key) => icons[key]) ? ( -
+ + {projectName && ( + + + {projectName} + + )} + + {/* Technology Icons*/} + {icons && Object.keys(Icons).some((key) => icons[key]) && ( +
{Object.keys(Icons).map((key, index) => icons[key] ? ( - ) : null} + )} + + {/* Summary section */} +
+ +
- {/* Link to project name if provided */} - {projectName && ( - - {projectName} - - )} - {/* Render project summary using Markdown */} - +
0 @@ -109,58 +112,50 @@ const Card = ({ : 'flex w-full items-center justify-between' } > - {/* Render top contributors as avatars */} -
- {topContributors?.map((contributor, index) => ( - - ))} -
- {!social || social.length === 0 ? ( -
- - {button.icon} - {button.label} - -
- ) : ( -
+ {/* First row: Contributors only when social links are present */} + {hasContributors && ( +
+
+ + Contributors + +
+ {topContributors.map((contributor, index) => ( + + ))} +
+
+
)} - > -
- {/* Render social links if available */} - {social && social.length > 0 && ( - + + {/* Second row: Social links and button on the same line */} +
+
+ + Connect + + {social.map((item) => ( ))} - )} - {/* Action Button */} -
+
+
{button.icon} {button.label} @@ -168,6 +163,33 @@ const Card = ({
+ ) : ( +
+ {hasContributors ? ( +
+ + Contributors + +
+ {topContributors.map((contributor, index) => ( + + ))} +
+
+ ) : ( +
+ )} +
+ + {button.icon} + {button.label} + +
+
)}