|
1 | 1 | import { days, months } from "@/helpers/utils" |
2 | 2 | import { Contribution } from "@/types" |
| 3 | +import { IssueCommentNodes } from "@/types/comments" |
| 4 | +import { PrNodes } from "@/types/pull_requests" |
3 | 5 | import React from "react" |
4 | 6 | import ToolTip from "../tool-tip" |
5 | 7 |
|
6 | 8 | const ContributionGraph = ({ |
7 | 9 | memoizedGraphValues, |
8 | 10 | loading, |
9 | | - onClickToolTip |
| 11 | + onClickToolTip, |
| 12 | + allPrs, |
| 13 | + allIssues, |
| 14 | + username |
10 | 15 | }: { |
11 | 16 | memoizedGraphValues: Contribution[] |
12 | 17 | onClickToolTip: (content: Contribution) => void |
13 | 18 | loading: boolean |
| 19 | + allPrs: PrNodes[] |
| 20 | + allIssues: IssueCommentNodes[] |
| 21 | + username: string |
14 | 22 | }) => { |
| 23 | + const condition = allPrs.length === 0 && allIssues.length === 0 |
| 24 | + |
15 | 25 | return ( |
16 | | - <div> |
17 | | - <div className="flex items-center gap-[3px]"> |
18 | | - <section className="flex flex-col justify-center h-full mt-[10px]"> |
19 | | - {days.map((d) => ( |
20 | | - <p key={d} className="text-black text-xs pt-[8.5px]"> |
21 | | - {d} |
22 | | - </p> |
23 | | - ))} |
| 26 | + <div |
| 27 | + className={`${ |
| 28 | + condition && loading === false ? "relative border rounded" : "" |
| 29 | + } `} |
| 30 | + > |
| 31 | + {condition && loading === false ? ( |
| 32 | + <section className="h-full w-full flex items-center justify-center absolute z-50 bg-slate-50 opacity-70"> |
| 33 | + <p className="text-black font-semibold text-sm opacity-100"> |
| 34 | + <span className="text-black capitalize"> |
| 35 | + {username} |
| 36 | + </span>{" "} |
| 37 | + may have mostly private contributions |
| 38 | + </p> |
24 | 39 | </section> |
25 | | - <div className="max-w-full w-full overflow-x-auto h-full relative"> |
26 | | - <section className="grid grid-flow-col pb-[2px] w-full overflow-x-auto md:min-w-[620px] min-w-[620px]"> |
27 | | - {months.map((m) => ( |
28 | | - <p key={m} className="text-black text-xs"> |
29 | | - {m} |
30 | | - </p> |
31 | | - ))} |
32 | | - </section> |
33 | | - <div> |
34 | | - <div className="gap-[2px] grid grid-flow-col h-full gridBox"> |
35 | | - {memoizedGraphValues.map((day, idx) => ( |
36 | | - <ToolTip |
37 | | - key={`${day.day}_${idx}`} |
38 | | - content={day} |
39 | | - onClickToolTip={onClickToolTip} |
40 | | - loading={loading} |
41 | | - /> |
| 40 | + ) : null} |
| 41 | + <> |
| 42 | + <div className="flex items-center gap-[3px]"> |
| 43 | + {condition ? null : ( |
| 44 | + <section className="flex flex-col justify-center h-full mt-[10px]"> |
| 45 | + {days.map((d) => ( |
| 46 | + <p |
| 47 | + key={d} |
| 48 | + className="text-black text-xs pt-[8.5px]" |
| 49 | + > |
| 50 | + {d} |
| 51 | + </p> |
42 | 52 | ))} |
| 53 | + </section> |
| 54 | + )} |
| 55 | + <div className="max-w-full w-full overflow-x-auto h-full relative"> |
| 56 | + {allPrs.length === 0 && |
| 57 | + allIssues.length === 0 ? null : ( |
| 58 | + <section className="grid grid-flow-col pb-[2px] w-full overflow-x-auto md:min-w-[620px] min-w-[620px]"> |
| 59 | + {months.map((m) => ( |
| 60 | + <p key={m} className="text-black text-xs"> |
| 61 | + {m} |
| 62 | + </p> |
| 63 | + ))} |
| 64 | + </section> |
| 65 | + )} |
| 66 | + <div> |
| 67 | + <div className="gap-[2px] grid grid-flow-col h-full gridBox"> |
| 68 | + {memoizedGraphValues.map((day, idx) => ( |
| 69 | + <ToolTip |
| 70 | + key={`${day.day}_${idx}`} |
| 71 | + content={day} |
| 72 | + onClickToolTip={onClickToolTip} |
| 73 | + loading={loading} |
| 74 | + /> |
| 75 | + ))} |
| 76 | + </div> |
43 | 77 | </div> |
44 | 78 | </div> |
45 | 79 | </div> |
46 | | - </div> |
47 | | - <section className="text-black text-xs font-medium flex gap-3 flex-wrap pt-4"> |
48 | | - <div className="flex items-center gap-1"> |
49 | | - <p>Commits</p> |
50 | | - <section className="h-[10px] w-[10px] rounded-[3px] bg-grid-blue"></section> |
51 | | - </div> |
52 | | - <div className="flex items-center gap-1"> |
53 | | - <p>Comments</p> |
54 | | - <section className="h-[10px] w-[10px] rounded-[3px] bg-grid-yellow"></section> |
55 | | - </div> |
56 | | - <div className="flex items-center gap-1"> |
57 | | - <p>Commits & Comments</p> |
58 | | - <section className="h-[10px] w-[10px] rounded-[3px] bg-grid-green"></section> |
59 | | - </div> |
60 | | - </section> |
| 80 | + {condition ? null : ( |
| 81 | + <section className="text-black text-xs font-medium flex gap-3 flex-wrap pt-4"> |
| 82 | + <div className="flex items-center gap-1"> |
| 83 | + <p>Commits</p> |
| 84 | + <section className="h-[10px] w-[10px] rounded-[3px] bg-grid-blue"></section> |
| 85 | + </div> |
| 86 | + <div className="flex items-center gap-1"> |
| 87 | + <p>Comments</p> |
| 88 | + <section className="h-[10px] w-[10px] rounded-[3px] bg-grid-yellow"></section> |
| 89 | + </div> |
| 90 | + <div className="flex items-center gap-1"> |
| 91 | + <p>Commits & Comments</p> |
| 92 | + <section className="h-[10px] w-[10px] rounded-[3px] bg-grid-green"></section> |
| 93 | + </div> |
| 94 | + </section> |
| 95 | + )} |
| 96 | + </> |
61 | 97 | </div> |
62 | 98 | ) |
63 | 99 | } |
|
0 commit comments