anuraghazra / github-readme-stats

:zap: Dynamically generated stats for your github readmes
https://github-readme-stats.vercel.app
MIT License
69.6k stars 23.06k forks source link

Top Languages Card API option for not display numbers #1708

Open altherlex opened 2 years ago

altherlex commented 2 years ago

Top Languages Card API option for not displaying numbers

RedHeadphone commented 2 years ago

Can I work on it? Also why is this done https://github.com/anuraghazra/github-readme-stats/blob/master/src/cards/top-languages-card.js#L170 ?

rickstaa commented 2 years ago

@RedHeadphone I am not 100% sure if I understand the feature request of @altherlex, but I guess it is about removing the percentages on the card. Feel free to create a PR for this option, and I will review it! I can not promise that it will be merged into the master shortly since #1708 doesn't have many upvotes.

https://github.com/anuraghazra/github-readme-stats/blob/54cc2919781cc96c5e728670c70444b6591120be/src/cards/top-languages-card.js#L170

This is done to make the progress item the correct width when a language percentage is below 10 -> 0.1. The variable naming is a bit unfortunate.

RedHeadphone commented 2 years ago

How is that correcting width? instead it is increasing size from it's original value. It is not done in normal form, only in compact form.

rickstaa commented 2 years ago

@RedHeadphone I haven't worked on the language card in a while, and that code was written by @anuraghazra, but here are my 2 cents. I think the compact card function code ensures that language results can be stacked next to each other. The maximum percentage we can get is 100% which is three characters. In this case, in the compact card, you will only have one item, so you don't need to worry about stacking items next to each other. When you have two items, items will be stacked. In most cases, you will have two characters for the percentages (e.g. 50%/50%). This is what the offset width represents. When an item is lower than 10%, however, you only have one character before the dot, and you, therefore, have to add 10px to align the items on the second column. You can check out how these widths work by inspecting https://github-readme-stats.vercel.app/api/top-langs/?username=anuraghazra&layout=compact using the chrome devTools.

image

RedHeadphone commented 2 years ago

but that progress variable isn't used for character offset, it is used for progress bar rect. To me that logic seems to be unnecessary.

with that logic image image

without that logic image image

Edit: Only possible reason I can think of why it was added is that low width rect are not rendered at all, to compensate that extra width is given which makes rect render

rickstaa commented 2 years ago

but that progress variable isn't used for character offset, it is used for progress bar rect. To me that logic seems to be unnecessary.

with that logic image image

without that logic image image

Edit: Only possible reason I can think of why it was added is that low width rect are not rendered at all, to compensate that extra width is given which makes rect render

I just checked the code on my laptop, and I think your conclusion is correct. The createLanguageTextNode function is responsible for the card item generation, while the code you showed creates the progress bar. @anuraghazra do you clamp the progress of languages at 10% to keep them from disappearing on the card? Maybe let's add a short comment explaining the behaviour.

RedHeadphone commented 2 years ago

even I don't feel that this option will be used much, If anyone else wants to do this, go ahead!

HemanthPaila commented 1 year ago

Hey @altherlex can I work on it? Could you please assign it to me?

az3vedo commented 1 year ago

Hey, is there any updates on this issue? I have interest to work on it

rickstaa commented 1 year ago

@az3vedo As I have yet to receive a PR of @HemanthPaila feel free to work on it. I just assigned you 👍🏻.

az3vedo commented 1 year ago

@rickstaa I'm quite confuse, there is an option on top-langs route called hide_progress that already hide the numbers url example: https://github-readme-stats-fzcliha4u-az3vedo.vercel.app/api/top-langs?username=az3vedo&language=true&layout=compact&hide_progress=true

2023-10-15_14-31

if I understood the discussion above along with the sugestion of @altherlex, we should add a option to show the progress bar but hiding the percentage numbers, right?

rickstaa commented 1 year ago

@rickstaa I'm quite confuse, there is an option on top-langs route called hide_progress that already hide the numbers url example: https://github-readme-stats-fzcliha4u-az3vedo.vercel.app/api/top-langs?username=az3vedo&language=true&layout=compact&hide_progress=true

2023-10-15_14-31

if I understood the discussion above along with the sugestion of @altherlex, we should add a option to show the progress bar but hiding the percentage numbers, right?

@az3vedo I'm not 100% sure I was unaware of the hide_progress parameter myself 👍🏻. Maybe @altherlex can elaborate 🤔.