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

Fix #1170: Allow customizable width for GitHub Stats Card #1334

Merged

Conversation

postatum
Copy link
Contributor

Fixes #1170 by allowing customizable width for Github Stats Card.

To avoid things overlaping each other, Stats Card has minimum widths which are applied when provided custom_width is less than certain values.

@vercel
Copy link

vercel bot commented Sep 28, 2021

@postatum is attempting to deploy a commit to the github readme stats Team on Vercel.

A member of the Team first needs to authorize it.

@rickstaa
Copy link
Collaborator

rickstaa commented Nov 4, 2021

@postatum Thanks for your pull request. I quickly reviewed your code and it looks good to me. It however looks that the current code doesn't take into account the show_icons argument (see last example below). You might have to reload several times to see all the stats since Github will likely timeout trying to request so many stats at the same time.

hide_rank=true

Test without card_width

Rick Staa's GitHub stats

Test with to small card_width (i.e 50)

This card width is 220 px smaller than the minimum card width of 270 px.

Rick Staa's GitHub stats

Test with card_width 300

This card width is 30 px bigger than the minimum card width of 270.

Rick Staa's GitHub stats

Test with card_width 600

Rick Staa's GitHub stats

hide_rank=true, show_icons=true

Test without card_width

Rick Staa's GitHub stats

Test with to small card_width (i.e 50)

This card width is 220 px smaller than the minimum card width of 270 px.

Rick Staa's GitHub stats

Test with card_width 300

This card width is 30 px bigger than the minimum card width of 270.

Rick Staa's GitHub stats

Test with card_width 600

Rick Staa's GitHub stats

hide_rank=false

Test without card_width

Rick Staa's GitHub stats

Test with to small card_width (i.e 50)

This card width is 220 px smaller than the minimum card width of 270 px.

Rick Staa's GitHub stats

Test with card_width 300

This card width is 30 px bigger than the minimum card width of 270.

Rick Staa's GitHub stats

Test with card_width 600

Rick Staa's GitHub stats

hide_rank=false, show_icons=true

Test without card_width

Rick Staa's GitHub stats

Test with to small card_width (i.e 50)

This card width is 220 px smaller than the minimum card width of 270 px.

Rick Staa's GitHub stats

Test with card_width 300

This card width is 30 px bigger than the minimum card width of 270.

Rick Staa's GitHub stats

Test with card_width 600

Rick Staa's GitHub stats

@rickstaa
Copy link
Collaborator

rickstaa commented Nov 4, 2021

@postatum, please merge postatum#1 to fix the issues described above. It also trims trialling whitespace, but I can remove that if you want. After this pull request has been merged I will forward it to anuraghazra for review.

hide_rank=false, show_icons=true

Test without card_width

Rick Staa's GitHub stats

Test with to small card_width (i.e 50)

This card width is 220 px smaller than the minimum card width of 270 px.

Rick Staa's GitHub stats

Test with card_width 300

This card width is 30 px bigger than the minimum card width of 270.

Rick Staa's GitHub stats

Test with card_width 600

Rick Staa's GitHub stats

src/cards/stats-card.js Outdated Show resolved Hide resolved
src/cards/stats-card.js Outdated Show resolved Hide resolved
@anuraghazra
Copy link
Owner

anuraghazra commented Nov 4, 2021

This commit fixes a padding problem that was introduced in
f9c0e0b. In the new code, the padding
around the rank circle will be 50 when the stats card is bigger than
450. When it is smaller than 450 the left and right padding will shrink
equally.
@rickstaa
Copy link
Collaborator

rickstaa commented Nov 4, 2021

@anuraghazra You are right I missed that. This seems to be caused by the following code that was added by @postatum:

transform="translate(${width - 50}, ${height / 2 - 50})">

I added a fix for this to my pull request (see postatum@34d6423).

@rickstaa
Copy link
Collaborator

rickstaa commented Nov 4, 2021

Left: THIS PR https://github-readme-stats-git-testwidthfix2-rickstaa.vercel.app/api?username=anuraghazra&show_icons=true&hide_rank=false
Right: CURRENT https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&hide_rank=false

Anurag's github stats

Visual tests

hide_rank=false

Test without card_width

