Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add percentile rank icon and remove progress #2859

Merged
merged 5 commits into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"markdown.extension.toc.levels": "1..3",
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
6 changes: 5 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ You can provide multiple comma-separated values in the bg\_color option to rende
* `hide_title` - *(boolean)*. Default: `false`.
* `card_width` - Set the card's width manually *(number)*. Default: `500px (approx.)`.
* `hide_rank` - *(boolean)* hides the rank and automatically resizes the card width. Default: `false`.
* `rank_icon` - Shows alternative rank icon (i.e. `github`, `progress` or `default`). Default: `default`.
* `rank_icon` - Shows alternative rank icon (i.e. `github`, `percentile` or `progress`, `default`). Default: `default`.
* `show_icons` - *(boolean)*. Default: `false`.
* `include_all_commits` - Count total commits instead of just the current year commits *(boolean)*. Default: `false`.
* `line_height` - Sets the line height between text *(number)*. Default: `25`.
Expand Down Expand Up @@ -557,6 +557,10 @@ Change the `?username=` value to your [Wakatime](https://wakatime.com) username.

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

* Shows user rank percentile instead of rank level

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

* Customize Border Color

![Anurag's GitHub stats](https://github-readme-stats.vercel.app/api?username=anuraghazra\&border_color=2e4058)
Expand Down
2 changes: 1 addition & 1 deletion src/cards/stats-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ const renderStatsCard = (stats = {}, options = {}) => {
<circle class="rank-circle-rim" cx="-10" cy="8" r="40" />
<circle class="rank-circle" cx="-10" cy="8" r="40" />
<g class="rank-text">
${rankIcon(rank_icon, rank?.level, progress)}
${rankIcon(rank_icon, rank?.level, rank?.percentile)}
</g>
</g>`;

Expand Down
2 changes: 1 addition & 1 deletion src/cards/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
type ThemeNames = keyof typeof import("../../themes/index.js");
type RankIcon = "default" | "github" | "progress";
type RankIcon = "default" | "github" | "progress" | "percentile";

export type CommonOptions = {
title_color: string;
Expand Down
17 changes: 13 additions & 4 deletions src/common/icons.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion src/getStyles.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ const getStyles = ({
.rank-progress-text {
font-size: 16px;
}
.rank-percentile-header {
font-size: 16px;
}
.rank-percentile-text {
font-size: 16px;
}

.not_bold { font-weight: 400 }
.bold { font-weight: 700 }
Expand Down Expand Up @@ -130,4 +136,4 @@ const getStyles = ({
`;
};

export { getStyles, getAnimations };
export { getAnimations, getStyles };
12 changes: 12 additions & 0 deletions tests/__snapshots__/renderWakatimeCard.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ exports[`Test Render Wakatime Card should render correctly with compact layout 1
.rank-progress-text {
font-size: 16px;
}
.rank-percentile-header {
font-size: 16px;
}
.rank-percentile-text {
font-size: 16px;
}

.not_bold { font-weight: 400 }
.bold { font-weight: 700 }
Expand Down Expand Up @@ -228,6 +234,12 @@ exports[`Test Render Wakatime Card should render correctly with compact layout w
.rank-progress-text {
font-size: 16px;
}
.rank-percentile-header {
font-size: 16px;
}
.rank-percentile-text {
font-size: 16px;
}

.not_bold { font-weight: 400 }
.bold { font-weight: 700 }
Expand Down
14 changes: 14 additions & 0 deletions tests/renderStatsCard.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,4 +427,18 @@ describe("Test renderStatsCard", () => {
queryByTestId(document.body, "progress-rank-icon").textContent.trim(),
).toBe((100 - stats.rank.percentile).toFixed(1) + "%");
});

it("should show the rank percentile", () => {
document.body.innerHTML = renderStatsCard(stats, {
rank_icon: "percentile",
});
expect(queryByTestId(document.body, "percentile-top-header")).toBeDefined();
expect(
queryByTestId(document.body, "percentile-top-header").textContent.trim(),
).toBe("Top");
expect(queryByTestId(document.body, "rank-percentile-text")).toBeDefined();
expect(
queryByTestId(document.body, "percentile-rank-value").textContent.trim(),
).toBe(stats.rank.percentile.toFixed(1) + "%");
});
});