primer-react
Version:
Primer react components
30 lines (24 loc) • 660 B
JavaScript
import React from 'react'
import PropTypes from 'prop-types'
import classnames from 'classnames'
import {withSystemProps, COMMON} from './system-props'
function BranchName({children, href, is: Tag, className}) {
// We don't want someone to use href on a non tag
if (Tag !== 'a') {
href = null
}
return (
<Tag href={href} className={classnames('branch-name', className)}>
{children}
</Tag>
)
}
BranchName.defaultProps = {
is: 'a'
}
BranchName.propTypes = {
children: PropTypes.node,
href: PropTypes.string,
is: PropTypes.oneOfType([PropTypes.string, PropTypes.func])
}
export default withSystemProps(BranchName, COMMON)