Skip to content

Commit f841a4c

Browse files
authored
Merge pull request #285 from prgrms-web-devcourse-final-project/feat/design/284-layout-css-edit
[feat/design] 레이아웃 수정 / 프로필 페이지 애니메이션 추가
2 parents 23c5865 + 001f192 commit f841a4c

File tree

2 files changed

+39
-37
lines changed

2 files changed

+39
-37
lines changed

src/layouts/Layout.tsx

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -20,38 +20,36 @@ function Layout() {
2020
location.pathname === '/chat';
2121

2222
return (
23-
<div className="flex justify-center w-full min-h-screen">
24-
<div className="max-w-[600px] min-w-[320px] w-full bg-background flex flex-col">
25-
{/* 헤더 */}
26-
<HeaderWrapper />
23+
<div className="max-w-[600px] min-w-[320px] w-full bg-background flex min-h-screen mx-auto">
24+
{/* 헤더 */}
25+
<HeaderWrapper />
2726

28-
{/* 메인 컨텐츠 영역 */}
29-
<div
30-
className={twMerge(
31-
'pt-[44px] flex-1 flex justify-center w-full px-3',
32-
showNav && 'pb-[62px] ', // 하단 네비게이션 숨길때만 padding주기
33-
)}
34-
>
35-
<MyErrorBoundary>
36-
<AnimatePresence mode="wait">
37-
<motion.div
38-
key={location.pathname} // 경로가 바뀔 때마다 애니메이션 트리거
39-
initial={{ opacity: 0 }}
40-
animate={{ opacity: 1 }}
41-
transition={{ duration: 0.3 }}
42-
className="flex justify-center w-full h-full"
43-
>
44-
<Outlet />
45-
</motion.div>
46-
</AnimatePresence>
47-
</MyErrorBoundary>
48-
</div>
49-
50-
{/* 하단 네비게이션 */}
51-
<BottomNavWrapper />
52-
{/* 글작성 버튼 */}
53-
<PostButton />
27+
{/* 메인 컨텐츠 영역 */}
28+
<div
29+
className={twMerge(
30+
'pt-[44px] flex-1 flex justify-center w-full px-3',
31+
showNav && 'pb-[62px] ', // 하단 네비게이션 숨길때만 padding주기
32+
)}
33+
>
34+
<MyErrorBoundary>
35+
<AnimatePresence mode="wait">
36+
<motion.div
37+
key={location.pathname} // 경로가 바뀔 때마다 애니메이션 트리거
38+
initial={{ opacity: 0 }}
39+
animate={{ opacity: 1 }}
40+
transition={{ duration: 0.3 }}
41+
className="flex justify-center w-full h-full"
42+
>
43+
<Outlet />
44+
</motion.div>
45+
</AnimatePresence>
46+
</MyErrorBoundary>
5447
</div>
48+
49+
{/* 하단 네비게이션 */}
50+
<BottomNavWrapper />
51+
{/* 글작성 버튼 */}
52+
<PostButton />
5553
</div>
5654
);
5755
}

src/pages/editprofile/EditProfile.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { useState } from 'react';
22
import ProfileEditForm from '@/pages/editprofile/components/ProfileEditForm';
33
import PasswordEditForm from '@/pages/editprofile/components/PasswordEditForm';
44
import { twMerge } from 'tailwind-merge';
5+
import { AnimatePresence, motion } from 'framer-motion';
56

67
function EditProfile() {
78
const [activeTab, setActiveTab] = useState('profile');
@@ -31,13 +32,16 @@ function EditProfile() {
3132
</div>
3233

3334
{/* 폼 */}
34-
{activeTab === 'profile' ? (
35-
// 프로필 수정 탭
36-
<ProfileEditForm />
37-
) : (
38-
// 비밀번호 변경 탭
39-
<PasswordEditForm />
40-
)}
35+
<AnimatePresence mode="wait">
36+
<motion.div
37+
key={activeTab} // 핵심! key를 다르게 주면 된다
38+
initial={{ opacity: 0 }}
39+
animate={{ opacity: 1 }}
40+
transition={{ duration: 0.3 }}
41+
>
42+
{activeTab === 'profile' ? <ProfileEditForm /> : <PasswordEditForm />}
43+
</motion.div>
44+
</AnimatePresence>
4145
</div>
4246
);
4347
}

0 commit comments

Comments
 (0)