react-awesome-button
Advanced tools
Comparing version 0.6.1 to 0.7.0
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("prop-types")):"function"==typeof define&&define.amd?define(["react","prop-types"],t):"object"==typeof exports?exports["react-awesome-button"]=t(require("react"),require("prop-types")):e["react-awesome-button"]=t(e.React,e.PropTypes)}("undefined"!=typeof self?self: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.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=0)}([function(e,t,n){e.exports=n(1)},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(2),c=o(u),p=n(3),d=o(p),f=n(4),h="aws-btn",m=function(e){return c.default.createElement("a",e)},b=function(e){return c.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},n.checkProps(e),n}return i(t,e),l(t,[{key:"componentDidMount",value:function(){this.container=this.button&&this.button.parentNode,(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?m:b)}},{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(){(0,f.toggleMoveClasses)({element:this.container,root:this.rootElement,cssModule:this.props.cssModule});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.button&&this.props.action(this.container,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||(e.pressed=(new Date).getTime(),e.setState({pressPosition:e.rootElement+"--active",loading:e.props.progress}))},onMouseUp:function(t){if(!0===e.state.disabled||!0===e.state.blocked)return t.preventDefault(),void t.stopPropagation();e.clearTimer&&clearTimeout(e.clearTimer);var n=(new Date).getTime()-e.pressed;if(!1===e.props.progress&&!0===e.props.bubbles&&e.createBubble(t),"undefined"!=typeof window&&e.button){var o=new Event("action");e.button.dispatchEvent(o)}e.action(),e.clearTimer=setTimeout(function(){e.clearPress()},100-n)}};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(),s=o.left,r=n.offsetWidth,i=t.pageX<s+.3*r?"left":t.pageX>s+.65*r?"right":"middle";(0,f.toggleMoveClasses)({element:e.container,root:e.rootElement,cssModule:e.props.cssModule,state:i})}}:t.onMouseEnter=function(){e.container.classList.add((0,f.classToModules)([e.rootElement+"--middle"],e.props.cssModule))},t}},{key:"render",value:function(){var e=this,t=this.renderComponent;return c.default.createElement(t,a({style:this.props.style,className:this.getRootClassName(),role:"button"},this.extraProps,this.moveEvents()),c.default.createElement("span",{ref:function(t){e.button=t},className:(0,f.getClassName)(this.rootElement+"__container",this.props.cssModule)},c.default.createElement("span",{ref:function(t){e.wrapper=t},className:(0,f.getClassName)(this.rootElement+"__wrapper",this.props.cssModule)},c.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)},c.default.createElement("span",null,this.props.children)))))}}]),t}(c.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,cssModule:null,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(t,n){t.exports=e},function(e,n){e.exports=t},function(e,t,n){"use strict";function o(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments[1];if(!t)return e.join(" ").trim();for(var 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.element,n=e.root,s=e.cssModule,r=void 0===s?null:s,i=e.state,a=void 0===i?null:i;if(!t)return!1;if(!a)return t.classList.remove(o([n+"--"+l[0]],r),o([n+"--"+l[1]],r),o([n+"--"+l[2]],r)),!1;for(var u=l.filter(function(e){return e!==a}),c=u.length;c--;)t.classList.remove(o([n+"--"+u[c]],r));return t.classList.add(o([n+"--"+a],r)),!0}function a(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.toggleMoveClasses=i,t.createBubbleEffect=a;var l=["middle","left","right"]}])}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("prop-types")):"function"==typeof define&&define.amd?define(["react","prop-types"],t):"object"==typeof exports?exports["react-awesome-button"]=t(require("react"),require("prop-types")):e["react-awesome-button"]=t(e.React,e.PropTypes)}("undefined"!=typeof self?self: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.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=0)}([function(e,t,n){e.exports=n(1)},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(2),c=o(u),d=n(3),p=o(d),f=n(4),h="aws-btn",b=function(e){return c.default.createElement("a",e)},m=function(e){return c.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||e.placeholder&&!e.children,loading:!1,loadingEnd:!1,loadingStart:!1,blocked:!1},n.checkProps(e),n}return i(t,e),l(t,[{key:"componentDidMount",value:function(){this.container=this.button&&this.button.parentNode,(0,f.setCssEndEvent)(this.wrapper,"transition",this.clearStagedWrapperAnimation.bind(this))}},{key:"componentWillReceiveProps",value:function(e){this.checkPlaceholder(e),this.checkProps(e)}},{key:"getRootClassName",value:function(){var e=this.rootElement,t=this.props,n=t.type,o=t.size,s=t.placeholder,r=t.children,i=t.visible,a=t.progress,l=t.cssModule,u=this.state,c=u.loadingStart,d=u.loadingEnd,p=u.disabled,h=u.pressPosition,b=[this.rootElement,n&&e+"--"+n,o&&e+"--"+o,s&&!r&&e+"--placeholder",i&&e+"--visible",c&&e+"--start"||null,d&&e+"--end"||null,a&&e+"--progress"||null];return!0===p&&b.push(e+"--disabled"),h&&b.push(h),l&&l["aws-btn"]?(0,f.classToModules)(b,l):b.join(" ").trim().replace(/[\s]+/gi," ")}},{key:"checkProps",value:function(e){var t=e.to,n=e.href,o=e.target,s=e.element;this.extraProps.to=t||null,this.extraProps.href=n||null,this.extraProps.target=o||null,this.renderComponent=s||(this.props.href?b:m)}},{key:"checkPlaceholder",value:function(e){var t=e.placeholder,n=e.children;!0===t&&(n?this.setState({disabled:!1}):this.setState({disabled:!0}))}},{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(){(0,f.toggleMoveClasses)({element:this.container,root:this.rootElement,cssModule:this.props.cssModule});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.button&&this.props.action(this.container,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||(e.pressed=(new Date).getTime(),e.setState({pressPosition:e.rootElement+"--active",loading:e.props.progress}))},onMouseUp:function(t){if(!0===e.state.disabled||!0===e.state.blocked)return t.preventDefault(),void t.stopPropagation();e.clearTimer&&clearTimeout(e.clearTimer);var n=(new Date).getTime()-e.pressed;if(!1===e.props.progress&&!0===e.props.bubbles&&e.createBubble(t),"undefined"!=typeof window&&e.button){var o=new Event("action");e.button.dispatchEvent(o)}e.action(),e.clearTimer=setTimeout(function(){e.clearPress()},100-n)}};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(),s=o.left,r=n.offsetWidth,i=t.pageX<s+.3*r?"left":t.pageX>s+.65*r?"right":"middle";(0,f.toggleMoveClasses)({element:e.container,root:e.rootElement,cssModule:e.props.cssModule,state:i})}}:t.onMouseEnter=function(){e.container.classList.add((0,f.classToModules)([e.rootElement+"--middle"],e.props.cssModule))},t}},{key:"render",value:function(){var e=this,t=this.renderComponent;return c.default.createElement(t,a({style:this.props.style,className:this.getRootClassName(),role:"button"},this.extraProps,this.moveEvents()),c.default.createElement("span",{ref:function(t){e.button=t},className:(0,f.getClassName)(this.rootElement+"__container",this.props.cssModule)},c.default.createElement("span",{ref:function(t){e.wrapper=t},className:(0,f.getClassName)(this.rootElement+"__wrapper",this.props.cssModule)},c.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)},c.default.createElement("span",null,this.props.children)))))}}]),t}(c.default.Component);g.propTypes={action:p.default.func,bubbles:p.default.bool,children:p.default.node.isRequired,disabled:p.default.bool,element:p.default.func,href:p.default.string,loadingLabel:p.default.string,placeholder:p.default.bool,progress:p.default.bool,resultLabel:p.default.string,rootElement:p.default.string,moveEvents:p.default.bool,size:p.default.string,style:p.default.object,cssModule:p.default.object,target:p.default.string,to:p.default.string,type:p.default.string,visible:p.default.bool},g.defaultProps={action:null,bubbles:!1,cssModule:null,disabled:!1,element:null,href:null,loadingLabel:"Wait ..",moveEvents:!0,progress:!1,placeholder:!1,resultLabel:"Success!",rootElement:h,size:null,style:{},target:null,to:null,type:"primary",visible:!0},t.default=g},function(t,n){t.exports=e},function(e,n){e.exports=t},function(e,t,n){"use strict";function o(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments[1];if(!t)return e.join(" ").trim();for(var 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.element,n=e.root,s=e.cssModule,r=void 0===s?null:s,i=e.state,a=void 0===i?null:i;if(!t)return!1;if(!a)return t.classList.remove(o([n+"--"+l[0]],r),o([n+"--"+l[1]],r),o([n+"--"+l[2]],r)),!1;for(var u=l.filter(function(e){return e!==a}),c=u.length;c--;)t.classList.remove(o([n+"--"+u[c]],r));return t.classList.add(o([n+"--"+a],r)),!0}function a(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.toggleMoveClasses=i,t.createBubbleEffect=a;var l=["middle","left","right"]}])}); |
{ | ||
"name": "react-awesome-button", | ||
"version": "0.6.1", | ||
"version": "0.7.0", | ||
"description": "Performant, extendable, highly customisable, production ready React Component that renders an animated basic set of UI buttons", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -33,2 +33,3 @@ import React from 'react'; | ||
loadingLabel: PropTypes.string, | ||
placeholder: PropTypes.bool, | ||
progress: PropTypes.bool, | ||
@@ -56,2 +57,3 @@ resultLabel: PropTypes.string, | ||
progress: false, | ||
placeholder: false, | ||
resultLabel: 'Success!', | ||
@@ -72,3 +74,3 @@ rootElement: ROOTELM, | ||
this.state = { | ||
disabled: props.disabled, | ||
disabled: props.disabled || (props.placeholder && !props.children), | ||
loading: false, | ||
@@ -86,31 +88,69 @@ loadingEnd: false, | ||
componentWillReceiveProps(newProps) { | ||
this.checkPlaceholder(newProps); | ||
this.checkProps(newProps); | ||
} | ||
getRootClassName() { | ||
const { rootElement } = this; | ||
const { | ||
type, | ||
size, | ||
placeholder, | ||
children, | ||
visible, | ||
progress, | ||
cssModule, | ||
} = this.props; | ||
const { | ||
loadingStart, | ||
loadingEnd, | ||
disabled, | ||
pressPosition, | ||
} = this.state; | ||
const className = [ | ||
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, | ||
type && `${rootElement}--${type}`, | ||
size && `${rootElement}--${size}`, | ||
placeholder && !children && `${rootElement}--placeholder`, | ||
visible && `${rootElement}--visible`, | ||
(loadingStart && `${rootElement}--start`) || null, | ||
(loadingEnd && `${rootElement}--end`) || null, | ||
(progress && `${rootElement}--progress`) || null, | ||
]; | ||
if (this.state.disabled === true) { | ||
className.push(`${this.rootElement}--disabled`); | ||
if (disabled === true) { | ||
className.push(`${rootElement}--disabled`); | ||
} | ||
if (this.state.pressPosition) { | ||
className.push(this.state.pressPosition); | ||
if (pressPosition) { | ||
className.push(pressPosition); | ||
} | ||
if (this.props.cssModule && this.props.cssModule['aws-btn']) { | ||
return classToModules(className, this.props.cssModule); | ||
if (cssModule && cssModule['aws-btn']) { | ||
return classToModules(className, cssModule); | ||
} | ||
return className.join(' ').trim().replace(/[\s]+/ig, ' '); | ||
} | ||
checkProps(props) { | ||
this.extraProps.to = props.to || null; | ||
this.extraProps.href = props.href || null; | ||
this.extraProps.target = props.target || null; | ||
this.renderComponent = props.element || (this.props.href ? Anchor : Button); | ||
checkProps(newProps) { | ||
const { | ||
to, | ||
href, | ||
target, | ||
element, | ||
} = newProps; | ||
this.extraProps.to = to || null; | ||
this.extraProps.href = href || null; | ||
this.extraProps.target = target || null; | ||
this.renderComponent = element || (this.props.href ? Anchor : Button); | ||
} | ||
checkPlaceholder(newProps) { | ||
const { placeholder, children } = newProps; | ||
if (placeholder === true) { | ||
if (!children) { | ||
this.setState({ | ||
disabled: true, | ||
}); | ||
} else { | ||
this.setState({ | ||
disabled: false, | ||
}); | ||
} | ||
} | ||
} | ||
endLoading() { | ||
@@ -230,3 +270,2 @@ this.setState({ loadingEnd: true }); | ||
}; | ||
if (this.props.moveEvents === true) { | ||
@@ -259,3 +298,2 @@ events.onMouseMove = (event) => { | ||
} | ||
return events; | ||
@@ -262,0 +300,0 @@ } |
@@ -19,3 +19,3 @@ import React from 'react'; | ||
title: 'Primary, Secondary and Disabled buttons', | ||
text: ` | ||
jsx: ` | ||
<AwesomeButton bubbles>Primary Button</AwesomeButton> | ||
@@ -26,3 +26,3 @@ <AwesomeButton bubbles type="secondary">Secondary Button</AwesomeButton> | ||
<div> | ||
<AwesomeButton bubbles>Primary Button</AwesomeButton> | ||
<AwesomeButton bubbles cssModule={AwsBtnStyles}>Primary Button</AwesomeButton> | ||
<AwesomeButton bubbles cssModule={AwsBtnStyles} type="secondary">Secondary Button</AwesomeButton> | ||
@@ -36,3 +36,3 @@ <AwesomeButton cssModule={AwsBtnStyles} disabled>Disabled Button</AwesomeButton> | ||
use almost anything as the component's child. i.e. <img> or <svg> tags.`, | ||
text: ` | ||
jsx: ` | ||
<AwesomeButton | ||
@@ -113,3 +113,3 @@ type="facebook" | ||
`, | ||
text: ` | ||
jsx: ` | ||
<AwesomeButton | ||
@@ -154,3 +154,3 @@ progress | ||
`, | ||
text: ` | ||
jsx: ` | ||
<AwesomeButton | ||
@@ -193,3 +193,3 @@ cssModule={AwsBtnStylesThemeTwo} | ||
title: 'Hover Animations', | ||
text: ` | ||
jsx: ` | ||
<AwesomeButton>With Move Events</AwesomeButton> | ||
@@ -213,3 +213,3 @@ <AwesomeButton moveEvents={false}>Without Move Events</AwesomeButton>`, | ||
js: 'const Div = props => (<div {... props} />);', | ||
text: ` | ||
jsx: ` | ||
<AwesomeButton element={Div}>With Div Container</AwesomeButton>`, | ||
@@ -220,2 +220,17 @@ button: ( | ||
}, | ||
{ | ||
title: 'Placeholder', | ||
description: 'Render a placeholder before children data is available. Usefull if for any reason the children data is available in an asynchronous way.', | ||
jsx: ` | ||
<AwesomeButton placeholder></AwesomeButton> | ||
<AwesomeButton size="small" type="secondary" placeholder></AwesomeButton> | ||
<AwesomeButton size="icon" placeholder></AwesomeButton>`, | ||
button: ( | ||
<div> | ||
<AwesomeButton placeholder cssModule={AwsBtnStyles} /> | ||
<AwesomeButton size="small" type="secondary" placeholder cssModule={AwsBtnStyles} /> | ||
<AwesomeButton size="icon" placeholder cssModule={AwsBtnStyles} /> | ||
</div> | ||
), | ||
}, | ||
]; | ||
@@ -222,0 +237,0 @@ |
@@ -48,3 +48,3 @@ import React from 'react'; | ||
dangerouslySetInnerHTML={{ | ||
__html: Prism.highlight(example.text.trim(), Prism.languages.jsx), | ||
__html: Prism.highlight(example.jsx.trim(), Prism.languages.jsx), | ||
}} | ||
@@ -51,0 +51,0 @@ /> |
@@ -26,3 +26,3 @@ const ExtractTextPlugin = require('extract-text-webpack-plugin'); | ||
modules: true, | ||
localIdentName: '[hash:base64:4]', | ||
localIdentName: '[local]--[hash:base64:4]', | ||
}, | ||
@@ -29,0 +29,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
84293
1054