-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Conversation
Generated by 🚫 dangerJS |
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.
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; |
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.
Is this change related to simpleicons?
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.
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.
lib/badge-data.js
Outdated
function makeLogo(defaultNamedLogo, overrides) { | ||
if (overrides.logo === undefined){ | ||
return logos[defaultNamedLogo]; | ||
return logos[defaultNamedLogo] || getSimpleIcon(defaultNamedLogo, overrides.logoColor); |
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.
For parity, is it possible to support logoColor
in our own logos?
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.
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.
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.
Seems to be okay 👍
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.
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.
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.
Ah, yeah that makes sense, should I also do the same for the simple-icons
and store them as their own default colors?
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.
Sure, that couldn't hurt!
gitlab: E24329
react: 61DAFB
etc..
If i could get another review please. @paulmelnikow |
update to 1.7.1
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 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! |
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?
No worries, sounds like a good idea to me 👍 |
Works for me! |
Added snapshot test for:
Should be ready for another review now @paulmelnikow Edit:
Also .supkoodal ti tewoh d wfo ith telphimaxs che htangie,w tn anemd maddeod scc reenpotsho ni t |
To make the URLs friendlier, what do you think about converting the spaces to dashes, similar to the way you've lowercased them? |
Sounds like a great idea, will definitely look cleaner. |
Now supports using a dash or space |
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 While using the static image does work: |
@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 |
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:
?logo=github&style=social
?logo=github&logoColor=blue
?logo=react
?logo=microsoft%20excel
?logo=microsoft-excel
?logo=microsoft%20excel&logoColor=blue
?logo=apple
?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:
logoColor
informationsimple-icon
information