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

nightlight

v1.0.2

Published

Light- and dark-mode favicons, made easy.

Downloads

3

Readme

nightlight

Nightlight helps your favicon switch between light and dark mode.

Context

Browsers don't provide a native way to switch favicons between light and dark modes. Some people have started embedding media queries in SVGs, but low browser support for SVG favicons means you'll need a PNG or ICO fallback anyways. And even if SVGs did work, Safari complicates the situation by using rel="mask-icon" icons, which require color to be defined as an HTML attribute.

This package is a light, dependency-free snippet for switching your favicon based on CSS media queries.

Installation

npm install nightlight

Better yet, copy-and-paste the 20 lines behind this package into your site. Often times a little copy-and-pasting is better than a linked dependency.

Usage

Tag your favicon and mask-icons with data-dark-href and data-dark-color attributes:

<link rel="icon" type="image/png" href="/favicon.png" data-dark-href="/favicon-dark.png" />
<link rel="mask-icon" href="favicon-mask.svg" color="#212121" data-dark-color="#f2f2f2" />

Then, import this package from your bundle. No configuration needed. It'll run on import, updating your icon to match the users' current theme.

import "nightlight";

Browser Support

Nightlight supports every browser that supports the prefers-color-scheme media query (caniuse): Chrome 76+, Firefox 67+, Safari 12.1+, and Edge 79+. On browsers that don't, nightlight simply does nothing.

Unfortunately, Safari and IE don't allow dynamically changing favicons after page load. With Nightlight, they'll use the correct theme favicon on first load, but won't respond to theme changes after that.

License

MIT