Skip to content
This repository was archived by the owner on Aug 16, 2021. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: kimmobrunfeldt/react-progressbar.js
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0.1.2
Choose a base ref
...
head repository: kimmobrunfeldt/react-progressbar.js
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 17 commits
  • 6 files changed
  • 5 contributors

Commits on Nov 1, 2015

  1. Bump to dev version

    kimmobrunfeldt committed Nov 1, 2015
    Copy the full SHA
    16f80e2 View commit details

Commits on Apr 25, 2016

  1. missing package

    alexbeletsky committed Apr 25, 2016
    Copy the full SHA
    1c3d7f7 View commit details
  2. Copy the full SHA
    abaa049 View commit details
  3. dist with babel

    alexbeletsky committed Apr 25, 2016
    Copy the full SHA
    5c7beb7 View commit details
  4. es2015 preset added

    alexbeletsky committed Apr 25, 2016
    Copy the full SHA
    90e25a1 View commit details

Commits on Jun 16, 2016

  1. Merge pull request #6 from blogfoster/feature/dist-output

    Upgrade to React v15, prepare dist folder.
    kimmobrunfeldt authored Jun 16, 2016
    Copy the full SHA
    4b15907 View commit details
  2. Release 0.2.0

    kimmobrunfeldt committed Jun 16, 2016
    Copy the full SHA
    0377881 View commit details
  3. Bump to dev version

    kimmobrunfeldt committed Jun 16, 2016
    Copy the full SHA
    8b3c551 View commit details

Commits on Oct 11, 2017

  1. Copy the full SHA
    8db4ab6 View commit details

Commits on Oct 20, 2017

  1. Update to ES6

    sebacruz committed Oct 20, 2017
    Copy the full SHA
    d6c73e8 View commit details
  2. Copy the full SHA
    fed276c View commit details
  3. Add compiled file

    sebacruz committed Oct 20, 2017
    Copy the full SHA
    56ea701 View commit details

Commits on Nov 10, 2017

  1. Copy the full SHA
    90be26a View commit details

Commits on Nov 15, 2017

  1. Copy the full SHA
    fae968f View commit details

Commits on May 28, 2018

  1. Merge pull request #29 from miro/patch-1

    Typofix: make animation.gif to render in GitHub
    kimmobrunfeldt authored May 28, 2018
    Copy the full SHA
    414dc4c View commit details
  2. Merge pull request #26 from sebacruz/master

    Update to React 16 and move to ES6
    kimmobrunfeldt authored May 28, 2018
    Copy the full SHA
    8ffd06c View commit details
  3. Merge pull request #23 from aaronang/fix-link

    Fix link to Shape options documentation
    kimmobrunfeldt authored May 28, 2018
    Copy the full SHA
    16d5cf0 View commit details
Showing with 363 additions and 83 deletions.
  1. +4 −0 .babelrc
  2. +2 −1 README.md
  3. +262 −0 dist/react-progressbar.js
  4. +19 −15 local-dev/main.js
  5. +27 −20 package.json
  6. +49 −47 src/main.js
4 changes: 4 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"presets": ["es2015", "react"],
"plugins": ["transform-es2015-modules-umd"]
}
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# react-progressbar.js

<br>

![Demo animation](docs/animation.gif)

<br>
@@ -116,7 +117,7 @@ Prop | Description
-------------------|------------------------
progress | Progress from 0 to 1. E.g. 67% progress would equal `0.67`. Default `0`.
text | Value for progress bar's text. Default `null`.
options | Options for path drawing. See [progressbar.js documentation](https://github.com/kimmobrunfeldt/progressbar.js#shapecontainer-options).
options | Options for path drawing. See [progressbar.js documentation](http://progressbarjs.readthedocs.io/en/latest/api/shape/#new-shapecontainer-options).
initialAnimate | If `true`, progress bar is animated to given progress when mounted. Default `false`.
containerStyle | Styles for progress bar container. Default `{}`.
containerClassName | Class name for progress bar container. Default `.progressbar-container`.
262 changes: 262 additions & 0 deletions dist/react-progressbar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,262 @@
(function (global, factory) {
if (typeof define === "function" && define.amd) {
define(['module', 'react', 'react-dom', 'lodash/isEqual', 'progressbar.js'], factory);
} else if (typeof exports !== "undefined") {
factory(module, require('react'), require('react-dom'), require('lodash/isEqual'), require('progressbar.js'));
} else {
var mod = {
exports: {}
};
factory(mod, global.react, global.reactDom, global.isEqual, global.progressbar);
global.main = mod.exports;
}
})(this, function (module, _react, _reactDom, _isEqual, _progressbar) {
'use strict';

var _react2 = _interopRequireDefault(_react);

var _isEqual2 = _interopRequireDefault(_isEqual);

var _progressbar2 = _interopRequireDefault(_progressbar);

function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}

var _extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];

for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}

return target;
};

function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}

var _createClass = function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}

return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();

function _possibleConstructorReturn(self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}

