Skip to content

Commit 3ffd7c7

Browse files
committed
base
1 parent 7b86b7d commit 3ffd7c7

File tree

4 files changed

+128
-8
lines changed

4 files changed

+128
-8
lines changed

src/GitHub/GitHub.css

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
.GitHub .select-group {
2+
margin-bottom: 1rem;
3+
}
4+
5+
.GitHub .labels .label-item {
6+
text-align: left;
7+
text-overflow: ellipsis;
8+
white-space: nowrap;
9+
overflow: hidden;
10+
width: 100%;
11+
}
12+
13+
.GitHub .Select-control {
14+
height: 2.5rem
15+
}
16+
17+
.GitHub .btn-apply-labels {
18+
width: 100%;
19+
}
20+
21+
@media (max-width: 768px) {
22+
.GitHub .btn-apply-labels {
23+
margin: 1rem 0;
24+
}
25+
}
26+
27+
.GitHub .labels .label-item [type=checkbox] {
28+
margin: .5rem;
29+
display: inline-block;
30+
}

src/GitHub/GitHub.js

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import Loading from '../Components/Loading';
33
import { withGithubRepositories } from './withGitHubRepositories';
44
import Select from 'react-select';
55
import 'react-select/dist/react-select.css';
6+
import LABELS_TO_ADD from '../Labels';
7+
import invertColor from '../invertColor';
8+
import './GitHub.css';
69

710
class GitHub extends React.Component {
811

@@ -29,14 +32,33 @@ class GitHub extends React.Component {
2932
</section>
3033
:
3134
<section>
32-
<Select
33-
value={selectedOption}
34-
onChange={(e) => this.handleSelect(e)}
35-
options={repositories.map(r => Object.assign(r, {
36-
value: r.full_name,
37-
label: r.full_name,
38-
}))}
39-
/>
35+
<div className="row select-group">
36+
<div className="col-md-10">
37+
<Select
38+
value={selectedOption}
39+
onChange={(e) => this.handleSelect(e)}
40+
options={repositories.map(r => Object.assign(r, {
41+
value: r.full_name,
42+
label: r.full_name,
43+
}))}
44+
/>
45+
</div>
46+
<div className="col-md-2">
47+
<button className="btn btn-apply-labels btn-primary">Apply</button>
48+
</div>
49+
</div>
50+
<div className="row labels">
51+
{LABELS_TO_ADD.map(({ name, color }) => (
52+
<div key={name} className="col-md-4">
53+
<label alt={name} className="label-item"
54+
style={{ backgroundColor: '#' + color, color: invertColor('#' + color, true) }}
55+
>
56+
<input disabled type="checkbox" />
57+
{name}
58+
</label>
59+
</div>
60+
))}
61+
</div>
4062
</section>
4163
}
4264
</div>

src/Labels.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
const LABELS_TO_ADD = [
2+
{ name: 'Priority: Highest', color: 'b60205', priority: 1 },
3+
{ name: 'Priority: High', color: 'fef2c0', priority: 2 },
4+
{ name: 'Priority: Medium', color: 'd4c5f9', priority: 3 },
5+
{ name: 'Priority: Low', color: 'd4c5f9', priority: 4 },
6+
{ name: 'Priority: Lowest', color: 'ededed', priority: 5 },
7+
{ name: 'Category: Backend', color: 'c2e0c6', priority: null },
8+
{ name: 'Category: Business/Meetings', color: '0e8a16', priority: null },
9+
{ name: 'Category: DevOps', color: 'fef2c0', priority: null },
10+
{ name: 'Category: Frontend', color: 'bfdadc', priority: null },
11+
{ name: 'Category: Infrastructure', color: 'f0e68c', priority: null },
12+
{ name: 'Category: Report', color: '40e0d0', priority: null },
13+
{ name: 'Category: Unit test', color: 'ededed', priority: null },
14+
{ name: 'Level: Easy', color: '48d1cc', priority: null },
15+
{ name: 'Level: Medium', color: '20b2aa', priority: null },
16+
{ name: 'Level: Hard', color: '008b8b', priority: null },
17+
{ name: 'Stage: Analysis', color: 'e6e6e6', priority: null },
18+
{ name: 'Stage: Backlog', color: 'ededed', priority: null },
19+
{ name: 'Stage: Cancelled', color: '000000', priority: null },
20+
{ name: 'Stage: In progress', color: 'fbca04', priority: null },
21+
{ name: 'Stage: Review', color: '0052cc', priority: null },
22+
{ name: 'Stage: Testing', color: 'e616e6', priority: null },
23+
{ name: 'Status: Blocked', color: 'd93f0b', priority: null },
24+
{ name: 'Status: Duplicated', color: 'c5def5', priority: null },
25+
{ name: 'Status: Impediment', color: 'b60205', priority: null },
26+
{ name: 'Status: Needs Fixing', color: 'ff8c00', priority: null },
27+
{ name: 'Type: Bug', color: 'fc2929', priority: null },
28+
{ name: 'Type: Improvement', color: '84b6eb', priority: null },
29+
{ name: 'Type: New feature', color: '0052cc', priority: null },
30+
{ name: 'Type: Sub-task', color: 'ededed', priority: null },
31+
];
32+
33+
export default LABELS_TO_ADD;

src/invertColor.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
const padZero = (str, len) => {
2+
len = len || 2;
3+
var zeros = new Array(len).join('0');
4+
return (zeros + str).slice(-len);
5+
}
6+
7+
const invertColor = (hex, bw) => {
8+
if (hex.indexOf('#') === 0) {
9+
hex = hex.slice(1);
10+
}
11+
// convert 3-digit hex to 6-digits.
12+
if (hex.length === 3) {
13+
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
14+
}
15+
if (hex.length !== 6) {
16+
throw new Error(`Invalid HEX color: ${hex}.`);
17+
}
18+
var r = parseInt(hex.slice(0, 2), 16),
19+
g = parseInt(hex.slice(2, 4), 16),
20+
b = parseInt(hex.slice(4, 6), 16);
21+
if (bw) {
22+
// http://stackoverflow.com/a/3943023/112731
23+
return (r * 0.299 + g * 0.587 + b * 0.114) > 186
24+
? '#000000'
25+
: '#FFFFFF';
26+
}
27+
// invert color components
28+
r = (255 - r).toString(16);
29+
g = (255 - g).toString(16);
30+
b = (255 - b).toString(16);
31+
// pad each with zeros and return
32+
return "#" + padZero(r) + padZero(g) + padZero(b);
33+
}
34+
35+
export default invertColor

0 commit comments

Comments
 (0)