All files / atom/tag/src/Actionable TagLink.js

100% Statements 4/4
50% Branches 1/2
100% Functions 1/1
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46              1x 1x                       1x                                           1x      
import {forwardRef} from 'react'
 
import PropTypes from 'prop-types'
 
import {getLinkTypesString} from './settings.js'
 
// eslint-disable react/no-unused-prop-types
const TagLink = forwardRef(({href, target, rel, className, role, children, ...props}, forwardRef) => (
  <a
    ref={forwardRef}
    href={href}
    target={target}
    className={className}
    role={role}
    {...{...props, ...(rel && {rel: getLinkTypesString(rel)})}}
  >
    {children}
  </a>
))
 
TagLink.propTypes = {
  /**
   * URL to be added on the HTML link
   */
  href: PropTypes.string, // eslint-disable-line react/no-unused-prop-types
  /**
   * Target to be added on the HTML link
   */
  target: PropTypes.string, // eslint-disable-line react/no-unused-prop-types
  /**
   * Role to be added on the HTML link
   */
  role: PropTypes.string, // eslint-disable-line react/no-unused-prop-types
  /**
   * Class name to be added on the HTML link
   */
  className: PropTypes.string // eslint-disable-line react/no-unused-prop-types
  /**
   * Content to be included in the link
   */
}
 
TagLink.displayName = 'TagLink'
 
export default TagLink