Skip to content

Commit 2642fc5

Browse files
rickstaaqwerty541
andauthored
add percentile rank icon (anuraghazra#2859)
* feat: add 'percentile' rank icon This commit adds the `percentile` option for the `rank_icon` query variable. This option displays the rank percentile the user belongs to. * style: improve percentile rank icon styling * dev * dev * dev --------- Co-authored-by: Alexandr <[email protected]>
1 parent de093e8 commit 2642fc5

File tree

8 files changed

+39
-19
lines changed

8 files changed

+39
-19
lines changed

Diff for: .vscode/settings.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"markdown.extension.toc.levels": "1..3",
33
"editor.formatOnSave": true,
4-
"editor.defaultFormatter": "esbenp.prettier-vscode",
4+
"editor.defaultFormatter": "esbenp.prettier-vscode"
55
}

Diff for: readme.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ You can provide multiple comma-separated values in the bg\_color option to rende
304304
* `hide_title` - *(boolean)*. Default: `false`.
305305
* `card_width` - Set the card's width manually *(number)*. Default: `500px (approx.)`.
306306
* `hide_rank` - *(boolean)* hides the rank and automatically resizes the card width. Default: `false`.
307-
* `rank_icon` - Shows alternative rank icon (i.e. `github`, `progress` or `default`). Default: `default`.
307+
* `rank_icon` - Shows alternative rank icon (i.e. `github`, `percentile` or `default`). Default: `default`.
308308
* `show_icons` - *(boolean)*. Default: `false`.
309309
* `include_all_commits` - Count total commits instead of just the current year commits *(boolean)*. Default: `false`.
310310
* `line_height` - Sets the line height between text *(number)*. Default: `25`.
@@ -557,6 +557,10 @@ Change the `?username=` value to your [Wakatime](https://wakatime.com) username.
557557

558558
![Anurag's GitHub stats](https://github-readme-stats.vercel.app/api?username=anuraghazra\&rank_icon=progress)
559559

560+
* Shows user rank percentile instead of rank level
561+
562+
![Anurag's GitHub stats](https://github-readme-stats.vercel.app/api?username=anuraghazra\&rank_icon=percentile)
563+
560564
* Customize Border Color
561565

562566
![Anurag's GitHub stats](https://github-readme-stats.vercel.app/api?username=anuraghazra\&border_color=2e4058)

Diff for: src/cards/stats-card.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ const renderStatsCard = (stats = {}, options = {}) => {
328328
<circle class="rank-circle-rim" cx="-10" cy="8" r="40" />
329329
<circle class="rank-circle" cx="-10" cy="8" r="40" />
330330
<g class="rank-text">
331-
${rankIcon(rank_icon, rank?.level, progress)}
331+
${rankIcon(rank_icon, rank?.level, rank?.percentile)}
332332
</g>
333333
</g>`;
334334

Diff for: src/cards/types.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
type ThemeNames = keyof typeof import("../../themes/index.js");
2-
type RankIcon = "default" | "github" | "progress";
2+
type RankIcon = "default" | "github" | "percentile";
33

44
export type CommonOptions = {
55
title_color: string;

Diff for: src/common/icons.js

+9-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: src/getStyles.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ const getStyles = ({
9898
font: 800 24px 'Segoe UI', Ubuntu, Sans-Serif; fill: ${textColor};
9999
animation: scaleInAnimation 0.3s ease-in-out forwards;
100100
}
101-
.rank-progress-text {
101+
.rank-percentile-header {
102+
font-size: 14px;
103+
}
104+
.rank-percentile-text {
102105
font-size: 16px;
103106
}
104107
@@ -130,4 +133,4 @@ const getStyles = ({
130133
`;
131134
};
132135

133-
export { getStyles, getAnimations };
136+
export { getAnimations, getStyles };

Diff for: tests/__snapshots__/renderWakatimeCard.test.js.snap

+8-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ exports[`Test Render Wakatime Card should render correctly with compact layout 1
4242
font: 800 24px 'Segoe UI', Ubuntu, Sans-Serif; fill: #434d58;
4343
animation: scaleInAnimation 0.3s ease-in-out forwards;
4444
}
45-
.rank-progress-text {
45+
.rank-percentile-header {
46+
font-size: 14px;
47+
}
48+
.rank-percentile-text {
4649
font-size: 16px;
4750
}
4851
@@ -225,7 +228,10 @@ exports[`Test Render Wakatime Card should render correctly with compact layout w
225228
font: 800 24px 'Segoe UI', Ubuntu, Sans-Serif; fill: #434d58;
226229
animation: scaleInAnimation 0.3s ease-in-out forwards;
227230
}
228-
.rank-progress-text {
231+
.rank-percentile-header {
232+
font-size: 14px;
233+
}
234+
.rank-percentile-text {
229235
font-size: 16px;
230236
}
231237

Diff for: tests/renderStatsCard.test.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -418,13 +418,17 @@ describe("Test renderStatsCard", () => {
418418
expect(queryByTestId(document.body, "github-rank-icon")).toBeDefined();
419419
});
420420

421-
it("should show the progress", () => {
421+
it("should show the rank percentile", () => {
422422
document.body.innerHTML = renderStatsCard(stats, {
423-
rank_icon: "progress",
423+
rank_icon: "percentile",
424424
});
425-
expect(queryByTestId(document.body, "rank-progress-text")).toBeDefined();
425+
expect(queryByTestId(document.body, "percentile-top-header")).toBeDefined();
426426
expect(
427-
queryByTestId(document.body, "progress-rank-icon").textContent.trim(),
428-
).toBe((100 - stats.rank.percentile).toFixed(1) + "%");
427+
queryByTestId(document.body, "percentile-top-header").textContent.trim(),
428+
).toBe("Top");
429+
expect(queryByTestId(document.body, "rank-percentile-text")).toBeDefined();
430+
expect(
431+
queryByTestId(document.body, "percentile-rank-value").textContent.trim(),
432+
).toBe(stats.rank.percentile.toFixed(1) + "%");
429433
});
430434
});

0 commit comments

Comments
 (0)