cf-component-button
Advanced tools
Comparing version 2.1.2 to 2.2.0
@@ -7,9 +7,21 @@ 'use strict'; | ||
function Button(props) { | ||
var disabled = props.disabled; | ||
var loading = props.loading; | ||
var type = props.submit ? 'submit' : 'button'; | ||
var className = 'cf-btn cf-btn--' + props.type; | ||
if (loading) { | ||
className += ' cf-btn--loading'; | ||
} | ||
// Unless the disabled state is explicitly set, the button is disabled when loading. | ||
var isDisabled = disabled ? loading : disabled; | ||
return React.createElement( | ||
'button', | ||
{ | ||
type: type, | ||
className: className, | ||
disabled: props.disabled, | ||
disabled: isDisabled, | ||
onClick: props.onClick }, | ||
@@ -22,7 +34,10 @@ props.children | ||
onClick: PropTypes.func.isRequired, | ||
submit: PropTypes.bool, | ||
type: PropTypes.oneOf(['default', 'primary', 'success', 'warning', 'error']).isRequired, | ||
disabled: PropTypes.bool | ||
disabled: PropTypes.bool, | ||
loading: PropTypes.bool | ||
}; | ||
Button.defaultProps = { | ||
type: 'default' | ||
type: 'default', | ||
submit: false | ||
}; | ||
@@ -29,0 +44,0 @@ ; |
{ | ||
"name": "cf-component-button", | ||
"description": "CloudFlare Button Component", | ||
"version": "2.1.2", | ||
"version": "2.2.0", | ||
"main": "lib/index.js", | ||
@@ -6,0 +6,0 @@ "author": "James Kyle <jkyle@cloudflare.com>", |
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
2471
47