Skip to content

Commit 42d5cbc

Browse files
committed
Use GitHub's own Octicons for the sidebar status icons
Replace the Font Awesome approximations with the official issue-opened, issue-closed and skip Octicons (MIT, primer/octicons), embedded inline as SVG with GitHub's exact colors.
1 parent 82e331c commit 42d5cbc

2 files changed

Lines changed: 47 additions & 11 deletions

File tree

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nodebb-plugin-github-issue",
3-
"version": "1.4.0",
3+
"version": "1.4.1",
44
"description": "Adds a post-menu button that opens a GitHub issue from the post content, with a write-only token, token expiry tracking and admin notifications",
55
"main": "library.js",
66
"license": "MIT",

‎static/lib/client.js‎

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,55 @@ $(document).ready(function () {
6060
});
6161
}
6262

63-
// mirrors GitHub's own issue icons: green open circle, purple check for
64-
// closed-as-completed, grey slashed circle for closed-as-not-planned
63+
// GitHub's own issue icons (Octicons, MIT licensed: primer/octicons),
64+
// embedded inline so no external assets are loaded
65+
const OCTICONS = {
66+
open: {
67+
color: '#1a7f37',
68+
paths: [
69+
'M8 9.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z',
70+
'M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Z',
71+
],
72+
},
73+
closed: {
74+
color: '#8250df',
75+
paths: [
76+
'M11.28 6.78a.75.75 0 0 0-1.06-1.06L7.25 8.69 5.78 7.22a.75.75 0 0 0-1.06 1.06l2 2a.75.75 0 0 0 1.06 0l3.5-3.5Z',
77+
'M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0Zm-1.5 0a6.5 6.5 0 1 0-13 0 6.5 6.5 0 0 0 13 0Z',
78+
],
79+
},
80+
notPlanned: {
81+
color: '#59636e',
82+
paths: [
83+
'M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm9.78-2.22-5.5 5.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734l5.5-5.5a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042Z',
84+
],
85+
},
86+
};
87+
6588
function buildStateIcon(issue, stateLabels) {
89+
let icon;
90+
let label;
6691
if (issue.state === 'open') {
67-
return $('<i class="fa fa-circle-dot me-1" style="color: #1a7f37;"></i>').attr('title', stateLabels.open);
68-
}
69-
if (issue.state === 'closed') {
70-
if (issue.stateReason === 'not_planned') {
71-
return $('<i class="fa fa-ban me-1 text-muted"></i>').attr('title', stateLabels.not_planned);
72-
}
73-
return $('<i class="fa fa-circle-check me-1" style="color: #8250df;"></i>').attr('title', stateLabels.closed);
92+
icon = OCTICONS.open;
93+
label = stateLabels.open;
94+
} else if (issue.state === 'closed' && issue.stateReason === 'not_planned') {
95+
icon = OCTICONS.notPlanned;
96+
label = stateLabels.not_planned;
97+
} else if (issue.state === 'closed') {
98+
icon = OCTICONS.closed;
99+
label = stateLabels.closed;
100+
} else {
101+
return null;
74102
}
75-
return null;
103+
const svg = '<svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true" fill="currentColor" style="vertical-align: -0.125em;">' +
104+
icon.paths.map(function (d) {
105+
return '<path d="' + d + '"></path>';
106+
}).join('') +
107+
'</svg>';
108+
return $('<span class="me-1"></span>')
109+
.css('color', icon.color)
110+
.attr('title', label)
111+
.append($(svg));
76112
}
77113

78114
function placePanel(panel) {

0 commit comments

Comments
 (0)