Skip to content

Commit

Permalink
feat: add color to scorecard menu
Browse files Browse the repository at this point in the history
  • Loading branch information
fraxken committed Nov 25, 2023
1 parent dbbd43e commit 94ec2ca
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
17 changes: 17 additions & 0 deletions public/css/components/package/navigation.css
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,20 @@ section#package-info>.package-navigation>div>.signal {
section#package-info>.package-navigation>div#scorecard-menu {
display: none;
}

section#package-info>.package-navigation>div#scorecard-menu.red {
border: 2px solid #EF5350;
color: #FF80AB;
}
section#package-info>.package-navigation>div#scorecard-menu.orange {
border: 2px solid #FDD835;
color: #FFD740;
}
section#package-info>.package-navigation>div#scorecard-menu.blue {
border: 2px solid #2962FF;
color: #BBDEFB;
}
section#package-info>.package-navigation>div#scorecard-menu.green {
border: 2px solid #00E676;
color: #B2FF59;
}
17 changes: 17 additions & 0 deletions public/js/components/package/pannels/scorecard.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,20 @@ export class Scorecard {
});
}

getScoreColor(score) {
if (score < 4) {
return "red";
}
if (score < 6.5) {
return "orange";
}
if (score < 8.5) {
return "blue";
}

return "green";
}

renderScorecard(data, repoName) {
const { score, checks } = data;

Expand All @@ -74,6 +88,9 @@ export class Scorecard {
}

document.getElementById('ossf-score').innerText = score;
document.getElementById('scorecard-menu').classList.add(
this.getScoreColor(score)
);
document.getElementById('head-score').innerText = score;
document
.querySelector(".score-header .visualizer a")
Expand Down
6 changes: 5 additions & 1 deletion src/http-server/endpoints/ossf-scorecard.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ export async function get(req, res) {
}

catch (error) {
return send(res, error.statusCode ?? 404, { error: error.statusMessage ?? "Not Found" });
return send(
res,
error.statusCode ?? 404,
{ error: error.statusMessage ?? "Not Found" }
);
}
}

0 comments on commit 94ec2ca

Please sign in to comment.