feat: connect CV request modal to command palette
All checks were successful
Deploy Portfolio to VPS / deploy (push) Successful in 58s

This commit is contained in:
Chneemann 2026-10-04 19:30:41 +02:00
parent 359cdddaf6
commit dcc077184c
No known key found for this signature in database
3 changed files with 13 additions and 8 deletions

View file

@ -26,7 +26,7 @@ export default function CommandPalette() {
cmd.category.toLowerCase().includes(search.toLowerCase()), cmd.category.toLowerCase().includes(search.toLowerCase()),
); );
// Global hotkeys listener (Cmd/Ctrl + K to toggle, ESC to close) // Global hotkeys listener (Cmd/Ctrl + K to toggle, ESC to close, close on CV modal)
useEffect(() => { useEffect(() => {
const handleKeyDown = (e: KeyboardEvent) => { const handleKeyDown = (e: KeyboardEvent) => {
if ((e.metaKey || e.ctrlKey) && e.key === "k") { if ((e.metaKey || e.ctrlKey) && e.key === "k") {
@ -38,13 +38,16 @@ export default function CommandPalette() {
}; };
const handleCustomToggle = () => setIsOpen((prev) => !prev); const handleCustomToggle = () => setIsOpen((prev) => !prev);
const handleCloseModal = () => setIsOpen(false);
window.addEventListener("keydown", handleKeyDown); window.addEventListener("keydown", handleKeyDown);
window.addEventListener("toggle-cmd-k", handleCustomToggle); window.addEventListener("toggle-cmd-k", handleCustomToggle);
window.addEventListener("open-cv-modal", handleCloseModal);
return () => { return () => {
window.removeEventListener("keydown", handleKeyDown); window.removeEventListener("keydown", handleKeyDown);
window.removeEventListener("toggle-cmd-k", handleCustomToggle); window.removeEventListener("toggle-cmd-k", handleCustomToggle);
window.removeEventListener("open-cv-modal", handleCloseModal);
}; };
}, []); }, []);

View file

@ -2,7 +2,7 @@
import { useTranslations } from "next-intl"; import { useTranslations } from "next-intl";
import SocialLinks from "./Social"; import SocialLinks from "./Social";
import { useState } from "react"; import { useEffect, useState } from "react";
import CvRequestModal from "./CvRequestModal"; import CvRequestModal from "./CvRequestModal";
/** /**
@ -14,6 +14,12 @@ export default function Hero() {
const [isCvModalOpen, setIsCvModalOpen] = useState(false); const [isCvModalOpen, setIsCvModalOpen] = useState(false);
useEffect(() => {
const handleOpenCvModal = () => setIsCvModalOpen(true);
window.addEventListener("open-cv-modal", handleOpenCvModal);
return () => window.removeEventListener("open-cv-modal", handleOpenCvModal);
}, []);
return ( return (
<section className="relative pt-18 py-6 px-4 md:px-6 md:pt-24 max-w-5xl mx-auto"> <section className="relative pt-18 py-6 px-4 md:px-6 md:pt-24 max-w-5xl mx-auto">
<div className="grid grid-cols-1 md:grid-cols-12 gap-3 items-center z-10 w-full"> <div className="grid grid-cols-1 md:grid-cols-12 gap-3 items-center z-10 w-full">

View file

@ -31,16 +31,12 @@ export const getCommands = (
}, },
}, },
{ {
id: "download-cv", id: "request-cv",
label: tCommands("downloadCV"), label: tCommands("downloadCV"),
category: tCommands("catQuickActions"), category: tCommands("catQuickActions"),
icon: "📄", icon: "📄",
action: () => { action: () => {
window.open( window.dispatchEvent(new CustomEvent("open-cv-modal"));
"/assets/downloads/Andre_Kempf_Lebenslauf.pdf",
"_blank",
"noopener,noreferrer",
);
}, },
}, },
{ {