npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@drawbotics/file-icons

v0.1.3

Published

Small icon library for file type icons

Downloads

1,701

Readme

File Icons

npm install @drawbotics/file-icons

A simple library to display icons depending on the file type. The library can be used both by importing the stylesheet (useful if you have a simple project without React dependencies), and also exports a React component.

DISCLAIMER In order to have a single div usage, and given the complexity of the icon look, a lot of CSS features that may not be compatible with older browsers is used. Namely linear-gradient, border-image and clip-path. Nonetheless, all the styles are prefixed.

Usage

There are two ways to use the icons: with a simple div or with a React component. Either way, you should include the stylesheet to have the icons style:

@import '~@drawbotics/file-icons/dist/style.css';

Pure CSS

You can use file-icons just by importing the css styling and using a div as a base element. Add the class file-icon to your div and set the file type as a data attribute data-file:

<div className="file-icon" data-file="docx" />

Note: The file extension needs to be in lower case.

You can also pass different class names for different sizes:

<div className="file-icon file-icon--medium" data-file="3ds" />
<div className="file-icon file-icon--large" data-file="rar" />

Example icons with default, medium and large sizing.

React

You can import the component anywhere in your code through:

import { FileIcon } from '@drawbotics/file-icons';

If you use CSSinJS then don't forget to include the stylesheet if you haven't already

import '@drawbotics/file-icons/dist/style.css';

And use it like such:

<FileIcon file="pdf" />

Here are the different options you can pass:

Prop | Type | Description | Possible values --- | --- | --- | --- file | String | File extension without the dot | .doc size | String | To toggle between the 3 sizes | medium, large filename | String | If you don't want to extract the extension yourself you can pass the filename directly | my-document.pdf

When using the React component you don't need to worry if the extension/filename is lowercase, the component takes care of that.

Supported file types

Any file extension that does not match the ones included with the library will fallback to the default grey color. Each category has its own color. The supported extension is a subset of the provided value, meaning that docx is supported since we look for doc.

Category | Possible values --- | --- Archives | zip, rar, tar, dmg, jar 3D Files | 3ds, dwg, obj, dae, skp, fbx Text Documents | doc, rtf, txt, odt, tex, Vector graphics | ai, svg PDF | pdf Data | xml, csv, xls Images | jpg, gif, png, jpeg, tif, psd, raw Video | webm, mkv, avi, mov, m4v, mpeg, mp4 Audio | mp3, m4a, ogg, acc, flac

If you want to add support for an extension, or support a new category of files don't hesitate to submit a PR. More extensions and categories will be added through time.

Develop

npm install

To run examples

npm run build:watch     # for build step
npm run example         # to serve examples

To build for production

npm run build

License

MIT. See LICENSE for details.