mirror of
https://github.com/gabehf/Koito.git
synced 2026-03-17 03:06:42 -07:00
chore: initial public commit
This commit is contained in:
commit
fc9054b78c
250 changed files with 32809 additions and 0 deletions
33
client/app/components/sidebar/SidebarSearch.tsx
Normal file
33
client/app/components/sidebar/SidebarSearch.tsx
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import { useEffect, useState } from "react";
|
||||
import SidebarItem from "./SidebarItem";
|
||||
import { Search } from "lucide-react";
|
||||
import SearchModal from "../modals/SearchModal";
|
||||
|
||||
interface Props {
|
||||
size: number
|
||||
}
|
||||
|
||||
export default function SidebarSearch({ size } : Props) {
|
||||
const [open, setModalOpen] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
const handleKeyDown = (e: KeyboardEvent) => {
|
||||
if (e.key === '/' && !open) {
|
||||
e.preventDefault();
|
||||
setModalOpen(true);
|
||||
}
|
||||
};
|
||||
document.addEventListener('keydown', handleKeyDown);
|
||||
return () => document.removeEventListener('keydown', handleKeyDown);
|
||||
}, [open]);
|
||||
|
||||
return (
|
||||
<SidebarItem
|
||||
space={26}
|
||||
onClick={() => setModalOpen(true)}
|
||||
name="Search"
|
||||
keyHint="/"
|
||||
children={<Search size={size}/>} modal={<SearchModal open={open} setOpen={setModalOpen} />}
|
||||
/>
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue