-
Notifications
You must be signed in to change notification settings - Fork 0
/
github_issues.jsx.sample
67 lines (61 loc) · 1.6 KB
/
github_issues.jsx.sample
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
// parameters
// personal access token of github.com
const token = "your personal access token";
// username of github.com
const user = "your username of github";
// repository name
const repo = "your repository";
// styles
export const className = `
position: fixed;
top: auto;
bottom: 20px;
left: 0px;
right: auto;
width: 250px;
text-align: left;
line-height: 1.1;
font-family: YuKyokasyo, Helvetica Neue;
font-weight: medium;
font-smoothing: antialiased;
font-size: 14px;
color: #ffffff;
text-shadow: 2px 2px 2px rgba(64, 64, 64, 0.8);
li {
color: #ffffff;
}
li span {
color: #ffffff;
}
`;
// refresh frequency
export const refreshFrequency = 3600000; // 1 hour
// command
// invoked every `refreshFrequency` milliseconds.
// the return value is passed to the `updateState` function.
export const command = `curl -s -u ${user}:${token} -H \"Accept: application/vnd.github.v3+json\" https://api.github.com/repos/${user}/${repo}/issues`;
// initialState
// SKIP
// updateState
// SKIP
// render
export const render = ({output}) => {
if (typeof output === "undefined") {
return (<div></div>);
}
var todos = [];
var issues = JSON.parse(output || "null");
if (issues == null) {
return (<div></div>);
}
issues.forEach(issue => {
var color = "#ffffff";
if (issue.labels.length > 0) {
color = `#${issue.labels[0].color}`;
}
todos.push(<li style={{color}}><span>{issue.title}</span></li>);
});
return (
<div><ul>{todos}</ul></div>
);
};