-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 헤더 컴포넌트 초안 및 스토리북 추가 * feat: 헤더 검색바 컴포넌트 추가 * feat: 홈페이지 헤더 검색바 숨김처리 * feat: 헤더 검색바 인터렉션 테스트 작성
- Loading branch information
Showing
11 changed files
with
1,308 additions
and
671 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
"use client"; | ||
|
||
import { | ||
Popover, | ||
PopoverButton, | ||
PopoverPanel, | ||
PopoverProps, | ||
Transition, | ||
} from "@headlessui/react"; | ||
import { SearchStoreProvider } from "@lib/providers/SearchStoreProvider"; | ||
import SearchBar from "@ui/SearchBar"; | ||
import SearchList from "@ui/SearchList"; | ||
import { usePathname } from "next/navigation"; | ||
import { MouseEventHandler } from "react"; | ||
|
||
interface HeaderSearchProps extends PopoverProps {} | ||
|
||
function HeaderSearch({ className = "", ...props }: HeaderSearchProps) { | ||
const pathname = usePathname(); | ||
if (pathname === "/") return null; | ||
|
||
const handlePopoverButtonClick: ( | ||
open: boolean | ||
) => MouseEventHandler<HTMLDivElement> = (open) => (e) => { | ||
if (open) { | ||
e.preventDefault(); | ||
} | ||
|
||
const eventTarget = e.target as HTMLElement; | ||
if (eventTarget.tagName === "INPUT") { | ||
eventTarget.focus(); | ||
} | ||
}; | ||
|
||
const popoverDefaultStyle = | ||
"flex h-14 flex-col items-center overflow-hidden transition-all duration-300"; | ||
const popoverOpenStyle = | ||
"data-[open]:h-[70vh] data-[open]:pb-16 data-[open]:shadow-2xl data-[open]:rounded-b-2xl"; | ||
|
||
return ( | ||
<Popover | ||
className={`${popoverDefaultStyle} ${popoverOpenStyle} ${className}`} | ||
{...props}> | ||
{({ open }) => ( | ||
<SearchStoreProvider> | ||
<PopoverButton | ||
as={SearchBar} | ||
role="button" | ||
aria-label="헤더 검색바" | ||
className={`shrink-0 transition-transform duration-300 focus:outline-none ${open ? "translate-y-7" : ""}`} | ||
onClick={handlePopoverButtonClick(open)} | ||
/> | ||
<Transition | ||
enter="duration-200 ease-out" | ||
enterFrom="scale-75 opacity-0 traslate-y-0" | ||
enterTo="scale-100 opacity-100 translate-y-16" | ||
leave="duration-200 ease-out" | ||
leaveFrom="scale-100 opacity-100 translate-y-16" | ||
leaveTo="scale-75 opacity-0 translate-y-0"> | ||
<PopoverPanel className="w-full min-w-64 max-w-[40rem] shrink grow origin-top overflow-scroll"> | ||
<SearchList /> | ||
</PopoverPanel> | ||
</Transition> | ||
</SearchStoreProvider> | ||
)} | ||
</Popover> | ||
); | ||
} | ||
|
||
export default HeaderSearch; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import HeaderSearch from "@ui/Header/HeaderSearch"; | ||
|
||
function Header() { | ||
return ( | ||
<div className="fixed left-0 top-0 flex h-14 w-full items-center justify-between border-b border-zinc-300"> | ||
<div>로고</div> | ||
<div className="relative h-full grow"> | ||
<HeaderSearch /> | ||
</div> | ||
<div>계정</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default Header; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.