Last active
August 29, 2015 14:06
-
-
Save kentcdodds/795951bab29d4c16e370 to your computer and use it in GitHub Desktop.
Travis build badge as a React Component
This file contains hidden or 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
/** @jsx React.DOM */ | |
'use strict'; | |
var React = require('react'); | |
var BuildBadge = React.createClass({ | |
propTypes: { | |
owner: React.PropTypes.string.isRequired, | |
repo: React.PropTypes.string.isRequired, | |
branch: React.PropTypes.string | |
}, | |
getDefaultProps: function() { | |
return { | |
branch: 'master' | |
}; | |
}, | |
render: function() { | |
var owner = this.props.owner; | |
var repo = this.props.repo; | |
var link = 'https://travis-ci.org/' + owner + '/' + repo; | |
var branch = encodeURIComponent(this.props.branch); | |
var url = link + '.svg?branch=' + branch; | |
return <a href={link}><img src={url} /></a>; | |
} | |
}); | |
module.exports = BuildBadge; |
This file contains hidden or 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'); | |
var BuildBadge = require('./travis-build-badge'); | |
React.renderComponent(<BuildBadge owner="kentcdodds" repo="react-formly" />, document.body); | |
// or | |
React.renderComponent(<BuildBadge owner="kentcdodds" repo="react-formly" branch="gh-pages" />, document.body); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment