Skip to content

Commit

Permalink
handle ⌘ K for search mode
Browse files Browse the repository at this point in the history
  • Loading branch information
gholi-dev committed Aug 12, 2024
1 parent 91355ca commit a6e7fb1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 151 deletions.
21 changes: 20 additions & 1 deletion src/components/Header/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,22 @@ const Header = ({ setShowSidebar }) => {
return false;
});

useEffect(() => {
const handleKeydown = event => {
if ((event.metaKey || event.ctrlKey) && event.key === "k") {
event.preventDefault();
setSearchOpen(prev => !prev);
}
if (event.key === "Escape") {
setSearchOpen(false);
}
};
window.addEventListener("keydown", handleKeydown);
return () => {
window.removeEventListener("keydown", handleKeydown);
};
}, []);

useEffect(
() => {
if (darkMode) {
Expand Down Expand Up @@ -229,7 +245,10 @@ const Header = ({ setShowSidebar }) => {
{item.title}
{item.type === "video" &&
<Fragment>
{" "}- <span className="bg-[#2563eb22] px-2 text-[12px] py-1 rounded-lg">همراه ویدیو</span>
{" "}-{" "}
<span className="bg-[#2563eb22] px-2 text-[12px] py-1 rounded-lg">
همراه ویدیو
</span>
</Fragment>}
</p>
</div>
Expand Down
150 changes: 0 additions & 150 deletions src/pages/components.mdx

This file was deleted.

0 comments on commit a6e7fb1

Please sign in to comment.