feat: connect CV request modal to command palette
All checks were successful
Deploy Portfolio to VPS / deploy (push) Successful in 58s
All checks were successful
Deploy Portfolio to VPS / deploy (push) Successful in 58s
This commit is contained in:
parent
359cdddaf6
commit
dcc077184c
3 changed files with 13 additions and 8 deletions
|
|
@ -26,7 +26,7 @@ export default function CommandPalette() {
|
|||
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(() => {
|
||||
const handleKeyDown = (e: KeyboardEvent) => {
|
||||
if ((e.metaKey || e.ctrlKey) && e.key === "k") {
|
||||
|
|
@ -38,13 +38,16 @@ export default function CommandPalette() {
|
|||
};
|
||||
|
||||
const handleCustomToggle = () => setIsOpen((prev) => !prev);
|
||||
const handleCloseModal = () => setIsOpen(false);
|
||||
|
||||
window.addEventListener("keydown", handleKeyDown);
|
||||
window.addEventListener("toggle-cmd-k", handleCustomToggle);
|
||||
window.addEventListener("open-cv-modal", handleCloseModal);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener("keydown", handleKeyDown);
|
||||
window.removeEventListener("toggle-cmd-k", handleCustomToggle);
|
||||
window.removeEventListener("open-cv-modal", handleCloseModal);
|
||||
};
|
||||
}, []);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import { useTranslations } from "next-intl";
|
||||
import SocialLinks from "./Social";
|
||||
import { useState } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import CvRequestModal from "./CvRequestModal";
|
||||
|
||||
/**
|
||||
|
|
@ -14,6 +14,12 @@ export default function Hero() {
|
|||
|
||||
const [isCvModalOpen, setIsCvModalOpen] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const handleOpenCvModal = () => setIsCvModalOpen(true);
|
||||
window.addEventListener("open-cv-modal", handleOpenCvModal);
|
||||
return () => window.removeEventListener("open-cv-modal", handleOpenCvModal);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<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">
|
||||
|
|
|
|||
|
|
@ -31,16 +31,12 @@ export const getCommands = (
|
|||
},
|
||||
},
|
||||
{
|
||||
id: "download-cv",
|
||||
id: "request-cv",
|
||||
label: tCommands("downloadCV"),
|
||||
category: tCommands("catQuickActions"),
|
||||
icon: "📄",
|
||||
action: () => {
|
||||
window.open(
|
||||
"/assets/downloads/Andre_Kempf_Lebenslauf.pdf",
|
||||
"_blank",
|
||||
"noopener,noreferrer",
|
||||
);
|
||||
window.dispatchEvent(new CustomEvent("open-cv-modal"));
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue