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 | 8x 21x 21x 21x 1x 1x 20x 1x 19x 8x 8x | import React from 'react'; import PropTypes from 'prop-types'; import { removeSomeProps } from 'src/utils/componentHelpers'; import { Link as ReactRouterLink } from 'react-router-dom'; import { spaceProps, typography } from 'src/utils/styledHelpers'; import { emailHrefString } from './utils'; export const LinkComponent = ({ children, emailHref, to, ...props }) => { const trimmedProps = removeSomeProps(props, Object.keys({ ...spaceProps.propTypes, ...typography.propTypes })); const emailLinkHref = emailHrefString(emailHref); if (to) { const linkProps = { to, ...trimmedProps, }; return ( <ReactRouterLink {...linkProps}> {children} </ReactRouterLink> ); } if (emailLinkHref) { return ( <a href={emailLinkHref} {...trimmedProps}> {children} </a> ); } return ( <a {...trimmedProps}> {children} </a> ); }; LinkComponent.propTypes = { children: PropTypes.any.isRequired, emailHref: PropTypes.shape({ bcc: PropTypes.string, body: PropTypes.string, cc: PropTypes.string, subject: PropTypes.string, to: PropTypes.string, }), to: PropTypes.string, }; LinkComponent.defaultProps = { emailHref: {}, to: '', }; |