From 5615d03590e9c495368abb5f7caa787a830c6c92 Mon Sep 17 00:00:00 2001 From: Zeke Abshire Date: Fri, 26 May 2023 20:40:19 -0500 Subject: [PATCH] Finished up the project cards --- src/components/NewProposalPopup.tsx | 2 +- src/components/SidePanel.tsx | 38 ------------------------ src/components/WithScroll.tsx | 24 +++++++++++++++ src/components/projects/ProjectCards.tsx | 37 +++++++++++++---------- src/pages/discover/archive/index.tsx | 4 +-- src/pages/discover/index.tsx | 4 +-- src/pages/discover/proposals/index.tsx | 4 +-- src/pages/discover/revisions/index.tsx | 4 +-- src/pages/projects/index.tsx | 2 +- 9 files changed, 51 insertions(+), 68 deletions(-) create mode 100644 src/components/WithScroll.tsx diff --git a/src/components/NewProposalPopup.tsx b/src/components/NewProposalPopup.tsx index fa6df5b..36e7402 100644 --- a/src/components/NewProposalPopup.tsx +++ b/src/components/NewProposalPopup.tsx @@ -9,7 +9,7 @@ import { useForm, type SubmitHandler } from "react-hook-form"; import toast from "react-hot-toast"; import Button from "./Button"; import { Divider } from "./Divider"; -import { WithScroll } from "./SidePanel"; +import { WithScroll } from "./WithScroll"; import { TextInput, MultilineTextInput } from "./TextInput"; import type { z } from "zod"; import { useState } from "react"; diff --git a/src/components/SidePanel.tsx b/src/components/SidePanel.tsx index abaa0c8..3f2c4fb 100644 --- a/src/components/SidePanel.tsx +++ b/src/components/SidePanel.tsx @@ -1,4 +1,3 @@ -import type { Children } from "@utils/types/props"; import Link from "next/link"; import { FiMoreVertical, @@ -9,26 +8,11 @@ import { } from "react-icons/fi"; import { Button } from "@components/Button"; import * as DropdownMenu from "@radix-ui/react-dropdown-menu"; -import * as Dialog from "@radix-ui/react-dialog"; -import * as ScrollArea from "@radix-ui/react-scroll-area"; -import { cx } from "class-variance-authority"; -import { TextInput, MultilineTextInput } from "@components/TextInput"; -import { Divider } from "@components/Divider"; -import { ImageInput } from "@components/ImageInput"; -import { api } from "@utils/api"; import { getRootContainer } from "@utils/constants/htmlTools"; -import toast from "react-hot-toast"; -import { useForm } from "react-hook-form"; -import { zodResolver } from "@hookform/resolvers/zod"; -import { proposalSchema } from "@utils/constants/schema/project"; -import type { z } from "zod"; -import type { SubmitHandler } from "react-hook-form"; import { signOut } from "next-auth/react"; import { navItems } from "@utils/constants/sidepanel"; import { NewProposalPopup } from "./NewProposalPopup"; -type ProposalForm = z.infer; - export const SidePanel: React.FC = () => { return (
@@ -123,25 +107,3 @@ const MoreMenu: React.FC = () => { ); }; - -export const WithScroll: React.FC = ({ - height, - children, -}) => { - return ( - - - {children} - - - - - - ); -}; diff --git a/src/components/WithScroll.tsx b/src/components/WithScroll.tsx new file mode 100644 index 0000000..80b41be --- /dev/null +++ b/src/components/WithScroll.tsx @@ -0,0 +1,24 @@ +import * as ScrollArea from "@radix-ui/react-scroll-area"; +import type { Children } from "@utils/types/props"; + +export const WithScroll: React.FC = ({ + height, + children, +}) => { + return ( + + + {children} + + + + + + ); +}; diff --git a/src/components/projects/ProjectCards.tsx b/src/components/projects/ProjectCards.tsx index 2511e8b..65bccd6 100644 --- a/src/components/projects/ProjectCards.tsx +++ b/src/components/projects/ProjectCards.tsx @@ -9,8 +9,7 @@ import * as Tooltip from "@radix-ui/react-tooltip"; import { getRootContainer } from "@utils/constants/htmlTools"; import { NewProposalPopup } from "@components/NewProposalPopup"; import Link from "next/link"; -import { Herr_Von_Muellerhoff } from "@next/font/google"; -import { WithScroll } from "@components/SidePanel"; +import { WithScroll } from "@components/WithScroll"; // === Styles ================================================================= @@ -42,9 +41,12 @@ type ProjectCardContainerProps = Children & VariantProps; type ProjectCardProps = Component & { - project: Omit & { - members: User[]; - }; + id: string; + title: string; + description: string; + state: ProjectLifecycle; + createdAt: Date; + bannerImageUrl: string | null; }; type NewProjectCardProps = Component & { onSubmit?: () => void }; @@ -58,14 +60,19 @@ const ProjectCardContainer: React.FC = ({ }) => {children}; export const ProjectCard: React.FC = ({ - project, + id, + title, + description, + state, component, + createdAt, + bannerImageUrl, }) => { const [showMore, setShowMore] = useState(false); return ( - +
setShowMore(true)} @@ -83,28 +90,26 @@ export const ProjectCard: React.FC = ({ fill className="object-cover object-top" src={ - project.bannerImageUrl ?? - `https://picsum.photos/seed/${project.id}/300/400.webp` + bannerImageUrl ?? + `https://picsum.photos/seed/${id}/300/400.webp` } - alt={project.title} + alt={title} />
{showMore && ( -

- {project.description} -

+

{description}

)}
- +

{/* TODO: Change to time last updated */} - Created {formatDate(project.createdAt)} + Created {formatDate(createdAt)}

diff --git a/src/pages/discover/archive/index.tsx b/src/pages/discover/archive/index.tsx index 50161c3..0e5ae01 100644 --- a/src/pages/discover/archive/index.tsx +++ b/src/pages/discover/archive/index.tsx @@ -17,9 +17,7 @@ const Discover: NextPage< {isLoading ? (

Loading ...

) : ( - data?.map((project) => ( - - )) + data?.map((project) => ) )} ); diff --git a/src/pages/discover/index.tsx b/src/pages/discover/index.tsx index 6669091..b9665d6 100644 --- a/src/pages/discover/index.tsx +++ b/src/pages/discover/index.tsx @@ -15,9 +15,7 @@ const Discover: NextPage< {isLoading ? (

Loading ...

) : ( - data?.map((project) => ( - - )) + data?.map((project) => ) )} ); diff --git a/src/pages/discover/proposals/index.tsx b/src/pages/discover/proposals/index.tsx index b632ab4..206617d 100644 --- a/src/pages/discover/proposals/index.tsx +++ b/src/pages/discover/proposals/index.tsx @@ -17,9 +17,7 @@ const Discover: NextPage< {isLoading ? (

Loading ...

) : ( - data?.map((project) => ( - - )) + data?.map((project) => ) )} ); diff --git a/src/pages/discover/revisions/index.tsx b/src/pages/discover/revisions/index.tsx index 3c34621..f4e3e3d 100644 --- a/src/pages/discover/revisions/index.tsx +++ b/src/pages/discover/revisions/index.tsx @@ -17,9 +17,7 @@ const Discover: NextPage< {isLoading ? (

Loading ...

) : ( - data?.map((project) => ( - - )) + data?.map((project) => ) )} ); diff --git a/src/pages/projects/index.tsx b/src/pages/projects/index.tsx index 5d799e9..1c6a633 100644 --- a/src/pages/projects/index.tsx +++ b/src/pages/projects/index.tsx @@ -87,7 +87,7 @@ const Projects: NextPage = () => { {isLoading || isFetching ? Array(5).fill() : sortedProjects.map((p) => ( - + ))}