apeman-react-button
Version:
apeman react package for button component.
78 lines (62 loc) • 1.6 kB
JSX
/**
* Button component.
* @constructor ApButton
*/
;
import React, {PropTypes as types} from 'react';
import classnames from 'classnames';
import {ApTouchMixin, ApPureMixin} from 'apeman-react-mixins';
/** @lends ApButton */
let ApButton = React.createClass({
//--------------------
// Specs
//--------------------
propTypes: {
disabled: types.bool,
primary: types.bool,
danger: types.bool,
wide: types.bool,
href: types.string,
id: types.string,
hidden: types.bool
},
mixins: [
ApTouchMixin,
ApPureMixin
],
getInitialState() {
return {};
},
getDefaultProps() {
return {
disabled: false,
primary: false,
danger: false,
wide: false,
href: null,
id: null,
hidden: false
}
},
render() {
let s = this;
let {props} = s;
return (
<a className={classnames("ap-button", props.className, {
'ap-button-primary': props.primary,
'ap-button-danger': props.danger,
'ap-button-wide': props.wide,
'ap-button-disabled': props.disabled,
'ap-button-hidden': props.hidden
})} href={props.href}
id={props.id}
style={Object.assign({}, props.style)}
>{props.children}
</a>
);
}
//------------------
// Helper
//------------------
});
module.exports = ApButton;