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

@tomickigrzegorz/react-circular-progress-bar

v1.1.2

Published

A circular progress bar in svg

Downloads

2,694

Readme

Demo

See the demo - example

Install

yarn add @tomickigrzegorz/react-circular-progress-bar
# or
npm install @tomickigrzegorz/react-circular-progress-bar

Usage

import { CircularProgressBar } from "@tomickigrzegorz/react-circular-progress-bar";
// available control variables
const props = {
  percent: 60, // is require
  colorSlice: "#00a1ff",
  colorCircle: "#00a1ff",
  fontColor: "#365b74",
  fontSize: "1.6rem",
  fontWeight: 400,
  size: 200,
  stroke: 10,
  strokeBottom: 5,
  speed: 60,
  cut: 0,
  rotation: -90,
  fill: "#00897B",
  unit: "%",
  textPosition: "0.35em",
  animationOff: false,
  strokeDasharray: "10,1",
  inverse: false,
  round: false,
  number: false,
  linearGradient: ["#ffff00", "brown"],
  styles: {
    borderRadius: "50%",
    boxShadow: "inset 0 0 25px 10px #a2caff"
  }
};

<CircularProgressBar {...props} />;

Update percent

If you want to update component you have to add id to each of them

const config = {
  id: 0, // important
  percent: 50,
  colorSlice: "#E91E63"
};

function App() {
  const [update, setUpdate] = useState(config);

  useEffect(() => {
    const interval = setInterval(() => {
      setUpdate({
        ...config,
        id: 0, // we indicate which component we want to change
        percent: Math.floor(Math.random() * 100 + 1)
        colorSlice: "#000",
        fontColor: "#F50057",
        fontSize: "1.2rem",
        fontWeight: 700
      });
    }, 3000);
    return () => clearInterval(interval);
  }, []);

  const newObject = { ...config, ...update };

  return (
    <div>
      <CircularProgressBar {...newObject} />
    </div>
  );
}

Add photos and text

const config = {
  percent: 55,
  colorSlice: "#E91E63",
  colorCircle: "#f1f1f1",
  fontWeight: 100,
  number: false // turn off the percentage animation first
};

<CircularProgressBar key={index} {...props}>
  <img
    src="https://picsum.photos/100/100"
    style={{
      width: "60px",
      borderRadius: "50%",
      padding: "2px",
      border: "3px solid salmon"
    }}
    alt="Random image"
  />
  <div style={{ textAlign: "center", padding: "0 35px" }}>
    Lorem, ipsum dolor.
  </div>
</CircularProgressBar>;

Add photos and percent animation

const config = {
  percent: 55,
  colorSlice: "#CDDC39",
  colorCircle: "#f1f1f1",
  fontWeight: 100,
  fontSize: "1rem",
  textPosition: "1.5em" // needed element to move the percentage animation lower
};

<CircularProgressBar key={index} {...props}>
  <img
    src="https://picsum.photos/100/100"
    style={{
      width: "60px",
      borderRadius: "50%",
      marginTop: "-40px",
      padding: "2px",
      border: "3px solid salmon"
    }}
    alt="Random image"
  />
</CircularProgressBar>;

How to turn off % or style them?

Turning off the percentage and leaving the number alone is very simple. Each percent (%) has a class of circular-unit-x of course you must add for each circle id. If you don't do this, the class will always be circular-unit-0. Just add .circular-unit-x { display: none } to our styles. Digit animation remains but percent sign [%] disappears.

You can also style this elements to create your own styles, example below:

.circular-unit-15 {
  fill: #f50057;
  font-size: 0.8rem;
  font-weight: 700;
}

Instead of adding styles to a component, you can add them in the configuration stage.

const examples = [
  {
    percent: 75,
    styles: {
      borderRadius: "50%",
      boxShadow: "inset 0 0 25px 10px #a2caff"
    }
  }
];

{examples.map((props, index) => {
  return <CircularSection key={index} {...props} />;
})}

See an example Minimal Width Shadow

Configuration of the plugin

| props | type | default | require | description | | --------------- | :-----: | :---------: | :-----: | ----- | | percent | number | | ✔ | Represents the progress bar and animation of the animation progress expressed by a number e.g. 65% | | id | number | | | If you want to update a component, you need to add an id to each of them. Also when you want to display several components with different gradients - linearGradient | | speed | number | | | Frame rate animation [fps]. Let's say you want the animation to be 60fps, just add the parameter speed: 60 | | animationOff | boolean | false | | Turn off the progress animation | | animationSmooth | string | | | The [transition](https://developer.mozilla.org/en-US/docs/Web/CSS/transition) property allows you to create animations (a smooth transition effect), e.g. `500ms ease-out` | | colorSlice | string | `'#00a1ff'` | | Progress layer color and background ["#ffff00","brown" \*](#colors-names) | | colorCircle | string | `'#00a1ff'` | | Bottom circle color Font ["#ffff00","brown" \*](#colors-names) | | stroke | number | `10` | | Stroke width, chart thickness | | strokeBottom | number | `10` | | If "strokBottom" is set, it is used to generate a background circle size | | round | boolean | `false` | | Path rounding | | inverse | boolean | `false` | | Counterclockwise animation | | rotation | number | `-90` | | Chart rotation | | number | boolean | `true` | | Add props number and set to false to hide the number with percent | | size | number | `200` | | Size progress bar width and height in px | | cut | number | `0` | | Angle of the circle sector | | unit | string | `%` | | Different unit instead of percentage (%) inside the circle | | fill | string | `none` | | Inner circle background color | | strokeDasharray | string | | | It works only on the lowest circle and only on whole circles - stroke-dasharray | | textPosition | string | 0.35em | | The position of the SVG TEXT element vertically | | fontSize | string | 1.6rem | | Font size. The font can be shown in units rem, em, px ... | | fontWeight | number | 400 | | 400, 600, ... | | fontColor | string | '#365b74' | | Font color "#ffff00","brown" * | | linearGradient | array | | | Array of colors "lineargradient": "#ffff00","brown" * | | styles | object | | | Possibility to add styles to parent div see example Minimal Width Shadow |

Colors names

* See colors names

Browser support

react-circular-progress-bar supports all major browsers including IE 11 and above