Skip to content

Commit 9478612

Browse files
gregorysldillionverma
authored andcommitted
Add icons to issues (#25)
* Add icons to issue * Added Icon component to show all types of issue * Added colors to icons, and move styles to different file * apply icon styles * move Icon to components
1 parent 89e022c commit 9478612

5 files changed

Lines changed: 55 additions & 2 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
6+
"@githubprimer/octicons-react": "^8.1.0",
67
"axios": "^0.18.0",
78
"i": "^0.3.6",
89
"node-sass": "^4.9.3",

src/features/Issues/Issues.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ import "./Issues.scss";
33
import { Link } from "react-router-dom";
44
import { connect } from "react-redux";
55
import { getIssues, filterIssues } from "./actions";
6+
import Icon from "../Icon/Icon";
67

78
const maxLength = 50;
89

9-
const Card = ({ title, body, labels, issueUrl, owner, repo, number }) => (
10+
const Card = ({ title, body, labels, issueUrl, owner, repo, number, state, pull_request }) => (
1011
<div className="card" onClick={() => issueUrl(owner, repo, number)}>
1112
<div className="card-title">
12-
<h4>{title}</h4>
13+
<Icon state={state} pull={pull_request} />
14+
<h4 className={"card-title-text"}>{title}</h4>
1315
</div>
1416
<div className="card-body">
1517
<div>
@@ -129,6 +131,8 @@ class Issues extends Component {
129131
owner={owner}
130132
repo={repo}
131133
number={issue.number}
134+
state={issue.state}
135+
pull_request={issue.pull_request}
132136
/>
133137
))}
134138
</div>

src/features/Issues/Issues.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ button#return-button a {
121121
padding: 20px;
122122
font-size: 12px;
123123
}
124+
.card-title-text {
125+
display: contents;
126+
}
124127
.card-labels > ul {
125128
list-style-type: none;
126129
padding: 15px;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import React from "react";
2+
import "./Icon.scss";
3+
import Octicon, { getIconByName } from "@githubprimer/octicons-react";
4+
5+
const Icon = ({ state, pull }) => {
6+
let icon = "";
7+
let color = "";
8+
if (state === "open") {
9+
if (pull) {
10+
icon = "git-pull-request";
11+
} else {
12+
icon = "issue-opened";
13+
}
14+
color = "green";
15+
} else {
16+
if (pull) {
17+
icon = "git-merge";
18+
color = "purple";
19+
} else {
20+
icon = "issue-closed";
21+
color = "red";
22+
}
23+
}
24+
return (
25+
<Octicon
26+
size={"medium"}
27+
className={`card-icon ${color}`}
28+
icon={getIconByName(icon)}
29+
/>
30+
);
31+
};
32+
33+
export default Icon;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.card-icon {
2+
margin: 3px;
3+
&.green {
4+
color: #28a745;
5+
}
6+
&.red {
7+
color: #cb2431;
8+
}
9+
&.purple {
10+
color: #6f42c1;
11+
}
12+
}

0 commit comments

Comments
 (0)