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

traffic-control

v0.1.1

Published

Get a grip on staging

Downloads

9

Readme

traffic-control

:vertical_traffic_light: Get a grip on staging

Concept

This adds a bar to the top of a website hosted on Netlify that uses the Github and Netlify APIs to visually communicate information about the staging environment and allow one-click production deploys. Here are some mockups of the concept:

When staging is far beyond production When staging is in sync with production When staging has diverged behind production When the user is unauthorized to view changes or deploy

Installation

You can grab the code from NPM:

$ npm i traffic-control -S

Or from NPM CDN:

<script src="//npmcdn.com/[email protected]/dist/traffic-control.min.js"></script>

Usage

The easiest way to get set up is by doing the following:

First, load Netlify's OAuth helpers before your closing </body> (traffic-control will load this automatically if not present, but doing this will make it much faster):

<script src="https://app.netlify.com/authentication.js"></script>

And then load this script:

<script src="//npmcdn.com/[email protected]/dist/traffic-control.min.js"></script>

Then, simply initiate the trafficControl function:

trafficControl({
  repo: 'username/repo', // required. default is undefined.
  productionBranch: 'master', // required. default is 'master'
  stagingBranch: 'develop' // required. default is 'develop'
})

A good place to put it is on your staging site via Netlify's script injection feature:

The final step is to configure Github OAuth for your Netlify site. You can do that by following the instructions here: https://www.netlify.com/docs/authentication-providers

Goals

Eventually, I want to get rid of the dependency on Netlify and have this be its own Github integration. Keep eyes peeled!

Custom CSS

traffic-control's default styles are designed to have as little footprint as possible.

Using CSS, you can customize just about any element - simply use the ID #traffic-control as a namespace before every element.

#traffic-control .tc-bar { /* custom styles */ }

You can target specific states like so:

#traffic-control.is-mounted {}
#traffic-control.is-diverged {}
#traffic-control.is-ahead {}
#traffic-control.is-unauthorized {}
/* ...etc... */

Animations

traffic-control ships with a tiny keyframe-based animation engine.

If an element does not have an is-active class, it should be hidden from view.

When an element is about to be rendered, it will have an is-entering class. Similarly, when an element is about to be hidden, it will have an is-leaving class.

You can animate enter/leave states using CSS @keyframes:

#traffic-control .tc-bar.is-entering {
  animation: slideIn .6s ease;
}

@keyframes slideIn {
  from: {
    transform: translateY(100%);
  }
  to: {
    transform: translateY(0%);
  }
}

Animations are intelligent enough to detect the animationend event before triggering any new logic.

Note: animations are mandatory. Things will break if each element is not animated. This behavior is intentional and required to keep uniform behavior.