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 support for simple-icons, colored icons with ?logoColor #1810

Merged
merged 18 commits into from Aug 1, 2018

Conversation

RedSparr0w
Copy link
Member

@RedSparr0w RedSparr0w commented Jul 25, 2018

Add support for simple-icons.

Support more icons without the overhead of reviewing them ourselves.
I also added support for colored icons.

It will use our icon > simple-icon if available.

Examples:

params badge
?logo=github&style=social
?logo=github&logoColor=blue
?logo=react
?logo=microsoft%20excel
?logo=microsoft-excel
?logo=microsoft%20excel&logoColor=blue
?logo=apple
NOTE: Some badges wont look good with ?logoColor
?logo=npm
?logo=npm&logoColor=blue

the npm & bitcoin logos (maybe others also) will be completely filled in when you change the logo color due to the background being solid

TODO:

  • Add logoColor information
  • Add simple-icon information
  • Add snapshot tests

image

@shields-ci
Copy link

shields-ci commented Jul 25, 2018

Messages
📖

✨ Thanks for your contribution to Shields, @RedSparr0w!

📖

Thanks for contributing to our documentation. We ❤️ our documentarians!

Generated by 🚫 dangerJS

@paulmelnikow paulmelnikow added the core Server, BaseService, GitHub auth label Jul 25, 2018
Copy link
Member

@paulmelnikow paulmelnikow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really good!

We've just gotten a list of named logos into the frontend in #1794. Should we add a link to a versioned list of theirs? Or just display the complete list, including simple-icons?

It would also be good to get a static badge test that exercises this feature.

return color;
} else {
return undefined;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change related to simpleicons?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kind of, I wasn't sure whether to make a new function for the color or just modify this function as it seemed to still fit quite well, I think it makes more sense to only return a valid color rather than just assume anything that's not hex is a valid color/colorscheme, and the current test were expecting any non valid color to return undefined.

Also there wasn't any test for this function so i've added these too, which are very similar to setBadgeColor().

The main differences between setBadgeColor() and makeColor() are:

setBadgeColor():

will set the either badgeData.colorB or badgeData.colorscheme(which i think may be redundant now, but will look at that in another PR) to the desired color.

makeColor():

returns a valid color.

function makeLogo(defaultNamedLogo, overrides) {
if (overrides.logo === undefined){
return logos[defaultNamedLogo];
return logos[defaultNamedLogo] || getSimpleIcon(defaultNamedLogo, overrides.logoColor);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For parity, is it possible to support logoColor in our own logos?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be able to, Do you know if there is a reason that we load the logos into memory on launch?
(in load-logos.js)
As that is the main reason i haven't tried yet, because it loads them and keeps them as base64.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to be okay 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s a performance optimization, to load and encode them once instead of per request. We could cache the unencoded logos instead, or keep both in memory, as a small optimization for the cases where logoColor is not specified.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yeah that makes sense, should I also do the same for the simple-icons and store them as their own default colors?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, that couldn't hurt!

@RedSparr0w RedSparr0w changed the title Add support for simple-icons Add support for simple-icons, colored icons with ?logoColor Jul 26, 2018
@RedSparr0w
Copy link
Member Author

  • use the base64 logos from memory (ours & simple-icons),
  • Updated descriptions for ?logoColor= & ?logo= (see image in main comment)
  • Simple-icons by default use their own color instead of whitesmoke:
gitlab: E24329
react: 61DAFB
etc..
  • Updated main comment to show some examples.

If i could get another review please. @paulmelnikow
Note: Unsure what the best way to show the logo options was, let me know if you think it should be changed back/adjusted at all.
😄

update to 1.7.1
@paulmelnikow
Copy link
Member

I'd prefer to keep the list in the frontend so it stays in sync with the deployed code. Maybe the simplest thing would be to update lib/export-supported-features-cli.js so it includes both the simpleicons and internal icons.

What do you think about my suggestion to add a test that exercises the simple logo feature on a static badge? It could be a snapshot test. I don't want us to break this stuff by accident.

Otherwise this looks good to me!

@RedSparr0w
Copy link
Member Author

I'd prefer to keep the list in the frontend so it stays in sync with the deployed code. Maybe the simplest thing would be to update lib/export-supported-features-cli.js so it includes both the simpleicons and internal icons.

I think it may end up making it look a little too busy if we included the simple-icons in the list as its already quite large just with the icons we have, what about if we just have a link to simple icons at the end of our list?

What do you think about my suggestion to add a test that exercises the simple logo feature on a static badge? It could be a snapshot test. I don't want us to break this stuff by accident.

No worries, sounds like a good idea to me 👍

@paulmelnikow
Copy link
Member

what about if we just have a link to simple icons at the end of our list?

Works for me!

@RedSparr0w
Copy link
Member Author

RedSparr0w commented Jul 31, 2018

Added snapshot test for:

  • shields GitHub logo
  • shields GitHub logo w/custom color
  • simple-icons javascript logo
  • simple-icons javascript logo w/custom color

Should be ready for another review now @paulmelnikow
🤞

Edit:

w‮?tsil‭hat ‮ ruo ‭abo‮fo ‭ut if‮dne ‭ ‮eht t‭we‮a sno‭ j‮ci ‭ust h‮elpm‭ave‮is‭ ‮ ot‭a‮ kni‭ l

‭Also ‮.s‭up‮koo‭da‮l ti ‭te‮woh ‭d w‮fo ‭ith t‮elp‭hi‮max‭s ch‮e ht‭ang‮i‭e,‮w tn‭ an‮em‭d ‮m‭adde‮o‭d sc‮c ‭reen‮pot‭sho‮ ni ‭t

@paulmelnikow
Copy link
Member

?logo=microsoft%20excel

To make the URLs friendlier, what do you think about converting the spaces to dashes, similar to the way you've lowercased them?

@RedSparr0w
Copy link
Member Author

Sounds like a great idea, will definitely look cleaner.

@RedSparr0w
Copy link
Member Author

Now supports using a dash or space ?logo=microsoft%20excel or ?logo=microsoft-excel

@RedSparr0w RedSparr0w merged commit 317e19e into badges:master Aug 1, 2018
@shields-deployment
Copy link

This pull request was merged to master branch. Now this change is waiting for deployment.
Deploys usually happen every few weeks. After deployment changes are copied to gh-pages branch.

This badge displays deployment status:

@JeanMertz
Copy link

Pretty sweet that all those icons are now available 👍. One question; is it correct that not all icon colours can be manipulated for every possible badge? For example, the Linux or Arch Linux icons don't seem to change color when using a URL like this:

https://img.shields.io/circleci/project/github/rusty-rockets/sm/master.svg?style=flat-square&logo=linux&logoColor=white

While using the static image does work:

https://img.shields.io/badge/style-flat--square-green.svg?style=flat-square&logo=linux&logoColor=white

@chris48s
Copy link
Member

@JeanMertz - it isn't intentional. This issue has already been reported and fixed in #2059 . It hasn't been deployed yet, but it will be fixed when we next deploy. Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Server, BaseService, GitHub auth
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants