aboutsummaryrefslogtreecommitdiffstats
path: root/src/react/Button.js
blob: c628455fa03c96605f5cee572bb053cb37923303 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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;