Skip to content

Commit

Permalink
feat: project page cards ready?
Browse files Browse the repository at this point in the history
  • Loading branch information
harshkhandeparkar committed Nov 15, 2023
1 parent 730cf25 commit f589687
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 51 deletions.
110 changes: 59 additions & 51 deletions src/components/ProjectCard.tsx
Original file line number Diff line number Diff line change
@@ -1,72 +1,80 @@
import { IProject, IProjectTags } from "../util/types";
import projectTags from "../data/projectTags.json";
import { IoPersonSharp } from "react-icons/io5";
import { IProject } from "../util/types";

function ProjectCard({
name,
description,
tags,
mentor,
secondary_mentor,
comm_channel,
repo_link,
}: IProject) {
function getColor(tag: string) {
if (tag in projectTags) {
return (projectTags as IProjectTags)[tag];
} else {
const randomColorIndex = Math.floor(
Math.random() * Object.keys(projectTags as IProjectTags).length,
);
const randomKey = Object.keys(projectTags as IProjectTags)[
randomColorIndex
];
return (projectTags as IProjectTags)[randomKey];
}
}
return (
<>
<div className="p-4 rounded-md w-full h-full bg-[#0f0f27]">
<h2 className="text-3xl font-bold text-center mb-1">{name}</h2>
<h3 className="text-lg text-center mb-3">
<span className="font-bold">Mentor</span>:{" "}
<a
className="text-primary font-semibold hover:text-primary-600 hover:underline"
href={`https://github.com/${mentor.username}`}
>
{mentor.name}
</a>
</h3>
<p className="mb-4 break-words line-clamp-4" title={description}>
{description}
</p>
<div className="flex flex-wrap gap-2 mb-8 justify-center">
{tags
.sort()
.slice(0, 6)
.map((tag, i) => (
<span
key={i}
style={{ backgroundColor: getColor(tag) }}
className="px-3 py-1 cursor-pointer text-xs font-bold rounded-md"
>
<div className="px-4 py-4 w-80 rounded-md bg-[#2a2a2aa3]">
<div className="flex flex-col mb-4 gap-1">
<h3 className="font-semibold text-2xl">{name}</h3>
<div className="flex gap-2.5">
{tags.map((tag) => (
<p className="rounded-md px-2.5 py-0.5 bg-primary-800 text-sm">
{tag}
</span>
</p>
))}
</div>
</div>

<p className="mb-4">{description}</p>

<div className="mb-5 space-y-1">
<div className="flex gap-2 items-center">
<div className="flex gap-2 items-center text-sm font-semibold">
<IoPersonSharp />
Mentor:
</div>
<a
href={`https://github.com/${mentor.username}`}
className="font-bold text-base hover:underline"
>
@{mentor.username}
</a>
</div>
<div className="flex gap-2 items-center">
<div className="flex gap-2 items-center text-sm font-semibold">
<IoPersonSharp />
Secondary Mentor:
</div>
<a
href={
secondary_mentor.username !== ""
? `https://github.com/${secondary_mentor.username}`
: undefined
}
className={`font-bold text-base ${
secondary_mentor.username !== "" ? "hover:underline" : ""
}`}
>
{secondary_mentor.username !== ""
? `@${secondary_mentor.username}`
: "None"}
</a>
</div>
</div>
<div className="flex justify-center gap-2 align-bottom">
<button
onClick={() => window.open(repo_link, "_blank")}
className="px-4 py-2 rounded-md bg-primary-950 hover:bg-primary-900 text-lg font-bold flex justify-center items-center"
<div className="mb-2 flex justify-around font-semibold gap-2">
<a
href={repo_link}
target="_blank"
className="text-center font-semibold text-lg w-full p-1 bg-primary-700 rounded-md hover:bg-primary-800"
>
View Project
</button>
<button
onClick={() => {
window.open(comm_channel, "_blank");
}}
className="px-4 py-2 rounded-md bg-primary-950 hover:bg-primary-900 text-lg font-bold flex justify-center items-center"
</a>
<a
href={comm_channel}
target="_blank"
className="text-center font-semibold text-lg w-full p-1 bg-primary-700 rounded-md hover:bg-primary-800"
>
Join Channel
</button>
</a>
</div>
</div>
</>
Expand Down
1 change: 1 addition & 0 deletions src/util/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export interface IProject {
comm_channel: string;
readme_link: string;
mentor: IMentor;
secondary_mentor: IMentor;
}

interface IProjectReg {
Expand Down

0 comments on commit f589687

Please sign in to comment.