react-shimmer-effect
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -1,1 +0,110 @@ | ||
"use strict"; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
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; }; }(); | ||
var _react = require("react"); | ||
var _react2 = _interopRequireDefault(_react); | ||
var _propTypes = require("prop-types"); | ||
var _propTypes2 = _interopRequireDefault(_propTypes); | ||
var _reactJss = require("react-jss"); | ||
var _reactJss2 = _interopRequireDefault(_reactJss); | ||
var _classnames = require("classnames"); | ||
var _classnames2 = _interopRequireDefault(_classnames); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
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 styles = { | ||
shimmer: { | ||
background: "#f2f2f2", | ||
display: "inline-block", | ||
backgroundImage: "linear-gradient(to right,#eeeeee 40%,#dddddd 50%,#eeeeee 60%)", | ||
backgroundSize: "800px 104px", | ||
backgroundRepeat: "no-repeat", | ||
animation: "shimmerAnim 2s infinite linear" | ||
}, | ||
"@keyframes shimmerAnim": { | ||
"0%": { | ||
backgroundPosition: "-468px 0" | ||
}, | ||
"100%": { | ||
backgroundPosition: "468px 0" | ||
} | ||
} | ||
}; | ||
var Shimmer = function (_Component) { | ||
_inherits(Shimmer, _Component); | ||
function Shimmer() { | ||
_classCallCheck(this, Shimmer); | ||
return _possibleConstructorReturn(this, (Shimmer.__proto__ || Object.getPrototypeOf(Shimmer)).apply(this, arguments)); | ||
} | ||
_createClass(Shimmer, [{ | ||
key: "appendShimmerToChild", | ||
/** | ||
* Appending animating shimmer class to the Shimmer component's child. | ||
*/ | ||
value: function appendShimmerToChild(child) { | ||
var classes = this.props.classes; | ||
return _react2.default.cloneElement(child, { | ||
className: (0, _classnames2.default)(child.props.className, classes.shimmer) | ||
}); | ||
} | ||
}, { | ||
key: "render", | ||
value: function render() { | ||
var _this2 = this; | ||
var children = this.props.children; | ||
var modifiedChildren = []; | ||
if (children.length > 0) { | ||
children.forEach(function (element) { | ||
modifiedChildren.push(_this2.appendShimmerToChild(element)); | ||
}); | ||
} else { | ||
modifiedChildren = this.appendShimmerToChild(children); | ||
} | ||
return _react2.default.createElement( | ||
_react.Fragment, | ||
null, | ||
modifiedChildren | ||
); | ||
} | ||
}]); | ||
return Shimmer; | ||
}(_react.Component); | ||
Shimmer.propTypes = { | ||
classes: _propTypes2.default.object, | ||
children: _propTypes2.default.object | ||
}; | ||
Shimmer.defaultProps = { | ||
classes: {}, | ||
children: {} | ||
}; | ||
exports.default = (0, _reactJss2.default)(styles)(Shimmer); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
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; }; }(); | ||
var _react = require("react"); | ||
@@ -13,99 +7,13 @@ | ||
var _propTypes = require("prop-types"); | ||
var _reactDom = require("react-dom"); | ||
var _propTypes2 = _interopRequireDefault(_propTypes); | ||
var _Shimmer = require("../src/Components/Shimmer"); | ||
var _reactJss = require("react-jss"); | ||
var _Shimmer2 = _interopRequireDefault(_Shimmer); | ||
var _reactJss2 = _interopRequireDefault(_reactJss); | ||
var _classnames = require("classnames"); | ||
var _classnames2 = _interopRequireDefault(_classnames); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
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 styles = { | ||
shimmer: { | ||
background: "#f2f2f2", | ||
display: "inline-block", | ||
backgroundImage: "linear-gradient(to right,#eeeeee 40%,#dddddd 50%,#eeeeee 60%)", | ||
backgroundSize: "800px 104px", | ||
backgroundRepeat: "no-repeat", | ||
animation: "shimmerAnim 2s infinite linear" | ||
}, | ||
"@keyframes shimmerAnim": { | ||
"0%": { | ||
backgroundPosition: "-468px 0" | ||
}, | ||
"100%": { | ||
backgroundPosition: "468px 0" | ||
} | ||
} | ||
var App = function App() { | ||
return _react2.default.createElement(_Shimmer2.default, null); | ||
}; | ||
var Shimmer = function (_Component) { | ||
_inherits(Shimmer, _Component); | ||
function Shimmer() { | ||
_classCallCheck(this, Shimmer); | ||
return _possibleConstructorReturn(this, (Shimmer.__proto__ || Object.getPrototypeOf(Shimmer)).apply(this, arguments)); | ||
} | ||
_createClass(Shimmer, [{ | ||
key: "appendShimmerToChild", | ||
/** | ||
* Appending animating shimmer class to the Shimmer component's child. | ||
*/ | ||
value: function appendShimmerToChild(child) { | ||
var classes = this.props.classes; | ||
return _react2.default.cloneElement(child, { | ||
className: (0, _classnames2.default)(child.props.className, classes.shimmer) | ||
}); | ||
} | ||
}, { | ||
key: "render", | ||
value: function render() { | ||
var _this2 = this; | ||
var children = this.props.children; | ||
var modifiedChildren = []; | ||
if (children.length > 0) { | ||
children.forEach(function (element) { | ||
modifiedChildren.push(_this2.appendShimmerToChild(element)); | ||
}); | ||
} else { | ||
modifiedChildren = this.appendShimmerToChild(children); | ||
} | ||
return _react2.default.createElement( | ||
_react.Fragment, | ||
null, | ||
modifiedChildren | ||
); | ||
} | ||
}]); | ||
return Shimmer; | ||
}(_react.Component); | ||
Shimmer.propTypes = { | ||
classes: _propTypes2.default.object, | ||
children: _propTypes2.default.object | ||
}; | ||
Shimmer.defaultProps = { | ||
classes: {}, | ||
children: {} | ||
}; | ||
exports.default = (0, _reactJss2.default)(styles)(Shimmer); | ||
(0, _reactDom.render)(_react2.default.createElement(App, null), document.getElementById("root")); |
{ | ||
"name": "react-shimmer-effect", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "React Shimmer Effect", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
# react-shimmer-effect | ||
Shimmer effect to the elements | ||
React-Shimmer-Effect, `<Shimmer>` component that simulates a [**shimmer**](https://github.com/facebook/Shimmer) effect for the component children.More customisable is on the way. | ||
<p align="center"> | ||
<a href="https://www.npmjs.com/package/react-shimmer"> | ||
<img alt= "NPM" src="https://img.shields.io/npm/v/react-shimmer.svg"> | ||
</a> | ||
<a href="https://standardjs.com"> | ||
<img alt="JavaScript Style Guide" src="https://img.shields.io/badge/code_style-standard-brightgreen.svg"> | ||
</a> | ||
<a href="https://codeclimate.com/github/eTechist/react-shimmer-effect"> | ||
<img alt= "Maintainability" src="https://api.codeclimate.com/v1/badges/a99a88d28ad37a79dbf6/maintainability"> | ||
</a> | ||
</p> | ||
![Optional Text](/shimmer.js.png) | ||
## Install | ||
```bash | ||
npm i react-shimmer-effect | ||
``` | ||
## Usage | ||
```jsx | ||
import React, { Component } from "react"; | ||
import Shimmer from "react-shimmer-effect"; | ||
import injectSheet from "react-jss"; | ||
const StyleSheet = { | ||
container: { | ||
border: "0px solid rgba(255, 255, 255, 1)", | ||
boxShadow: "0px 0px 20px rgba(0, 0, 0, .1)", | ||
borderRadius: "4px", | ||
backgroundColor: "white", | ||
display: "flex", | ||
padding: "16px", | ||
width: "200px" | ||
}, | ||
circle: { | ||
height: "56px", | ||
width: "56px", | ||
borderRadius: "50%" | ||
}, | ||
line: { | ||
width: "96px", | ||
height: "8px", | ||
alignSelf: "center", | ||
marginLeft: "16px", | ||
borderRadius: "8px" | ||
} | ||
}; | ||
class App extends Component { | ||
render() { | ||
const { classes } = this.props; | ||
return ( | ||
<div className={classes.container}> | ||
<Shimmer> | ||
<div className={classes.circle} /> | ||
<div className={classes.line} /> | ||
</Shimmer> | ||
</div> | ||
); | ||
} | ||
} | ||
export default injectSheet(StyleSheet)(App); | ||
``` | ||
### Live Demo | ||
![](https://media.giphy.com/media/X81Xq7aYcjWjo7iDZN/giphy.gif) | ||
## Contributing | ||
Feel free to send PRs. | ||
## License | ||
MIT © [eTechist](https://github.com/eTechist) | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
443055
8
445
85