Last active
August 29, 2015 14:17
-
-
Save jamesslock/767b36b2760a2e409d9d to your computer and use it in GitHub Desktop.
Simple React Button Component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var React = require('react'), | |
Classable = require('../mixins/classable.jsx'); | |
var Button = React.createClass({ | |
mixins: [Classable], | |
buildAriaLabel: function() { | |
return "" + this.props.ariaLabel; | |
}, | |
render: function() { | |
var classes = this.getClasses('btn'); | |
var buttonProps = { | |
className: classes | |
}; | |
if (this.props.buttonType === "link") { | |
return ( | |
<a {...buttonProps} aria-label={this.buildAriaLabel()}> | |
{this.props.children} | |
</a> | |
) | |
} | |
else { | |
return ( | |
<button {...buttonProps} aria-label={this.buildAriaLabel()}> | |
{this.props.children} | |
</button> | |
) | |
} | |
} | |
}); | |
module.exports = Button; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment