Skip to content

Commit

Permalink
Refector: 데스크탑 환경에서 사이드바 닫히는 애니메이션 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoon-kyungLee committed Mar 26, 2024
1 parent e922039 commit 2d156c2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion co-kkiri/src/components/commons/SideBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default function SideBar({ onClick, onClose }: SideBarProps) {
</ModalLayout>
) : (
<S.Background>
<SideBarList onClick={onClick} />
<SideBarList />
</S.Background>
)}
</>
Expand Down
19 changes: 8 additions & 11 deletions co-kkiri/src/layouts/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,27 @@ import Gnb from "@/components/commons/Gnb";
import SideBar from "@/components/commons/SideBar";
import { useWindowSize } from "usehooks-ts";
import { slideIn, slideOut } from "@/utils/animation";
import { useState } from "react";

export default function Navigation() {
const [isOpen, setIsOpen] = useState(false);
const isSideBarOpen = useSideBarStore((state) => state.isSideBarOpen);
const toggleSideBar = useSideBarStore((state) => state.toggleSideBar);

const { width: screenWidth } = useWindowSize();
const isTabletOrMobile = screenWidth < 1200;

const handleSideBarOpen = () => {
const handleSideBar = () => {
toggleSideBar();
};

return (
<>
<Gnb onSideBarClick={handleSideBarOpen} />
{isSideBarOpen && (
<SideBarWrapper $isOpen={isSideBarOpen}>
{isTabletOrMobile ? (
isSideBarOpen && <SideBar onClick={handleSideBarOpen} onClose={handleSideBarOpen} />
) : (
<SideBar onClose={() => {}} />
)}
</SideBarWrapper>
)}
<Gnb onSideBarClick={handleSideBar} />
<SideBarWrapper $isOpen={isSideBarOpen}>
{isSideBarOpen && isTabletOrMobile && <SideBar onClick={handleSideBar} onClose={handleSideBar} />}
</SideBarWrapper>
<SideBarWrapper $isOpen={isSideBarOpen}>{!isTabletOrMobile && <SideBar onClose={() => {}} />}</SideBarWrapper>
<OutletWrapper $isOpen={isSideBarOpen}>
<Outlet />
</OutletWrapper>
Expand Down

0 comments on commit 2d156c2

Please sign in to comment.