Create Button component

This commit is contained in:
SleepWalker
2016-05-01 10:01:32 +03:00
parent eb9937bf7d
commit a8af63b46c
2 changed files with 43 additions and 6 deletions

View File

@@ -5,6 +5,7 @@ import { intlShape } from 'react-intl';
import icons from './icons.scss';
import styles from './form.scss';
import buttons from './buttons.scss';
export class Input extends Component {
static displayName = 'Input';
@@ -160,6 +161,46 @@ export class Checkbox extends Component {
}
}
export class Button extends Component {
static displayName = 'Button';
static propTypes = {
label: PropTypes.oneOfType([
PropTypes.shape({
id: PropTypes.string
}),
PropTypes.string
]).isRequired,
block: PropTypes.bool,
color: PropTypes.oneOf(['green', 'blue', 'red', 'lightViolet', 'darkBlue'])
};
static contextTypes = {
intl: intlShape.isRequired
};
render() {
const { color = 'green', block } = this.props;
const props = {
...this.props
};
if (props.label.id) {
props.label = this.context.intl.formatMessage(props.label);
}
return (
<button className={classNames(buttons[color], {
[buttons.block]: block
})} {...props}>
{props.label}
</button>
);
}
}
export class Form extends Component {
static displayName = 'Form';