-
-
Notifications
You must be signed in to change notification settings - Fork 38
/
RepositoryContributionsCard.tsx
94 lines (93 loc) · 3.29 KB
/
RepositoryContributionsCard.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import { Contributions, PullRequestNode, Repository } from "@/types/github";
import Image from "next/image";
import Link from "next/link";
import { FaCodeMerge } from "react-icons/fa6";
import { IoIosCloseCircleOutline } from "react-icons/io";
import { GoIssueOpened } from "react-icons/go";
export const RepositoryContributionsCard = ({
repository,
contributions: { totalCount, nodes },
}: {
repository: Repository;
contributions: Contributions;
}) => {
return (
<div className="card bg-base-100 overflow-visible">
<div className="sm:w-auto card bg-base-100 repository-card">
<div className="card-body">
<div className="card-title flex items-center justify-between">
<div className="flex items-center space-x-2 flex-grow">
<Image
src={repository.owner.avatarUrl}
alt={repository.owner.login}
width={40}
height={40}
className="rounded-full"
/>
<div
className="grid grid-flow-col gap-2 flex-grow tooltip text-left"
data-tip={`${repository.owner.login}/${repository.name}`}
>
<Link
href={`https://github.com/${repository.owner.login}/${repository.name}`}
rel="noopener noreferrer"
target="_blank"
className="hover:underline truncate flex-grow"
aria-label={`${repository.name}`}
>
<h3 className="logged-user truncate">
{repository.owner.login}/{repository.name}
</h3>
</Link>
</div>
<div
className="tooltip tooltip-left"
data-tip="Total contributions"
>
<div className="rounded outline outline-1 cursor-default px-2">
{totalCount}
</div>
</div>
</div>
</div>
<div className="max-h-[22rem] hide-scrollbar overflow-auto flex flex-col gap-1">
{nodes?.map(
({ pullRequest: { state, title, id, url } }: PullRequestNode) => (
<div
key={id}
className="flex items-center justify-between gap-2"
>
<a
href={url}
target="_blank"
className="truncate"
title={title}
>
{title}
</a>
<span
className={`h-fit rounded p-1 ${
state === "MERGED"
? "bg-purple-500"
: state === "CLOSED"
? "bg-red-500"
: "bg-green-500"
}`}
>
{state === "MERGED" ? (
<FaCodeMerge size={18} />
) : state === "CLOSED" ? (
<IoIosCloseCircleOutline size={18} />
) : (
<GoIssueOpened size={18} />
)}
</span>
</div>
)
)}
</div>
</div>
</div>
</div>
);
};