From 1c158b56399e9770f28bd18ad2532cf1e7e8e80f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=95=EC=84=B8=EC=A4=80?= Date: Sat, 11 Jan 2025 03:37:01 +0900 Subject: [PATCH 01/12] =?UTF-8?q?feat:=20post=20api=20=EC=97=B0=EA=B2=B0?= =?UTF-8?q?=20=EB=B0=8F=20=EA=B8=B0=EB=B3=B8=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/feed/Post.tsx | 13 +- src/components/layout/SideBar.tsx | 91 +++++++++++-- src/components/modals/CreatePostModal.tsx | 148 ++++++++++++++++++++++ src/pages/MainPage.tsx | 119 ++++++++--------- 4 files changed, 302 insertions(+), 69 deletions(-) create mode 100644 src/components/modals/CreatePostModal.tsx diff --git a/src/components/feed/Post.tsx b/src/components/feed/Post.tsx index 03f5e0b..e46fe4a 100644 --- a/src/components/feed/Post.tsx +++ b/src/components/feed/Post.tsx @@ -26,7 +26,18 @@ const Post = ({ /> {username} - Post + Post { + e.currentTarget.src = '/placeholder.svg'; + }} + />
diff --git a/src/components/layout/SideBar.tsx b/src/components/layout/SideBar.tsx index f09b210..2932e1c 100644 --- a/src/components/layout/SideBar.tsx +++ b/src/components/layout/SideBar.tsx @@ -11,10 +11,13 @@ import { useContext, useState } from 'react'; import { Link } from 'react-router-dom'; import { LoginContext } from '../../App'; +import CreatePostModal from '../modals/CreatePostModal'; import { NavItem } from './NavItem'; const SideBar = () => { const [isMenuOpen, setIsMenuOpen] = useState(false); + const [activeItem, setActiveItem] = useState('home'); + const [isCreateModalOpen, setIsCreateModalOpen] = useState(false); const context = useContext(LoginContext); @@ -22,24 +25,91 @@ const SideBar = () => { throw new Error('LoginContext is not provided'); } + const handleNavItemClick = (itemName: string) => { + setActiveItem(itemName); + if (itemName === 'create') { + setIsCreateModalOpen(true); + } + }; + return (
- Instagram + Logo
- - } label="Home" active /> + { + handleNavItemClick('home'); + }} + > + } + label="Home" + active={activeItem === 'home'} + /> - } label="Search" active={false} /> - - } label="Explore" active={false} /> + } + label="Search" + active={activeItem === 'search'} + onClick={() => { + handleNavItemClick('search'); + }} + /> + { + handleNavItemClick('explore'); + }} + > + } + label="Explore" + active={activeItem === 'explore'} + /> - } label="Notifications" active={false} /> - } label="Create" active={false} /> - - } label="Profile" active={false} /> + } + label="Notifications" + active={activeItem === 'notifications'} + onClick={() => { + handleNavItemClick('notifications'); + }} + /> + } + label="Create" + active={activeItem === 'create'} + onClick={() => { + handleNavItemClick('create'); + }} + /> + {isCreateModalOpen && ( + { + setIsCreateModalOpen(false); + }} + /> + )} + { + handleNavItemClick('profile'); + }} + > + } + label="Profile" + active={activeItem === 'profile'} + />
@@ -57,7 +127,6 @@ const SideBar = () => { +
+ ) : ( +
+ +
+ )} +
+
+
+