You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We provide a free-to-use API to retrieve icons for NPM packages. I think it'd be pretty cool if you integrated it with this project
The API is as simple as loading an image tag with
https://github-icons.com/npm/PACKAGE_NAME
for example https://github-icons.com/npm/react
This image can return a 404 if no icon is found. It can also take a while waiting for the GitHub API (second time is always instant), so on https://github-icons.com I do the following.
Render the <img> tag with opacity: 0, and object-fit: contain (so it retains aspect ratio)
Render a loading animation in the place of the icon, with position absolute
Attach an onLoad handler to the image, which removes the loading animation and unhides the icon
Attach an onError handler to the image which updates the src to either a generic npm logo or not found icon
The text was updated successfully, but these errors were encountered:
Yeah some icons could do with custom picked ones instead. I was testing the water as I hadn't seen any project that scraped github repo icons automatically before and thought it would be a good idea. Scraping has worked pretty well because if you search on github-icons.com for a repo / package, you're bound to find something related.
It's got some users now around 700 daily, but i'd like to see it grow.
Maybe I should add a curating / icon suggestion thing, instead of relying on package authors to manually set the "icon": "./icon.png" field in package json to use custom icons. I was picking between both ideas and thought it could be nicer to have a standard, but i guess some repos will never accept new contributions.
Regarding showing the user avatar on NPM icons, I did that as that's what github does on repos. I prioritise organization avatars over user ones, but maybe I should not display user ones at all when on an NPM package. Curious on your thoughts
Hi there 👋
I'm the creator of https://github-icons.com / https://github.com/samdenty/github-icons.
We provide a free-to-use API to retrieve icons for NPM packages. I think it'd be pretty cool if you integrated it with this project
The API is as simple as loading an image tag with
for example
https://github-icons.com/npm/react
This image can return a 404 if no icon is found. It can also take a while waiting for the GitHub API (second time is always instant), so on https://github-icons.com I do the following.
<img>
tag withopacity: 0
, andobject-fit: contain
(so it retains aspect ratio)src
to either a generic npm logo or not found iconThe text was updated successfully, but these errors were encountered: