From 364c138facbba8fcbc2f0a662cf510c72bd3904c Mon Sep 17 00:00:00 2001 From: Kamran Ahmed Date: Sat, 17 Aug 2024 01:09:17 +0100 Subject: [PATCH] Make project pages responsive --- .../Projects/ListProjectSolutions.tsx | 26 +++--- src/components/Projects/ProjectTabs.tsx | 81 ++++++++++++------- src/components/Projects/VoteButton.tsx | 2 +- .../projects/[projectId]/solutions.astro | 6 +- 4 files changed, 66 insertions(+), 49 deletions(-) diff --git a/src/components/Projects/ListProjectSolutions.tsx b/src/components/Projects/ListProjectSolutions.tsx index 5bdb48353..9b48f680d 100644 --- a/src/components/Projects/ListProjectSolutions.tsx +++ b/src/components/Projects/ListProjectSolutions.tsx @@ -3,22 +3,14 @@ import { useToast } from '../../hooks/use-toast'; import { httpGet, httpPost } from '../../lib/http'; import { LoadingSolutions } from './LoadingSolutions'; import { EmptySolutions } from './EmptySolutions'; -import { - ArrowDown, - ArrowUp, - CalendarCheck, - ThumbsDown, - ThumbsUp, -} from 'lucide-react'; +import { ThumbsDown, ThumbsUp } from 'lucide-react'; import { getRelativeTimeString } from '../../lib/date'; import { Pagination } from '../Pagination/Pagination'; import { deleteUrlParam, getUrlParams, setUrlParams } from '../../lib/browser'; import { pageProgressMessage } from '../../stores/page'; -import { cn } from '../../lib/classname'; import { LeavingRoadmapWarningModal } from './LeavingRoadmapWarningModal'; import { isLoggedIn } from '../../lib/jwt'; import { showLoginPopup } from '../../lib/popup'; -import { CheckIcon } from '../ReactIcons/CheckIcon.tsx'; import { VoteButton } from './VoteButton.tsx'; import { GitHubIcon } from '../ReactIcons/GitHubIcon.tsx'; @@ -239,7 +231,7 @@ export function ListProjectSolutions(props: ListProjectSolutionsProps) {
{leavingRoadmapModal} -
+
{solutions?.data.map((solution, counter) => { const isVisited = alreadyVisitedSolutions[solution._id!]; const avatar = solution.user.avatar || ''; @@ -247,7 +239,7 @@ export function ListProjectSolutions(props: ListProjectSolutionsProps) { return (
{solution.user.name} - {submittedAlternatives[ - counter % submittedAlternatives.length - ] || 'submitted their solution'}{' '} - + + {submittedAlternatives[ + counter % submittedAlternatives.length + ] || 'submitted their solution'} + {' '} + {getRelativeTimeString(solution?.submittedAt!)}
-
+
+ {ButtonIcon && } + {text} + {smText && {smText}} + + {isActive && ( + + )} + + ); +} + type ProjectTabsProps = { activeTab: AllowedProjectTab; projectId: string; @@ -12,37 +48,22 @@ type ProjectTabsProps = { export function ProjectTabs(props: ProjectTabsProps) { const { activeTab, projectId } = props; - const tabs = [ - { name: 'Project Details', value: 'details', icon: Text }, - { name: 'Community Solutions', value: 'solutions', icon: Blocks }, - ]; - return (
- {tabs.map((tab) => { - const isActive = tab.value === activeTab; - - return ( - - {tab.icon && } - {tab.name} - {isActive && ( - - )} - - ); - })} + +
); } diff --git a/src/components/Projects/VoteButton.tsx b/src/components/Projects/VoteButton.tsx index 64209999f..3b047ae79 100644 --- a/src/components/Projects/VoteButton.tsx +++ b/src/components/Projects/VoteButton.tsx @@ -12,7 +12,7 @@ export function VoteButton(props: VoteButtonProps) { return (