New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

fluid-meter

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fluid-meter

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

latest
Source
npmnpm
Version
1.1.2
Version published
Maintainers
1
Created
Source

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

optiontypedefaultinfo
initialProgressnumber0initial progress to show
maxProgressnumber100max progress of the meter
borderWidthnumber or BreakpointValueConfig30border width. Can be a number or an array of breakpoint value configs
borderColorstring#75758bcolor of the outer border.
paddingnumber30space between the boundaries of the container and the meter. Usefull if drop shadow is enabled
backgroundColorstring#9f9faemeter background color
showProgressbooleantruedisplays or not the center text
showBubblesbooleantruedisplays or not the bubbles
bubbleColorstring#ffffffcolor of the bubbles
textColorstring#fffffftext color
textDropShadowbooleantruetext has a small shadow. Helps when colors are too similar or on difficult contrasting scenarios
textShadowOpacitynumber1intensity of the shadow between 0 and 1: 0 invisible and 1 fully visible
textShadowColorstring#000000text shadow color
fontFamilystringArialname of the typeface to use
fontSizenumber or BreakpointValueConfig30tex size. Can be a number of an array of breakpoint value configs
use3Dbooleantrueenables details that gives the impresion of depth
dropShadowbooleantruemeter drops shadow. Requires some padding to show correctly
dropShadowColorstring#000000meter 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
fluidConfigurationFluidLayerConfiguration{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 / getterinfo
progressnumber
maxProgress (only getter)number
borderWidthnumber or BreakpointValueConfig[]
borderColorstring
meterPaddingnumber
backgroundColorstring
textColorstring
fontFamilystring
fontSizenumber or BreakpointValueConfig[]
textDropShadowboolean
textShadowOpacitynumber (between 0 and 1)
textShadowColorstring
showProgressboolean
showBubblesboolean
bubbleColorstring
use3Dboolean
dropShadowboolean
dropShadowColorstring
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();

Keywords

npm

FAQs

Package last updated on 21 May 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts