@jswork/react-svg-circle

Svg circle for react.

Usage no npm install needed!

<script type="module">
  import jsworkReactSvgCircle from 'https://cdn.skypack.dev/@jswork/react-svg-circle';
</script>

README

react-svg-circle

Svg circle for react.

version license size download

installation

npm install -S @jswork/react-svg-circle

properties

Name Type Required Default Description
className string false - The extended className for component.
lineWidth number false 10 The circle line-width.
lineCap enum false 'inherit' The circle line-cap.
value number false 0 Circle deg, default 0.
onChange func false noop The change handler.
svgProps any false - Any other svg props.
elementProps any false - Any other circle(main element) props.

usage

  1. import css
@import "~@jswork/react-svg-circle/dist/style.css";

// or use sass
@import "~@jswork/react-svg-circle/dist/style.scss";

// customize your styles:
$react-svg-circle-options: ()
  1. import js
import ReactDemokit from '@jswork/react-demokit';
import React from 'react';
import ReactDOM from 'react-dom';
import ReactSvgCircle from '@jswork/react-svg-circle';
import './assets/style.scss';

class App extends React.Component {
  state = {
    value: 180
  };
  render() {
    const { value } = this.state;
    return (
      <ReactDemokit
        className="p-3 app-container"
        url="https://github.com/afeiship/react-svg-circle">
        <h2 className="is-title">Drag me to change</h2>
        <div className="is-control">
          <input
            type="range"
            onChange={(e) => {
              const { value } = e.target;
              this.setState({ value: parseInt(value) });
            }}
            step="1"
            min="0"
            max="360"
            value={value}
            name=""
            id=""
          />
        </div>
        <div className="is-component">
          <ReactSvgCircle lineWidth={20} lineCap="inherit" value={value}>
            <text
              x="20"
              y="35"
              x="50%"
              y="50%"
              dominantBaseline="middle"
              textAnchor="middle">
              {value}%
            </text>
          </ReactSvgCircle>
        </div>
      </ReactDemokit>
    );
  }
}

ReactDOM.render(<App />, document.getElementById('app'));

fix ios9 debug

  • babel const error
    ["@babel/preset-env", {
      "targets": {
        "browsers": ["last 2 versions"],
      }
    }]
    
  • babel rest(..args)
    "@babel/plugin-transform-parameters"
    

documentation

resources

license

Code released under the MIT license.