All files / src/components/ui/links ExternalLink.tsx

36.66% Statements 11/30
100% Branches 0/0
0% Functions 0/1
36.66% Lines 11/30

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 311x 1x 1x 1x 1x 1x 1x 1x 1x                                       1x 1x  
import React from "react";
import { EmailIcon, MapPinIcon, PhoneIcon } from "../icons";
 
type ExternalLinkProps = {
  type: "email" | "phone" | "location";
  value: string;
};
 
const ExternalLink: React.FC<ExternalLinkProps> = ({ type, value }) => {
  const hrefPrefix = {
    email: "mailto:",
    phone: "tel:",
    location: "https://maps.google.com/?q="}[type];

  const Icon = {
    email: EmailIcon,
    phone: PhoneIcon,
    location: MapPinIcon}[type];

  return (
    <li>
      <a href={`${hrefPrefix}${value}`} target="_blank" rel="noopener noreferrer" className="flex items-center gap-4.5 text-dark-3 dark:text-gray-300 hover:text-blue dark:hover:text-blue">
        <Icon />
        {value}
      </a>
    </li>
  );
};
 
export default ExternalLink;