Jack Maclennan Portfolio
    Preparing search index...
    • Modal component for consistent styling across the application.

              <div className="flex h-full flex-col px-6 py-6 text-slate-700 sm:px-8 sm:py-8 dark:text-slate-300">
      <div className="flex items-center justify-between border-b border-slate-200 pb-6 dark:border-slate-700">
      <span className="text-xl font-semibold text-slate-800 dark:text-slate-200">Menu</span>
      <button
      type="button"
      aria-label="exit hamburger menu"
      onClick={handleClose}
      className="group flex h-12 w-12 items-center justify-center rounded-xl transition-all hover:bg-slate-100 dark:hover:bg-slate-800"
      >
      <FontAwesomeIcon
      className="h-6 w-6 text-slate-600 transition-colors group-hover:text-emerald-600 dark:text-slate-400 dark:group-hover:text-emerald-400"
      icon={faX}
      />
      </button>
      </div>
      <nav className="flex-1 overflow-y-auto pt-6">
      <div className="flex flex-col gap-6">
      <div className="flex flex-col gap-3">
      <span className="px-3 text-xs font-semibold tracking-widest text-slate-400 uppercase dark:text-slate-500">
      Connect
      </span>
      <div className="flex justify-center">
      <SocialIcons />
      </div>
      </div>
      <div className="flex flex-col gap-3">
      <span className="px-3 text-xs font-semibold tracking-widest text-slate-400 uppercase dark:text-slate-500">
      Explore
      </span>
      <SiteLinks className="flex flex-col" onClick={handleClose} />
      </div>
      </div>
      </nav>
      </div>
      </Modal>
      </div>

      Parameters

      • props: ModalProps

        Modal configuration and content.

        • isOpen: boolean
        • onClose: () => void
        • children: ReactNode
        • Optionaltitle?: string

      Returns ReactPortal | null

      The rendered Modal component.

      export default function Modal({ isOpen, onClose, children, title = 'Modal' }: ModalProps) {
      const modalRef = useRef<HTMLDivElement>(null);

      useEffect(() => {
      const handleEscape = (event: KeyboardEvent) => {
      if (event.key === 'Escape') {
      onClose();
      }
      };

      if (isOpen) {
      document.addEventListener('keydown', handleEscape);
      document.body.style.overflow = 'hidden';
      modalRef.current?.focus();
      }

      return () => {
      document.removeEventListener('keydown', handleEscape);
      document.body.style.overflow = 'unset';
      };
      }, [isOpen, onClose]);

      if (!isOpen) return null;

      const modalContent = (
      <>
      <div className="fixed inset-0 z-9999 bg-black/50 backdrop-blur-sm" onClick={onClose} aria-hidden="true" />
      <div
      ref={modalRef}
      className="fixed top-0 right-0 z-10000 h-full w-2/3 translate-x-0 transform bg-white/95 shadow-2xl backdrop-blur-xl transition-transform duration-300 ease-in-out dark:bg-slate-900/95"
      role="dialog"
      aria-modal="true"
      aria-labelledby={title}
      tabIndex={-1}
      >
      {children}
      </div>
      </>
      );

      return createPortal(modalContent, document.body);
      }