diff --git a/src/app/page.tsx b/src/app/page.tsx index 75e4eb5e..e9fd9878 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -11,6 +11,8 @@ import { ExperienceSection } from "@/components/sections/experience"; import Intro from "@/components/sections/hero"; import { ProjectsSection } from "@/components/sections/projects"; import { PublicationsSection } from "@/components/sections/publications"; +import { AnimatePresence } from "framer-motion"; + import { SkillsSection } from "@/components/sections/skills"; import { UnifiedFilterBar } from "@/components/unified-filter-bar"; @@ -63,7 +65,7 @@ const Home = () => { - {showFilter && } + {showFilter && } ); }; diff --git a/src/components/header.tsx b/src/components/header.tsx index 044773c3..07e9dcdd 100644 --- a/src/components/header.tsx +++ b/src/components/header.tsx @@ -15,7 +15,8 @@ export const sections = [ const Title = ({ onClick }: { onClick: (e: React.MouseEvent) => void }) => ( diff --git a/src/components/search.tsx b/src/components/search.tsx index 5354ba49..a46558a5 100644 --- a/src/components/search.tsx +++ b/src/components/search.tsx @@ -8,17 +8,25 @@ export const Searchbar = ({ query, setQuery, className, + autoFocus = false, }: { placeholder: string; query: string; setQuery: (query: string) => void; className?: string; + autoFocus?: boolean; }) => { const inputId = useId(); const inputRef = useRef(null); const [isFocused, setIsFocused] = useState(false); + const [isMac, setIsMac] = useState(false); useEffect(() => { + setIsMac( + globalThis.window !== undefined && + /Mac|iPod|iPhone|iPad/.test(globalThis.navigator.platform), + ); + const handleKeyDown = (e: KeyboardEvent) => { const isSearchShortcut = (e.key === "k" && (e.metaKey || e.ctrlKey)) || e.key === "/"; @@ -56,7 +64,7 @@ export const Searchbar = ({ maxLength={100} onFocus={() => setIsFocused(true)} onBlur={() => setIsFocused(false)} - autoFocus + autoFocus={autoFocus} autoCapitalize="none" autoComplete="off" autoCorrect="off" @@ -64,7 +72,11 @@ export const Searchbar = ({ /> {!isFocused && !query && ( -
+
+ + {isMac ? "⌘" : "Ctrl"} K + + or / diff --git a/src/components/unified-filter-bar.tsx b/src/components/unified-filter-bar.tsx index f074d325..acf8c240 100644 --- a/src/components/unified-filter-bar.tsx +++ b/src/components/unified-filter-bar.tsx @@ -2,6 +2,7 @@ import { XMarkIcon } from "@heroicons/react/24/outline"; import { Button } from "@heroui/react"; +import { motion } from "framer-motion"; import { useFilter } from "@/contexts/filter"; import { useSearch } from "@/contexts/search"; @@ -25,7 +26,13 @@ export const UnifiedFilterBar = () => { }; return ( -
+
{ query={query} setQuery={setQuery} className="rounded-l-2xl rounded-r-none border-r-0" + autoFocus={false} /> {
)}
-
+ ); };