return call && (typeof call === "object" || typeof call === "function") ? call : self;
}

function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}

subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
}

var Shape = function (_Component) {
_inherits(Shape, _Component);

function Shape(props) {
_classCallCheck(this, Shape);

var _this = _possibleConstructorReturn(this, (Shape.__proto__ || Object.getPrototypeOf(Shape)).call(this, props));

_this.state = {
shape: null
};
return _this;
}

_createClass(Shape, [{
key: 'render',
value: function render() {
var _props = this.props,
style = _props.style,
className = _props.className;


return _react2.default.createElement('div', { className: className, style: style, ref: 'progressBar' });
}
}, {
key: 'componentWillReceiveProps',
value: function componentWillReceiveProps(nextProps) {
if (!(0, _isEqual2.default)(this.props.options, nextProps.options)) {
this._destroy();
this._create(nextProps, this.props);

return;
}

this._animateProgress(nextProps.progress);
this._setText(nextProps.text);
}
}, {
key: 'componentDidMount',
value: function componentDidMount() {
this._create(this.props);
}
}, {
key: 'componentWillUnmount',
value: function componentWillUnmount() {
this._destroy();
}
}, {
key: '_create',
value: function _create(props, oldProps) {
if (this.state.shape !== null) {
throw new Error('Progressbar is already created');
}

// setState function is not used to prevent a new render cycle
// This handling happens outside of React component's lifecycle
var container = (0, _reactDom.findDOMNode)(this.refs.progressBar);

this.state.shape = new props.ShapeClass(container, props.options);

if (props.initialAnimate) {
if (oldProps) {
this._setProgress(oldProps.progress);
}

this._animateProgress(props.progress);
} else {
this._setProgress(props.progress);
}

this._setText(props.text);
}
}, {
key: '_destroy',
value: function _destroy() {
if (this.state.shape) {
this.state.shape.destroy();
this.state.shape = null;
}
}
}, {
key: '_animateProgress',
value: function _animateProgress(progress) {
this.state.shape.animate(progress);
}
}, {
key: '_setProgress',
value: function _setProgress(progress) {
this.state.shape.set(progress);
}
}, {
key: '_setText',
value: function _setText(text) {
if (text) {
this.state.shape.setText(text);
}
}
}]);

return Shape;
}(_react.Component);

;

var Line = function (_Component2) {
_inherits(Line, _Component2);

function Line() {
_classCallCheck(this, Line);

return _possibleConstructorReturn(this, (Line.__proto__ || Object.getPrototypeOf(Line)).apply(this, arguments));
}

_createClass(Line, [{
key: 'render',
value: function render() {
return _react2.default.createElement(Shape, _extends({}, this.props, { ShapeClass: _progressbar2.default.Line }));
}
}]);

return Line;
}(_react.Component);

;

var Circle = function (_Component3) {
_inherits(Circle, _Component3);

function Circle() {
_classCallCheck(this, Circle);

return _possibleConstructorReturn(this, (Circle.__proto__ || Object.getPrototypeOf(Circle)).apply(this, arguments));
}

_createClass(Circle, [{
key: 'render',
value: function render() {
return _react2.default.createElement(Shape, _extends({}, this.props, { ShapeClass: _progressbar2.default.Circle }));
}
}]);

return Circle;
}(_react.Component);

;

var SemiCircle = function (_Component4) {
_inherits(SemiCircle, _Component4);

function SemiCircle() {
_classCallCheck(this, SemiCircle);

return _possibleConstructorReturn(this, (SemiCircle.__proto__ || Object.getPrototypeOf(SemiCircle)).apply(this, arguments));
}

_createClass(SemiCircle, [{
key: 'render',
value: function render() {
return _react2.default.createElement(Shape, _extends({}, this.props, { ShapeClass: _progressbar2.default.SemiCircle }));
}
}]);

return SemiCircle;
}(_react.Component);

;

module.exports = {
Line: Line,
Circle: Circle,
SemiCircle: SemiCircle
};
});
34 changes: 19 additions & 15 deletions local-dev/main.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,44 @@
var React = require('react');
var ProgressBar = require('../src/main.js');
var Circle = ProgressBar.Circle;
import React, { Component } from 'react';
import { render } from 'react-dom';
import { Circle } from '../src/main.js';

var App = React.createClass({
getInitialState: function() {
return {
class App extends Component {
constructor(props) {
super(props);

this.state = {
progress: 0.1,
options: {}
};
},
}

render: function() {
render() {
return <Circle initialAnimate={this.state.initialAnimate} options={this.state.options} progress={this.state.progress} />;
},
}

componentDidMount: function() {
var self = this;
componentDidMount() {
const self = this;

setTimeout(function() {
console.log('setstate')

self.setState({
progress: 1
});
}, 1000);

setTimeout(function() {
console.log('setstate')

self.setState({
initialAnimate: true,
progress: 1
});
}, 500);

}
});
};

React.render(
render(
<App />,
document.querySelector('body')
document.querySelector('#progress')
);
Loading