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

houdini-decorative-barcharts

v0.1.2

Published

An Eleventy environment for creating CSS Houdini worklets.

Downloads

13

Readme

Preview of generated bar charts, in shades of purple, blue, and seafoam with various numbers of bars

CSS Houdini Decorative Bar Charts

From Stephanie Eckles @5t3ph - author of ModernCSS.dev.

Generate dynamic decorative/placeholder bar charts using CSS Houdini. Intended to be an alternate to SVG icons or less flexible CSS gradient solutions.

The worklet will create randomized bar heights and compute bar widths and gap sizes relative to the number of bars requested vs. the width of the element. Since worklets update when the element is repainted, these values will resize alongside the element. The seed value ensures consistent results across repaints (prevents "flashing" effect on resize).

Important: Do not use these as a substitute for real bar charts because they will not provide any information to non-sighted or keyboard users unless you separately create text alternatives to describe the information. Plus, they are random which means you will not be able to match real data.

How to Use

While Houdini paint worklets have the best support out of available Houdini features, they still currently require a polyfill to ensure they are applied cross browser.

So, first include the following once in your project.

<script src="https://unpkg.com/css-paint-polyfill"></script>

Note: The polyfill will not work if the worklet is applied to pseudo elements.

Then, include the paint worklet script after the polyfill is loaded:

<script>
  CSS.paintWorklet.addModule("https://unpkg.com/houdini-decorative-barcharts");

  // Trickery to get the polyfill to draw the charts in Firefox and Safari
  setTimeout(() => {
    document.querySelector("ANCESTOR_ELEMENT").style.width = "100.01%";
    document.querySelector("ANCESTOR_ELEMENT").style.width = "100%";
  }, 500);
</script>

Finally, use it in your styles! For best results, assign as the background-image to a dedicated element to control the size used for the bar chart.

.barchart-element {
  /* Number of bars */
  --barchart-number: 5;
  /* Chart seed number - ensures chart variance */
  --barchart-seed: 22382;
  /* Option 1: Provide a CSS color */
  --barchart-color: purple;
  /* Option 2: Provide gradient start and end colors for a "to bottom" gradient */
  --barchart-start-color: hsl(260, 85%, 65%);
  --barchart-end-color: hsl(260, 85%, 35%);

  /* Use the worklet! */
  background: paint(houdiniBarCharts);
}

What is CSS Houdini?

Check out other Houdini paint worklets and more info at Houdini.How.