All files / atom/button/src Button.js

100% Statements 4/4
100% Branches 0/0
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 47 48 49 50 51 52 53            1x 16x   16x             1x                                                                        
import {forwardRef} from 'react'
 
import PropTypes from 'prop-types'
 
import {useElement} from './config.js'
 
const Button = forwardRef(({children, className, ...attrs}, forwardedRef) => {
  const [Element, props] = useElement({...attrs})
 
  return (
    <Element ref={forwardedRef} className={className} {...props} {...attrs}>
      {children}
    </Element>
  )
})
 
Button.propTypes = {
  /**
   * Render the passed value as the correspondent HTML tag or the component if a function is passed
   */
  as: PropTypes.elementType,
  /**
   * Content to be included in the button
   */
  children: PropTypes.node,
  /**
   * CSS class to be added to the button
   */
  className: PropTypes.string,
  /**
   * HTML element: if true, render a link. Otherwise render a button
   */
  link: PropTypes.bool,
  /**
   * URL to be added on the HTML link
   */
  href: PropTypes.string,
  /**
   * Target to be added on the HTML link
   */
  target: PropTypes.string,
  /**
   * Disable: faded with no interaction.
   */
  disabled: PropTypes.bool,
  /**
   * Factory used to create navigation links
   */
  linkFactory: PropTypes.func
}
 
export default Button