react-awesome-button
Advanced tools
Comparing version 0.3.0 to 0.4.0
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("prop-types"),require("react")):"function"==typeof define&&define.amd?define(["prop-types","react"],t):"object"==typeof exports?exports["react-awesome-button"]=t(require("prop-types"),require("react")):e["react-awesome-button"]=t(e.PropTypes,e.React)}(this,function(e,t){return function(e){function t(o){if(n[o])return n[o].exports;var s=n[o]={i:o,l:!1,exports:{}};return e[o].call(s.exports,s,s.exports,t),s.l=!0,s.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=4)}([function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},l=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),u=n(3),p=o(u),c=n(2),d=o(c),f=n(1),h="aws-btn",b=function(e){return p.default.createElement("a",e)},m=function(e){return p.default.createElement("button",e)},g=function(e){function t(e){s(this,t);var n=r(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.rootElement=e.rootElement||h,n.animationStage=0,n.extraProps={},n.state={disabled:e.disabled,loading:!1,loadingEnd:!1,loadingStart:!1,blocked:!1,clicked:!1},n.checkProps(e),n}return i(t,e),l(t,[{key:"componentDidMount",value:function(){(0,f.setCssEndEvent)(this.wrapper,"transition",this.clearStagedWrapperAnimation.bind(this))}},{key:"componentWillReceiveProps",value:function(e){this.checkProps(e)}},{key:"getRootClassName",value:function(){var e=[this.rootElement,this.props.type&&this.rootElement+"--"+this.props.type,this.props.size&&this.rootElement+"--"+this.props.size,this.props.visible&&this.rootElement+"--visible",this.state.loadingStart&&this.rootElement+"--start"||null,this.state.loadingEnd&&this.rootElement+"--end"||null,this.props.progress&&this.rootElement+"--progress"||null];return!0===this.state.disabled&&e.push(this.rootElement+"--disabled"),this.state.pressPosition&&e.push(this.state.pressPosition),this.props.cssModule&&this.props.cssModule["aws-btn"]?(0,f.classToModules)(e,this.props.cssModule):e.join(" ").trim().replace(/[\s]+/gi," ")}},{key:"checkProps",value:function(e){this.extraProps.to=e.to||null,this.extraProps.href=e.href||null,this.extraProps.target=e.target||null,this.renderComponent=e.element||(this.props.href?b:m)}},{key:"endLoading",value:function(){this.setState({loadingEnd:!0}),this.animationStage=1}},{key:"startLoading",value:function(){this.setState({loading:!0,loadingStart:!0,blocked:!0})}},{key:"clearPress",value:function(){var e=this.state.loading?this.state.pressPosition:null;this.setState({pressPosition:e})}},{key:"clearLoading",value:function(){this.setState({loading:!1,loadingStart:!1,loadingEnd:!1})}},{key:"clearStagedWrapperAnimation",value:function(){var e=this;if(0!==this.animationStage){if(5===this.animationStage)return this.animationStage=0,void setTimeout(function(){"undefined"!=typeof window&&window.requestAnimationFrame(function(){e.clearLoading(),e.clearPress(),setTimeout(function(){e.setState({blocked:!1})},500)})},350);this.animationStage+=1}}},{key:"action",value:function(){this.props.progress&&this.startLoading(),this.props.action&&this.props.action(this.button.parentNode,this.props.progress?this.endLoading.bind(this):null)}},{key:"createBubble",value:function(e){(0,f.createBubbleEffect)({event:e,button:this.button,content:this.content,className:(0,f.getClassName)(this.rootElement+"__bubble",this.props.cssModule)})}},{key:"moveEvents",value:function(){var e=this,t={onMouseLeave:function(){e.clearPress()},onMouseDown:function(t){!0===e.state.disabled||!0===e.state.loading||!0===e.state.blocked||t&&1!==t.nativeEvent.which||(!1===e.props.progress&&!0===e.props.bubbles&&e.createBubble(t),e.setState({loading:e.props.progress,pressPosition:e.rootElement+"--active"}),"undefined"!=typeof window&&window.requestAnimationFrame(function(){var t=new Event("action");e.button.dispatchEvent(t),e.action()}))},onMouseUp:function(t){if(!0===e.state.disabled||!0===e.state.loading||!0===e.state.blocked)return t.preventDefault(),void t.stopPropagation();e.clearPress()}};return!0===this.props.moveEvents?t.onMouseMove=function(t){if(!0!==e.state.disabled&&!0!==e.state.loading&&!0!==e.state.blocked){var n=e.button,o=n.getBoundingClientRect().left,s=n.offsetWidth;e.setState({pressPosition:t.pageX<o+.3*s?e.rootElement+"--left":t.pageX>o+.65*s?e.rootElement+"--right":e.rootElement+"--middle"})}}:t.onMouseEnter=function(){e.setState({pressPosition:e.rootElement+"--middle"})},t}},{key:"render",value:function(){var e=this,t=this.renderComponent;return p.default.createElement(t,a({style:this.props.style,className:this.getRootClassName(),role:"button"},this.extraProps,this.moveEvents()),p.default.createElement("span",{ref:function(t){e.button=t},className:(0,f.getClassName)(this.rootElement+"__container",this.props.cssModule)},p.default.createElement("span",{ref:function(t){e.wrapper=t},className:(0,f.getClassName)(this.rootElement+"__wrapper",this.props.cssModule)},p.default.createElement("span",{ref:function(t){e.content=t},"data-loading":this.props.progress&&this.props.loadingLabel||null,"data-status":this.props.progress&&this.props.resultLabel||null,className:(0,f.getClassName)(this.rootElement+"__content",this.props.cssModule)},p.default.createElement("span",null,this.props.children)))))}}]),t}(p.default.Component);g.propTypes={action:d.default.func,bubbles:d.default.bool,children:d.default.node.isRequired,disabled:d.default.bool,element:d.default.func,href:d.default.string,loadingLabel:d.default.string,progress:d.default.bool,resultLabel:d.default.string,rootElement:d.default.string,moveEvents:d.default.bool,size:d.default.string,style:d.default.object,cssModule:d.default.object,target:d.default.string,to:d.default.string,type:d.default.string,visible:d.default.bool},g.defaultProps={action:null,bubbles:!1,disabled:!1,element:null,href:null,loadingLabel:"Wait ..",moveEvents:!0,progress:!1,resultLabel:"Success!",rootElement:h,rounded:!0,size:null,style:{},target:null,to:null,type:"primary",visible:!0},t.default=g},function(e,t,n){"use strict";function o(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments[1],n=[],o=e.length;o--;)t[e[o]]&&n.push(t[e[o]]);return n.join(" ").trim()}function s(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments[1];return t?t[e]||e:e}function r(e,t,n){if(!e)return!1;var o=t.charAt(0).toUpperCase()+t.slice(1);return void 0!==e.style["Webkit"+o]?e.addEventListener("webkit"+o+"End",n):void 0!==e.style.OTransition?e.addEventListener("o"+t+"End",n):e.addEventListener(t+"End",n)}function i(e){var t=e.event,n=e.button,o=e.content,s=e.className,i=n.getBoundingClientRect(),a=window.pageYOffset||document.documentElement.scrolltop||0,l=document.createElement("span"),u=i.width<50?3*i.width:2*i.width;l.className=s,l.style.top="-"+(u/2-(t.pageY-i.top-a))+"px",l.style.left="-"+(u/2-(t.pageX-i.left))+"px",l.style.width=u+"px",l.style.height=u+"px",r(l,"animation",function(){o.removeChild(l)}),window.requestAnimationFrame(function(){o.appendChild(l)})}Object.defineProperty(t,"__esModule",{value:!0}),t.classToModules=o,t.getClassName=s,t.setCssEndEvent=r,t.createBubbleEffect=i},function(t,n){t.exports=e},function(e,n){e.exports=t},function(e,t,n){e.exports=n(0)}])}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("prop-types"),require("react")):"function"==typeof define&&define.amd?define(["prop-types","react"],t):"object"==typeof exports?exports["react-awesome-button"]=t(require("prop-types"),require("react")):e["react-awesome-button"]=t(e.PropTypes,e.React)}(this,function(e,t){return function(e){function t(o){if(n[o])return n[o].exports;var s=n[o]={i:o,l:!1,exports:{}};return e[o].call(s.exports,s,s.exports,t),s.l=!0,s.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=4)}([function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},l=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),u=n(3),p=o(u),c=n(2),d=o(c),f=n(1),h="aws-btn",b=function(e){return p.default.createElement("a",e)},m=function(e){return p.default.createElement("button",e)},g=function(e){function t(e){s(this,t);var n=r(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.rootElement=e.rootElement||h,n.animationStage=0,n.extraProps={},n.state={disabled:e.disabled,loading:!1,loadingEnd:!1,loadingStart:!1,blocked:!1,clicked:!1},n.checkProps(e),n}return i(t,e),l(t,[{key:"componentDidMount",value:function(){(0,f.setCssEndEvent)(this.wrapper,"transition",this.clearStagedWrapperAnimation.bind(this))}},{key:"componentWillReceiveProps",value:function(e){this.checkProps(e)}},{key:"getRootClassName",value:function(){var e=[this.rootElement,this.props.type&&this.rootElement+"--"+this.props.type,this.props.size&&this.rootElement+"--"+this.props.size,this.props.visible&&this.rootElement+"--visible",this.state.loadingStart&&this.rootElement+"--start"||null,this.state.loadingEnd&&this.rootElement+"--end"||null,this.props.progress&&this.rootElement+"--progress"||null];return!0===this.state.disabled&&e.push(this.rootElement+"--disabled"),this.state.pressPosition&&e.push(this.state.pressPosition),this.props.cssModule&&this.props.cssModule["aws-btn"]?(0,f.classToModules)(e,this.props.cssModule):e.join(" ").trim().replace(/[\s]+/gi," ")}},{key:"checkProps",value:function(e){this.extraProps.to=e.to||null,this.extraProps.href=e.href||null,this.extraProps.target=e.target||null,this.renderComponent=e.element||(this.props.href?b:m)}},{key:"endLoading",value:function(){this.setState({loadingEnd:!0}),this.animationStage=1}},{key:"startLoading",value:function(){this.setState({loading:!0,loadingStart:!0,blocked:!0})}},{key:"clearPress",value:function(){var e=this.state.loading?this.state.pressPosition:null;this.setState({pressPosition:e})}},{key:"clearLoading",value:function(){this.setState({loading:!1,loadingStart:!1,loadingEnd:!1})}},{key:"clearStagedWrapperAnimation",value:function(){var e=this;if(0!==this.animationStage){if(5===this.animationStage)return this.animationStage=0,void setTimeout(function(){"undefined"!=typeof window&&window.requestAnimationFrame(function(){e.clearLoading(),e.clearPress(),setTimeout(function(){e.setState({blocked:!1})},500)})},350);this.animationStage+=1}}},{key:"action",value:function(){this.props.progress&&this.startLoading(),this.props.action&&this.props.action(this.button.parentNode,this.props.progress?this.endLoading.bind(this):null)}},{key:"createBubble",value:function(e){(0,f.createBubbleEffect)({event:e,button:this.button,content:this.content,className:(0,f.getClassName)(this.rootElement+"__bubble",this.props.cssModule)})}},{key:"moveEvents",value:function(){var e=this,t={onMouseLeave:function(){e.clearPress()},onMouseDown:function(t){!0===e.state.disabled||!0===e.state.loading||!0===e.state.blocked||t&&1!==t.nativeEvent.which||(!1===e.props.progress&&!0===e.props.bubbles&&e.createBubble(t),e.setState({loading:e.props.progress,pressPosition:e.rootElement+"--active"}),"undefined"!=typeof window&&window.requestAnimationFrame(function(){var t=new Event("action");e.button.dispatchEvent(t),e.action()}))},onMouseUp:function(t){if(!0===e.state.disabled||!0===e.state.loading||!0===e.state.blocked)return t.preventDefault(),void t.stopPropagation();e.clearPress()}};return!0===this.props.moveEvents?t.onMouseMove=function(t){if(!0!==e.state.disabled&&!0!==e.state.loading&&!0!==e.state.blocked){var n=e.button,o=n.getBoundingClientRect().left,s=n.offsetWidth;e.setState({pressPosition:t.pageX<o+.3*s?e.rootElement+"--left":t.pageX>o+.65*s?e.rootElement+"--right":e.rootElement+"--middle"})}}:t.onMouseEnter=function(){e.setState({pressPosition:e.rootElement+"--middle"})},t}},{key:"render",value:function(){var e=this,t=this.renderComponent;return p.default.createElement(t,a({style:this.props.style,className:this.getRootClassName(),role:"button"},this.extraProps,this.moveEvents()),p.default.createElement("span",{ref:function(t){e.button=t},className:(0,f.getClassName)(this.rootElement+"__container",this.props.cssModule)},p.default.createElement("span",{ref:function(t){e.wrapper=t},className:(0,f.getClassName)(this.rootElement+"__wrapper",this.props.cssModule)},p.default.createElement("span",{ref:function(t){e.content=t},"data-loading":this.props.progress&&this.props.loadingLabel||null,"data-status":this.props.progress&&this.props.resultLabel||null,className:(0,f.getClassName)(this.rootElement+"__content",this.props.cssModule)},p.default.createElement("span",null,this.props.children)))))}}]),t}(p.default.Component);g.propTypes={action:d.default.func,bubbles:d.default.bool,children:d.default.node.isRequired,disabled:d.default.bool,element:d.default.func,href:d.default.string,loadingLabel:d.default.string,progress:d.default.bool,resultLabel:d.default.string,rootElement:d.default.string,moveEvents:d.default.bool,size:d.default.string,style:d.default.object,cssModule:d.default.object,target:d.default.string,to:d.default.string,type:d.default.string,visible:d.default.bool},g.defaultProps={action:null,bubbles:!1,disabled:!1,element:null,href:null,loadingLabel:"Wait ..",moveEvents:!0,progress:!1,resultLabel:"Success!",rootElement:h,size:null,style:{},target:null,to:null,type:"primary",visible:!0},t.default=g},function(e,t,n){"use strict";function o(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments[1],n=[],o=e.length;o--;)t[e[o]]&&n.push(t[e[o]]);return n.join(" ").trim()}function s(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments[1];return t?t[e]||e:e}function r(e,t,n){if(!e)return!1;var o=t.charAt(0).toUpperCase()+t.slice(1);return void 0!==e.style["Webkit"+o]?e.addEventListener("webkit"+o+"End",n):void 0!==e.style.OTransition?e.addEventListener("o"+t+"End",n):e.addEventListener(t+"End",n)}function i(e){var t=e.event,n=e.button,o=e.content,s=e.className,i=n.getBoundingClientRect(),a=window.pageYOffset||document.documentElement.scrolltop||0,l=document.createElement("span"),u=i.width<50?3*i.width:2*i.width;l.className=s,l.style.top="-"+(u/2-(t.pageY-i.top-a))+"px",l.style.left="-"+(u/2-(t.pageX-i.left))+"px",l.style.width=u+"px",l.style.height=u+"px",r(l,"animation",function(){o.removeChild(l)}),window.requestAnimationFrame(function(){o.appendChild(l)})}Object.defineProperty(t,"__esModule",{value:!0}),t.classToModules=o,t.getClassName=s,t.setCssEndEvent=r,t.createBubbleEffect=i},function(t,n){t.exports=e},function(e,n){e.exports=t},function(e,t,n){e.exports=n(0)}])}); |
{ | ||
"name": "react-awesome-button", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "Performant, extendable, highly customisable, production ready React Component that renders an animated basic set of UI buttons", | ||
@@ -18,2 +18,3 @@ "main": "dist/index.js", | ||
"start": "webpack-dev-server -d --config webpack.demo.config.js", | ||
"white": "webpack-dev-server -d --config webpack.demo-white.config.js", | ||
"build": "NODE_ENV=production webpack", | ||
@@ -20,0 +21,0 @@ "build:scss": "NODE_ENV=production webpack --config webpack.scss.config.js && rm ./dist/styles.js", |
@@ -6,4 +6,11 @@ # <ReactAwesomeButton /> | ||
`ReactAwesomeButton` is a performant, extendable, highly customisable, production ready React Component that renders an animated set of UI buttons. | ||
<img width="600" alt="react-awesome-button demo" src="https://image.ibb.co/dOzGum/react_awesome_button_demo.gif"> | ||
## Live demo | ||
+ <a href="https://caferati.me/demo/react-awesome-button" target="_blank">On my portfolio</a> | ||
+ <a href="https://www.webpackbin.com/bins/-Kod7WV_1sLWnwxPdZJ-" target="_blank">Live code at Webpackbin</a> | ||
## Key Features | ||
+ Look and feel customisable and extendable via SASS variables and lists ([scss config file](https://github.com/rcaferati/react-awesome-button/blob/master/src/styles/default.scss)) | ||
@@ -15,7 +22,2 @@ + Use it with CSSModules or Plain CSS (NO inline-styles) | ||
### Live demo and examples | ||
+ <a href="https://caferati.me/demo/react-awesome-button" target="_blank">On my portfolio</a> | ||
+ <a href="https://www.webpackbin.com/bins/-Kod7WV_1sLWnwxPdZJ-" target="_blank">Live code at Webpackbin</a> | ||
![Live Demo](https://ibb.co/dhXLWR) | ||
## Examples | ||
@@ -22,0 +24,0 @@ |
@@ -35,3 +35,2 @@ import React from 'react'; | ||
moveEvents: PropTypes.bool, | ||
// rounded: PropTypes.bool, | ||
size: PropTypes.string, | ||
@@ -56,3 +55,2 @@ style: PropTypes.object, | ||
rootElement: ROOTELM, | ||
rounded: true, | ||
size: null, | ||
@@ -59,0 +57,0 @@ style: {}, |
@@ -91,2 +91,11 @@ import React from 'react'; | ||
</AwesomeButton> | ||
<AwesomeButton | ||
cssModule={AwsBtnStyles} | ||
type="instagram" | ||
size="icon" | ||
bubbles | ||
moveEvents={false} | ||
> | ||
<i className="fa fa-instagram" aria-hidden /> | ||
</AwesomeButton> | ||
</div> | ||
@@ -93,0 +102,0 @@ ), |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
76712
31
866
71