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

fluid-meter

v1.1.2

Published

a dependency free library that draws a circular meter where progress is displayed as the amount of liquid on it

Downloads

357

Readme

Fluid Meter

Dependency free library to represent progress as the amount of fluid in a container.

Demo

https://aarcoraci.github.io/fluid-meter/

Installation

npm i fluid-meter

Usage

The library is higlhly customizable but it can be easily initialized. It requires a DOM container with a setted width and height (inline or css).

<div id="target" style="width:500px;height:500px"></div>
import { CircularFluidMeter } from 'fluid-meter';

const target = document.querySelector('#target');
new CircularFluidMeter(target, {
  initialProgress: 33
});

Bundled version

A new bundled version has been added. It can be accessed via the IIFE on the global scope.

1 - Add the bundle file to your project (can be found as bundle.js in the /dist directory):

<!-- make sure the path is correct -->
<script src="dist/bundle.js"></script>

2 - Access via the IIFE on the global scope (named cfmModule):

const target = document.querySelector("#target");
new cfmModule.CircularFluidMeter(target, {
  initialProgress: 33,
});

Responsiveness

The library is prepared to work on a responsive scenario if needed via the BreakpointValueConfig:

const config = {
  initialProgress: 75,
  borderWidth: [
    {
      resolution: 0,
      value: 15
    },
    {
      resolution: 1024,
      value: 60
    }
  ],
  fontSize: [
    {
      resolution: 0,
      value: 25
    },
    {
      resolution: 768,
      value: 50
    }
  ]
};

See the supported responsive values on the Configuration table

Configuration

Here are some examples on how to use it. It's with typescript but should be the same with plain javascript. https://github.com/aarcoraci/fluid-meter/blob/main/src/main.ts

| option | type | default | info | | ------------------ | ------------------------------- | ------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ | | initialProgress | number | 0 | initial progress to show | | maxProgress | number | 100 | max progress of the meter | | borderWidth | number or BreakpointValueConfig | 30 | border width. Can be a number or an array of breakpoint value configs | | borderColor | string | #75758b | color of the outer border. | | padding | number | 30 | space between the boundaries of the container and the meter. Usefull if drop shadow is enabled | | backgroundColor | string | #9f9fae | meter background color | | showProgress | boolean | true | displays or not the center text | | showBubbles | boolean | true | displays or not the bubbles | | bubbleColor | string | #ffffff | color of the bubbles | | textColor | string | #ffffff | text color | | textDropShadow | boolean | true | text has a small shadow. Helps when colors are too similar or on difficult contrasting scenarios | | textShadowOpacity | number | 1 | intensity of the shadow between 0 and 1: 0 invisible and 1 fully visible | | textShadowColor | string | #000000 | text shadow color | | fontFamily | string | Arial | name of the typeface to use | | fontSize | number or BreakpointValueConfig | 30 | tex size. Can be a number of an array of breakpoint value configs | | use3D | boolean | true | enables details that gives the impresion of depth | | dropShadow | boolean | true | meter drops shadow. Requires some padding to show correctly | | dropShadowColor | string | #000000 | meter shadow color | | progressFormatter | (value: number) => string | (value: number) => Math.round(value).toString() | a function that transforms the value shown in the center of the meter | | fluidConfiguration | FluidLayerConfiguration | {color: '#ff0000',waveSpeed: Speed.NORMAL,horizontalSpeed: Speed.NORMAL} | values of the fluid being displayed |

API and Methods

Example:
import { CircularFluidMeter } from 'fluid-meter';

const target = document.querySelector('#target');
const m = new CircularFluidMeter(target, {
  initialProgress: 50
});

m.targetProgress = 50;
m.dropShadow = false;
m.use3D = false;
List of setters and getters

| setter / getter | info | | ------------------------------- | ----------------------------------- | | progress | number | | maxProgress (only getter) | number | | borderWidth | number or BreakpointValueConfig[] | | borderColor | string | | meterPadding | number | | backgroundColor | string | | textColor | string | | fontFamily | string | | fontSize | number or BreakpointValueConfig[] | | textDropShadow | boolean | | textShadowOpacity | number (between 0 and 1) | | textShadowColor | string | | showProgress | boolean | | showBubbles | boolean | | bubbleColor | string | | use3D | boolean | | dropShadow | boolean | | dropShadowColor | string | | progressFormatter (only getter) | (value: number) => string |

Performance

If yo are using the library on a context where you will be adding it or removing it dynamically you should call dispose when removing it to correctly clear the animation:

meter.dispose();