Skip to content

Integration with github-icons.com #28

@samdenty

Description

@samdenty

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

CleanShot 2022-12-24 at 19 54 41@2x

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.

  1. Render the <img> tag with opacity: 0, and object-fit: contain (so it retains aspect ratio)
  2. Render a loading animation in the place of the icon, with position absolute
  3. Attach an onLoad handler to the image, which removes the loading animation and unhides the icon
  4. Attach an onError handler to the image which updates the src to either a generic npm logo or not found icon

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or requestnode dependenciesIssues related to Node Dependencies extension

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions