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

goodnight

v0.2.0

Published

Apply CSS styles depending on date or time

Downloads

4

Readme

Goodnight

A super small Javascript plugin for applying special CSS styles at night.

Demo (night): https://jaredcubilla.github.io/goodnight/demo/ Demo (day): https://jaredcubilla.github.io/goodnight/demo/day.html

Usage

Download the goodnight.min.js file. Include it in your HTML

<script src="scripts/goodnight.min.js"></script>

Goodnight.css(path) adds a custom styles for you when it's nighttime.

You can add as many styles as you want, and the files will be added if it's nighttime.

Goodnight.css('path/to/style.css');
Goodnight.css('path/to/another.css');
Goodnight.css('path/to/night.css');

You can also specify the hours of which the dark styles are used. By default, your dark CSS file is activated from 6PM to midnight and midnight to 6AM, but you can specify the exact hours using the Goodnight.AM and Goodnight.PM variables. You should set the hours before adding any styles.

Goodnight.AM = 5 // (5AM)
Goodnight.PM = 20 // (8PM)
Goodnight.css('path/to/style.css') // this now activates dark styles before 5AM and after 8PM

If you want to provide easy way to revert back to light styles, you can call Goodnight.toggle(). For example you might create button for turning on and off these styles and call Goodnight.toggle() inside the event handler.

Goodnight.css('path/to/style.css');

document.querySelector('#some-button').addEventListener('click', function () {
  Goodnight.toggle(); // This removes styles from document.head
}, false);

You can also append a specific class to the body at night. Simply use Goodnight.class() (goodnight is given if not specified).

Goodnight.class('my-night-class');

Tips

If you leave this script at the bottom of the <body>, there will be a flash of daytime styles during nighttime, due to the browser processing the document until the script. It's best if you include the script in the <head>.

If you use Bower, it is available as a package there too. Run the following...

bower install goodnight

... and Goodnight should be installed as a bower package.

If you're too lazy to download it, you could always just do this:

<script src= "https://jaredcubilla.github.io/goodnight/goodnight.min.js"></script>

Contributing

If something's wrong or needs changing, feel free to leave issues at Github's issue tracker. If you're feeling generous, please send pull requests for fixing bugs or adding cool new stuff.

License

Licensed under MIT. Created by Jared Cubilla.