import { ProjectLink } from "../mappings/project-link" import { ProjectInterface, ProjectLinkWebsite, ProjectStatus, ProjectStatusLabelMapping, } from "@/lib/types" import { cn } from "@/lib/utils" import { VariantProps, cva } from "class-variance-authority" import Image from "next/image" import Link from "next/link" import { useRouter } from "next/navigation" import React from "react" interface ProjectCardProps extends React.HTMLAttributes, VariantProps { project: ProjectInterface showLinks?: boolean // show links in the card showBanner?: boolean // show images in the card } const tagCardVariants = cva( "text-xs font-sans text-white rounded-[3px] py-[2px] px-[6px] dark:text-black", { variants: { variant: { primary: "bg-[#D8FEA8]", secondary: "bg-[#C2E8F5]", }, }, } ) const projectCardVariants = cva( "flex flex-col overflow-hidden rounded-lg transition duration-200 ease-in border border-transparent", { variants: { showLinks: { true: "min-h-[280px]", false: "min-h-[200px]", }, border: { true: "border border-slate-900/20 dark:border-anakiwa-800", }, }, } ) export const ProjectStatusColorMapping: Record = { active: "#D8FEA8", inactive: "#FFB7AA", maintained: "#FFEC9E", } export default function ProjectCard({ project, showLinks = false, showBanner = false, border = false, className, }: ProjectCardProps) { const router = useRouter() const { id, image, links, name, imageAlt, projectStatus, cardTags, tldr } = project ?? {} return (
{showBanner && (
{ router.push(`/projects/${id}`) }} > Project banner image {!image && ( {imageAlt || name} )}
)}

{name}

{(tldr ?? "")?.length > 0 && (

{tldr}

)}
{showLinks && (
{Object.entries(links ?? {})?.map(([website, url], index) => { return ( ) })}
)}
{ProjectStatusLabelMapping[project?.projectStatus]}
{cardTags && (
{cardTags?.primary && (
{cardTags?.primary}
)} {cardTags?.secondary && (
{cardTags?.secondary}
)}
)}
) }