Without the card, width specified a card width of 495 will be used.

Test normal

Test with to small card_width (i.e 50)

This card width is 290 px smaller than the minimum card width of 340 px.

Test 50

Test with card_width 400

This card width is 60 px bigger smaller than the minimum card width of 340.

Test 400

Test with card_width 600

Test 600

hide_rank=false, show_icons=true

Test without card_width

Without the card, width specified a card width of 495 will be used.

Test normal -2

Test with to small card_width (i.e 50)

This card width is 290 px smaller than the minimum card width of 340 px.

Test 50 - 2

Test with card_width 400

This card width is 60 px bigger than the minimum card width of 340.

Test 400 - 2

Test with card_width 600

Test 600 - 2

@anuraghazra
Copy link
Owner

@postatum can you merge in the changes done by @rickstaa?

Also @rickstaa it's better to keep the PR waterfall minimal, try to code review the PR first instead of committing to the branch of Artem.

@rickstaa
Copy link
Collaborator

rickstaa commented Nov 6, 2021

@anuraghazra No problem, I will do that next time. I created the pull request to speed up the development process since it solves one of my problems.

…ation

fix: add icon width to stats-card min width calculation
@postatum
Copy link
Contributor Author

postatum commented Nov 8, 2021

Hi guys!

Thanks for reviewing this PR. Sorry, I didn't have time to merge your PR. I did it just now.

@rickstaa
Copy link
Collaborator

rickstaa commented Nov 8, 2021

@postatum No problem. Thanks again for creating this pull request!

tests/renderStatsCard.test.js Outdated Show resolved Hide resolved
src/cards/stats-card.js Show resolved Hide resolved
@douglasg14b
Copy link

Is this blocked by code review mostly?

@rickstaa
Copy link
Collaborator

rickstaa commented May 1, 2022

@douglasg14b Thanks for your interest in this feature. I already reviewed this PR some time ago. I, however, have to check it one last time. There are currently three things preventing this PR from being merged:

After these points are solved, this PR can be merged. However, I am very short on time since I'm in the final stage of my master's thesis. Therefore, I cannot make a promise when I have time to look at this PR again.

@codecov
Copy link

codecov bot commented Sep 16, 2022

Codecov Report

Base: 95.07% // Head: 95.13% // Increases project coverage by +0.06% 🎉

Coverage data is based on head (61e287b) compared to base (192170c).
Patch coverage: 100.00% of modified lines in pull request are covered.

❗ Current head 61e287b differs from pull request most recent head 247d1a3. Consider uploading reports for the commit 247d1a3 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1334      +/-   ##
==========================================
+ Coverage   95.07%   95.13%   +0.06%     
==========================================
  Files          22       22              
  Lines         771      781      +10     
  Branches      208      214       +6     
==========================================
+ Hits          733      743      +10     
  Misses         33       33              
  Partials        5        5              
Impacted Files Coverage Δ
api/index.js 90.47% <ø> (ø)
src/cards/stats-card.js 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

This commit makes sure we also test the stats card width for the case that the 'show_icons'
option is enabled.
@rickstaa rickstaa merged commit b0bb994 into anuraghazra:master Sep 16, 2022
@rickstaa
Copy link
Collaborator

rickstaa commented Sep 16, 2022

Just merged into the master. Sorry for the delay. @postatum Thanks a lot for implementing this feature 🚀.

infinity-plus pushed a commit to infinity-plus/github-readme-stats that referenced this pull request Sep 24, 2022
…nuraghazra#1334)

* Change default stats card width with hide rank

* Add tests for stats card with card_width

* Add card_width Stats Card description to readme

* fix: add icon width to stats-card min width calculation

* fix: fixes rank circle padding problem

This commit fixes a padding problem that was introduced in
f9c0e0b. In the new code, the padding
around the rank circle will be 50 when the stats card is bigger than
450. When it is smaller than 450 the left and right padding will shrink
equally.

* style: run prettier

* tests: add extra stats 'card_width' tests

This commit makes sure we also test the stats card width for the case that the 'show_icons'
option is enabled.

* style: run prettier

Co-authored-by: rickstaa <rick.staa@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add card_width for stats Card repo cards
4 participants