Skip to content
This repository has been archived by the owner on May 25, 2023. It is now read-only.

Commit

Permalink
feat: enhance contributions rendering (#1139)
Browse files Browse the repository at this point in the history
  • Loading branch information
Elixer3000 committed Aug 27, 2021
1 parent d3e2963 commit 0cc646a
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 7 deletions.
44 changes: 44 additions & 0 deletions src/components/CommitType.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React from "react";
import {GitPullRequestDraftIcon, GitPullRequestIcon, IssueOpenedIcon,
IssueClosedIcon, GitPullRequestClosedIcon, GitMergeIcon} from "@primer/octicons-react";

function CommitType({status, isDraft, mergeable, merged}) {
switch (status) { // Check the status variable for OPEN/CLOSED/MERGED ISSUES
case "OPEN":
{
if (isDraft) { //check wether if its a draft
return (
<GitPullRequestDraftIcon className="gitGrey" />
);
}
if (mergeable === "MERGEABLE") {//check if its a pull request
return (
<GitPullRequestIcon verticalAlign="middle" className="gitGreen" />
);
}
return (
<IssueOpenedIcon verticalAlign="middle" className="gitGreen"/>
);
}
case "CLOSED": // check for closed PR or Closed issue
{
if (mergeable === "MERGEABLE" && merged === false) {
return (
<GitPullRequestClosedIcon verticalAlign="middle" className="gitRed"/>
);
}
return (
<IssueClosedIcon verticalAlign="middle" className="gitRed" />
);
}
case "MERGED":
return (
<GitMergeIcon verticalAlign="middle" className="gitPurple" />
);
default:
return (
""
);
}
}
export default CommitType;
4 changes: 4 additions & 0 deletions src/components/Contributions.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ function Contributions({repoName, owner, viewer}) {
participants={issue.participants}
comments={issue.comments}
milestone={issue.milestone}
status={issue.state}
mergeable={issue.mergeable}
isDraft={issue.isDraft}
merged={issue.merged}
/>
</a>
</li>
Expand Down
11 changes: 6 additions & 5 deletions src/components/IssueListItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,24 @@ import React from "react";
import {FloatRight, FloatLeft, FlexColumn, FlexHeader, FlexCenter} from "../styles/Grid";
import {chevronRight} from "../icons";
import dayjs from "dayjs";
import CommitType from "../components/CommitType";
import relativeTime from "dayjs/plugin/relativeTime";
import {IssueOpenedIcon, CommentIcon, MilestoneIcon} from "@primer/octicons-react";
import {CommentIcon, MilestoneIcon} from "@primer/octicons-react";
import contrast from "contrast";
import {fontSize, size} from "../styles/variables";

dayjs.extend(relativeTime);

function IssueListItem({title, labels, author, opened, type, participants, comments, milestone}) {
function IssueListItem({title, labels, author, opened, type,
participants, comments, milestone, status, mergeable, isDraft, merged}) {
const participantsDiffCount = 3;
const participantsShowDiff = participants && participants.totalCount - participantsDiffCount;

return (
<FlexHeader>
<FloatLeft>
<FlexCenter>
<span style={{marginRight: 10}}>
<IssueOpenedIcon verticalAlign="middle" />
<span style={{marginRight: 10}} className="gitIcons">
<CommitType status={status} isDraft={isDraft} mergeable={mergeable} merged={merged} />
</span>
<FlexColumn className="details">
<p style={{fontSize: fontSize.default}}>
Expand Down
1 change: 1 addition & 0 deletions src/components/Issues.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ function Issues({repoName, owner}) {
participants={issue.node.participants}
comments={issue.node.comments}
milestone={issue.node.milestone}
status={issue.node.state}
/>
</a>
</li>
Expand Down
15 changes: 14 additions & 1 deletion src/styles/List.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,20 @@ const Container = styled.ul`
border: 1px solid ${colors.darkGrey};
}
}
.gitIcons {
.gitGreen {
fill: ${colors.gitGreen} !important;
}
.gitRed {
fill: ${colors.gitRed} !important;
}
.gitPurple {
fill: ${colors.gitPurple} !important;
}
.gitGrey {
fill: ${colors.gitGrey} !important;
}
}
.issueHelper {
color: grey;
margin-left: 3px;
Expand Down
6 changes: 5 additions & 1 deletion src/styles/variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ const colors = {
green: "#00c7b7",
darkGreen: "#03b1a3",
red: "#fb6d77",
darkRed: "#fa3946"
darkRed: "#fa3946",
gitGreen: "#3fb94f",
gitRed:"#eb4f47",
gitPurple:"#7e59c0",
gitGrey:"#8b949e",
};

const margin = {
Expand Down

0 comments on commit 0cc646a

Please sign in to comment.