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

pbar

v1.0.4

Published

Tiny progress bar widget in css and js es5

Downloads

20

Readme

pbar

Tiny progress bar widget in css3 and js es6 / es2015. Designed for ease of use.

Add to your site with two lines of code:

ES5

<script defer src="pbar.es5.min.js" type="text/javascript"></script>
<script defer type="text/javascript">var pb = new require('pbar').pbar;</script>

ES6

<script defer src="pbar.js" type="text/javascript"></script>
<script defer type="text/javascript">import {pbar} from './pbar.js';</script>

No production dependencies, assets, globals, or primitive decoration. Source is 2.1k. Minified ES5 with require() packaging is 2.6k. Works in browsers, node, and embedded browsers.

You have control of color, background color and presence, location (defaults to fixed browser top,) animation transition, and many other things that most people won't actually care about in practice.

Ships with ES6 packaging, ES5 packaging that works in-browser and in-node, and minified ES5. (We're waiting on a closure compiler patch before es6 minification will work correctly.)

tl;dr

<!doctype html><html><head>

  <script defer src="../dist/pbar.es5.min.js" type="text/javascript"></script>
  <script type="text/javascript">

    var pbar, pb;
    var pb;

    window.onload = function() {                       // when the page loads
      pbar     = require('pbar').pbar;                 // load the library
      pb       = new pbar({color:'red', value:'0%'});  // make a new progress bar, initially red and empty
      pb.value = '20%';                                // immediately animate to 20%
    }

    window.setTimeout(function() {                     // when the timeout fires
      pb.color = '#aa0';                               // change the color to dark yellow
      pb.value = '80%';                                // set the value to 80%
    }, 2000);                                          // the timeout fires in two seconds

    window.setTimeout(function() {                     // when the timeout fires
      pb.color = 'green';                              // change the color to green
      pb.value = '100%';                               // set the value to 100%
    }, 4000);                                          // the timeout fires in four seconds

</script></head><body></body></html>

Options

pbar with no options, or with an empty object, is legal. pbar will ignore options it doesn't recognize.

pbar writes inline styles without quoting. Options are subject to injections. Do not use pbar with user generated content.

Options that pbar does recognize:

  • background is the value of the background property on the master frame tag. Default is transparent.
  • border is the value of the border property on the tag drawing the frame. Default is 0px solid transparent.
  • color is the value of the background property on the tag drawing the bar. Generally this will be a color, but this very easily could be an image, or whatever. Default is #40B3CC, a light blue.
  • height is the value of the height property of the frame tag. Default is '4px'. This is a CSS string, and therefore requires a unit unless 0.
  • value is the value of the width property of the bar tag. Normally this would be expressed as a percentage. Default is 50%, which is kind of trolly, but nice for newcomers.
  • target is the identity of the bar's host. Unlike most values, this isn't a CSS property. Instead, it's either a DOM reference like you'd get from document.getElementById(), or a string which will be looked up as an id by the library. If no target is given, document.body is assumed.
  • position is the position of the frame tag. Default is fixed if no target is given, or absolute if one is.
  • transition is the value of the transition property, but with the string 'width ' prepended to the front. Generally provide the time and/or the easing function in CSS format, such as '0.35s' or '0.5s easeOutSine'. Default is '0.35s'.

Polemic :neckbeard:

pbar is MIT licensed, because viral licenses and newspeak language modification are evil. Free is only free when it's free for everyone.