diff options
Diffstat (limited to 'src/react/Button.js')
-rw-r--r-- | src/react/Button.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/react/Button.js b/src/react/Button.js new file mode 100644 index 0000000..c628455 --- /dev/null +++ b/src/react/Button.js @@ -0,0 +1,37 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import SVGIcon from './SVGIcon.js'; + +const Button = ({btnType, size, className, iconName, onClick, disabled, children, ...other}) => ( + <button + onClick={onClick} + className={`sdc-button sdc-button__${btnType} ${size && `btn-${size}`} ${className} ${iconName}`} + disabled={disabled} + {...other}> + { + iconName ? + <SVGIcon name={iconName} label={children} labelPosition='right' /> + : + children + } + </button> +); + +Button.propTypes = { + btnType: PropTypes.string, + size: PropTypes.oneOf(['', 'default', 'x-small', 'small', 'medium', 'large']), + className: PropTypes.string, + iconName: PropTypes.string, + onClick: PropTypes.func, + disabled: PropTypes.bool +}; + +Button.defaultProps = { + btnType: 'primary', + size: '', + className: '', + iconName: '', + disabled: false +}; + +export default Button; |