All files / app / resume Close.tsx

100% Statements 8/8
50% Branches 1/2
100% Functions 4/4
100% Lines 8/8

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                7x   7x   1x 1x       2x   2x 2x       7x                    
'use client';
 
import Link from 'next/link';
import { useRouter } from 'next/navigation';
import { useEffect } from 'react';
import type { JSX } from 'react';
 
export function Close(): JSX.Element {
  const router = useRouter();
 
  useEffect(() => {
    function handleKeyDown(event: KeyboardEvent): void {
      Eif (event.key === 'Escape') {
        router.push('/');
      }
    }
 
    document.addEventListener('keydown', handleKeyDown);
 
    return (): void => {
      document.removeEventListener('keydown', handleKeyDown);
    };
  }, [router]);
 
  return (
    <Link
      aria-label="Close résumé"
      className="fixed top-4 right-4 z-10 flex h-11 w-11 items-center justify-center rounded-lg border-2 border-black/5 bg-black/5 text-black transition duration-300 hover:border-black/10 hover:bg-black/10 lg:border-[oklch(1_0_0/.05)] lg:bg-[oklch(1_0_0/.05)] lg:text-white lg:hover:border-[oklch(1_0_0/.1)] lg:hover:bg-[oklch(1_0_0/.1)] print:hidden"
      href="/"
    >
      <span aria-hidden>{'✕'}</span>
    </Link>
  );
}