All files / app/src/shared/lib/optional-link-wrapper optional-link-wrapper.tsx

100% Statements 11/11
75% Branches 3/4
100% Functions 1/1
100% Lines 11/11

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 221x               1x 376x 376x 376x 1x 1x 1x   371x   376x   376x  
import { FC, PropsWithChildren } from 'react'
import Link from 'next/link'
 
export interface OptionalLinkWrapperProps {
  href?: string
  newTab?: boolean
}
 
export const OptionalLinkWrapper: FC<PropsWithChildren<OptionalLinkWrapperProps>> = ({ children, href, newTab }) => {
  return (
    <>
      {href ? (
        <Link href={href}>
          <a {...(newTab && { target: '_blank', rel: 'noreferrer noopener' })}>{children}</a>
        </Link>
      ) : (
        children
      )}
    </>
  )
}