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 54 55 56 57 58 59 60 61 62 63 64 65 | 1x 4x 4x 4x 1x | import PropTypes from 'prop-types' import ActionButtonLink from './ActionButtonLink.js' const ActionButtonWrapper = ({ children, href, target, disabled, isSubmit, isButton, link, linkFactory: Link = ActionButtonLink, ...attrs }) => { Iif (isSubmit) attrs.type = 'submit' Iif (isButton) attrs.type = 'button' return link ? ( <Link {...attrs} href={href} target={target} rel={target === '_blank' ? 'noopener' : undefined}> {children} </Link> ) : ( <button {...attrs} disabled={disabled}> {children} </button> ) } ActionButtonWrapper.propTypes = { /** * Content to be included in the button */ children: PropTypes.node, /** * Disable: faded with no interaction. */ disabled: PropTypes.bool, /** * URL to be added on the HTML link */ href: PropTypes.string, /** * HTML element: if true, render a link. Otherwise render a button */ link: PropTypes.bool, /** * Factory used to create navigation links */ linkFactory: PropTypes.func, /** * if true, type="submit" (needed when several buttons coexist under the same form) */ isSubmit: PropTypes.bool, /** * if true, type="button" (needed when several buttons coexist under the same form) */ isButton: PropTypes.bool, /** * Target to be added on the HTML link */ target: PropTypes.string } export default ActionButtonWrapper |