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

react-battery-gauge

v1.0.7

Published

This library is a SVG based react component for displaying battery status, ultra lightweight, highly customizable with zero dependencies ## Live Demo [Click here](https://umerbhat.github.io/react-battery-gauge/) ## Short Demo ![Short Demo](demo/demo1.gif)

Downloads

10,317

Readme

React Battery Gauge

This library is a SVG based react component for displaying battery status, ultra lightweight, highly customizable with zero dependencies

Live Demo

Click here

Short Demo

Short Demo

Storybook Demo

Click here

Usage

Install it by running

npm install react-battery-gauge # or yarn add react-battery-gauge

Include the component:

import BatteryGauge from 'react-battery-gauge'

<BatteryGauge value={40} />

Options

| Name | Description | Default | type | |---------------|----------------------------------------------------------------------------------------------------------------------------------------------------------|--------------|---------------------------| | value | Meter value range [0-maxValue(100)] | 50 | number | | maxValue | Meter max value | 100 | number | | orientation | Changes orientation, keeping text horizontal | "horizontal" | "horizontal"| "vertical" | | padding | Padding of gauge within canvas | 5 | number | | size | We don't like passing both width and height, can create unusual looking shape. Size will help gauge to achieve the desired size maintaining aspect ratio | 300 | number | | aspectRatio | Gauge aspect ratio, At padding 0 easy to create battery types -> D = 0.56, C = 0.52, AA = 0.28, AAA = 0.23, AAAA = 0.19 , default C battery | 0.52 | number | | animated | Enable animation on mount | false | boolean | | charging | Enable charging mode | false | boolean | | customization | All individual components customisation | GaugeCustom | Partial |

Override any customization default values:

{
  batteryBody: {
    strokeWidth: 4,
    cornerRadius: 6,
    fill: 'none',
    strokeColor: '#111'
  },
  batteryCap: {
    fill: 'none',
    strokeWidth: 4,
    strokeColor: '#111',
    cornerRadius: 2,
    capToBodyRatio: 0.4
  },
  batteryMeter: {
    fill: 'green',
    lowBatteryValue: 15,
    lowBatteryFill: 'red',
    outerGap: 1,
    noOfCells: 1, // more than 1, will create cell battery
    interCellsGap: 1
  },
  readingText: {
    lightContrastColor: '#111',
    darkContrastColor: '#fff',
    lowBatteryColor: 'red',
    fontFamily: 'Helvetica',
    fontSize: 14,
    showPercentage: true
  },
  chargingFlash: {
    scale: undefined,
    fill: 'orange',
    animated: true,
    animationDuration: 1000
  },
}

License

MIT

Free Software, Your contribution is welcome!