-
-
Notifications
You must be signed in to change notification settings - Fork 23.7k
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
feature(top langs card): add ability to change progress bar background color in normal layout (resolves #3307) #3312
base: master
Are you sure you want to change the base?
Changes from all commits
e291374
0eb16bd
6fcf07e
6c0cb91
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -143,7 +143,7 @@ Change the `?username=` value to your GitHub username. | |
> By default, the stats card only shows statistics like stars, commits and pull requests from public repositories. To show private statistics on the stats card, you should [deploy your own instance](#deploy-on-your-own) using your own GitHub API token. | ||
|
||
> [!NOTE]\ | ||
> Available ranks are S (top 1%), A+ (12.5%), A (25%), A- (37.5%), B+ (50%), B (62.5%), B- (75%), C+ (87.5%) and C (everyone). This ranking scheme is based on the [Japanese academic grading](https://wikipedia.org/wiki/Academic_grading_in_Japan) system. The global percentile is calculated as a weighted sum of percentiles for each statistic (number of commits, pull requests, reviews, issues, stars and followers), based on the cumulative distribution function of the [exponential](https://wikipedia.org/wiki/exponential_distribution) and the [log-normal](https://wikipedia.org/wiki/Log-normal_distribution) distributions. The implementation can be investigated at [src/calculateRank.js](./src/calculateRank.js). The circle around the rank shows 100 minus the global percentile. | ||
> Available ranks are S (top 1%), A+ (12.5%), A (25%), A- (37.5%), B+ (50%), B (62.5%), B- (75%), C+ (87.5%) and C (everyone). This ranking scheme is based on the [Japanese academic grading](https://wikipedia.org/wiki/Academic_grading_in_Japan) system. The global percentile is calculated as a weighted sum of percentiles for each statistic (number of commits, pull requests, reviews, issues, stars and followers), based on the cumulative distribution function of the [exponential](https://wikipedia.org/wiki/exponential_distribution) and the [log-normal](https://wikipedia.org/wiki/Log-normal_distribution) distributions. The implementation can be investigated at [src/calculateRank.js](https://github.com/anuraghazra/github-readme-stats/blob/master/src/calculateRank.js). The circle around the rank shows 100 minus the global percentile. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Your pull request should contain changes only related to linked issue, you should remove this. Instead of this you should add information about new query parameter into language card options section https://github.com/anuraghazra/github-readme-stats#language-card-exclusive-options. |
||
|
||
### Hiding individual stats | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -203,11 +203,19 @@ const trimTopLanguages = (topLangs, langs_count, hide) => { | |
* @param {number} props.width The card width | ||
* @param {string} props.color Color of the programming language. | ||
* @param {string} props.name Name of the programming language. | ||
* @param {string} props.prog_bg_color Color of the background of progress bar | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Type of this argument does not indicate that it can be |
||
* @param {number} props.progress Usage of the programming language in percentage. | ||
* @param {number} props.index Index of the programming language. | ||
* @returns {string} Programming language SVG node. | ||
*/ | ||
const createProgressTextNode = ({ width, color, name, progress, index }) => { | ||
const createProgressTextNode = ({ | ||
width, | ||
color, | ||
name, | ||
progress, | ||
index, | ||
prog_bg_color, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's better to use camel case for this function argument. |
||
}) => { | ||
const staggerDelay = (index + 3) * 150; | ||
const paddingRight = 95; | ||
const progressTextX = width - paddingRight + 10; | ||
|
@@ -223,7 +231,9 @@ const createProgressTextNode = ({ width, color, name, progress, index }) => { | |
color, | ||
width: progressWidth, | ||
progress, | ||
progressBarBackgroundColor: "#ddd", | ||
progressBarBackgroundColor: prog_bg_color | ||
? `#${prog_bg_color}` | ||
: "#ddd", | ||
delay: staggerDelay + 300, | ||
})} | ||
</g> | ||
|
@@ -322,9 +332,10 @@ const createDonutLanguagesNode = ({ langs, totalSize }) => { | |
* @param {Lang[]} langs Array of programming languages. | ||
* @param {number} width Card width. | ||
* @param {number} totalLanguageSize Total size of all languages. | ||
* @param {string} prog_bg_color Total size of all languages. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Description of this function argument was copy-pasted from previous. You should write correct description. Also type of argument does not indicate that it can be |
||
* @returns {string} Normal layout card SVG object. | ||
*/ | ||
const renderNormalLayout = (langs, width, totalLanguageSize) => { | ||
const renderNormalLayout = (langs, width, totalLanguageSize, prog_bg_color) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's better to use camel case for this function argument. |
||
return flexLayout({ | ||
items: langs.map((lang, index) => { | ||
return createProgressTextNode({ | ||
|
@@ -335,6 +346,7 @@ const renderNormalLayout = (langs, width, totalLanguageSize) => { | |
((lang.size / totalLanguageSize) * 100).toFixed(2), | ||
), | ||
index, | ||
prog_bg_color, | ||
}); | ||
}), | ||
gap: 40, | ||
|
@@ -738,8 +750,9 @@ const renderTopLanguages = (topLangs, options = {}) => { | |
border_radius, | ||
border_color, | ||
disable_animations, | ||
prog_bg_color, | ||
} = options; | ||
|
||
console.log(prog_bg_color); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This console log should be removed |
||
const i18n = new I18n({ | ||
locale, | ||
translations: langCardLocales, | ||
|
@@ -798,7 +811,12 @@ const renderTopLanguages = (topLangs, options = {}) => { | |
width = width + 50; // padding | ||
finalLayout = renderDonutLayout(langs, width, totalLanguageSize); | ||
} else { | ||
finalLayout = renderNormalLayout(langs, width, totalLanguageSize); | ||
finalLayout = renderNormalLayout( | ||
langs, | ||
width, | ||
totalLanguageSize, | ||
prog_bg_color, | ||
); | ||
} | ||
|
||
const card = new Card({ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ export type CommonOptions = { | |
icon_color: string; | ||
text_color: string; | ||
bg_color: string; | ||
prog_bg_color: string; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is wrong place for adding this parameter since it is exclusive for top languages card. It should be moved to |
||
theme: ThemeNames; | ||
border_radius: number; | ||
border_color: string; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's rename it to
progress_bar_bg_color
orprog_bar_bg_color
everywhere for consistency.