Skip to content

Commit 17d1e68

Browse files
authored
Merge pull request #51 from codeit-sprint-part3-6team/#43_공통-컴포넌트_프로필-이미지
2 parents bad8e7e + 910f6a6 commit 17d1e68

File tree

8 files changed

+808
-174
lines changed

8 files changed

+808
-174
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,6 @@ yarn-error.log*
3838
# typescript
3939
*.tsbuildinfo
4040
next-env.d.ts
41+
42+
# http
43+
*.http

next.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ const nextConfig: NextConfig = {
1818

1919
return config;
2020
},
21+
images: {
22+
domains: ['sprint-fe-project.s3.ap-northeast-2.amazonaws.com'], // 외부 이미지 도메인 추가
23+
},
2124
};
2225

2326
export default nextConfig;

package-lock.json

Lines changed: 590 additions & 172 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@
99
"lint": "next lint"
1010
},
1111
"dependencies": {
12+
"@emotion/react": "^11.14.0",
13+
"@emotion/styled": "^11.14.0",
14+
"@mui/material": "^6.2.0",
1215
"axios": "^1.7.9",
1316
"clsx": "^2.1.1",
1417
"next": "15.0.3",
15-
"react": "19.0.0-rc-66855b96-20241106",
16-
"react-dom": "19.0.0-rc-66855b96-20241106"
18+
"react": "^18.3.1",
19+
"react-dom": "^18.3.1"
1720
},
1821
"devDependencies": {
1922
"@svgr/webpack": "^8.1.0",
Lines changed: 9 additions & 0 deletions
Loading
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
.user_profile {
2+
display: flex;
3+
align-items: center;
4+
}
5+
6+
.user_img {
7+
border-radius: 100%;
8+
width: 38px;
9+
height: 38px;
10+
overflow: hidden;
11+
position: relative;
12+
}
13+
14+
.user_img > div {
15+
width: 100%;
16+
height: 100%;
17+
}
18+
19+
.user_img img,
20+
.user_img svg {
21+
width: 100%;
22+
height: 100%;
23+
object-fit: cover;
24+
}
25+
26+
.user_nickname {
27+
font-size: 16px;
28+
font-weight: 400;
29+
color: #333236;
30+
margin-left: 12px;
31+
}
32+
33+
.header .user_nickname {
34+
font-weight: 500;
35+
}
36+
37+
.dashboard_detail .user_img {
38+
width: 24px;
39+
height: 24px;
40+
}
41+
42+
.todo_detail .user_img {
43+
width: 34px;
44+
height: 34px;
45+
}
46+
47+
.todo_detail .user_nickname {
48+
font-size: 14px;
49+
}
50+
51+
.todo_create .user_img {
52+
width: 26px;
53+
height: 26px;
54+
}
55+
56+
@media screen and (max-width: 743px) {
57+
.user_img {
58+
width: 34px;
59+
height: 34px;
60+
}
61+
62+
.user_nickname {
63+
font-size: 14px;
64+
margin-left: 8px;
65+
}
66+
67+
.header .user_nickname {
68+
display: none;
69+
}
70+
71+
.dashboard_detail .user_img {
72+
width: 22px;
73+
height: 22px;
74+
}
75+
76+
.todo_detail .user_img {
77+
width: 32px;
78+
height: 32px;
79+
}
80+
81+
.todo_detail .user_nickname {
82+
font-size: 12px;
83+
}
84+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import styles from './UserProfile.module.css';
2+
import Avatar from '@mui/material/Avatar';
3+
4+
type UserProfileProps = {
5+
type?: 'header' | 'dashboard_detail' | 'todo_detail' | 'todo_create';
6+
onlyImg?: boolean;
7+
nickname: string;
8+
profileImageUrl?: string | null;
9+
};
10+
11+
function UserProfile({
12+
type,
13+
onlyImg,
14+
nickname,
15+
profileImageUrl,
16+
}: UserProfileProps) {
17+
return (
18+
<>
19+
<div className={`${styles.user_profile} ${styles[type]}`}>
20+
<div className={styles.user_img}>
21+
{profileImageUrl ? (
22+
<Avatar src={profileImageUrl} alt={nickname} />
23+
) : (
24+
<Avatar>{nickname[0].toUpperCase()}</Avatar>
25+
)}
26+
</div>
27+
28+
{!onlyImg && <span className={styles.user_nickname}>{nickname}</span>}
29+
</div>
30+
</>
31+
);
32+
}
33+
34+
export default UserProfile;
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import { useEffect, useState } from 'react';
2+
import axios from '../../../pages/api/axios';
3+
import UserProfile from './UserProfile';
4+
5+
function TestUserProfile() {
6+
const [user, setUser] = useState<any>();
7+
8+
const getData = async () => {
9+
const response = await axios.get('/users/me', {
10+
headers: {
11+
Authorization:
12+
'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6NDk1MSwidGVhbUlkIjoiMTEtNiIsImlhdCI6MTczNDA4MjM2MCwiaXNzIjoic3AtdGFza2lmeSJ9.1OCu1v8l8V9qtW1sghPM-O7NmEL_LuyIDFqPgb1lhWI',
13+
},
14+
});
15+
const data = response.data;
16+
setUser(data);
17+
};
18+
19+
useEffect(() => {
20+
getData();
21+
}, []);
22+
23+
if (!user) {
24+
return;
25+
}
26+
27+
return (
28+
<>
29+
<h1>프로필 이미지를 등록하지 않은 경우</h1>
30+
<UserProfile nickname={user.nickname} profileImageUrl={null} />
31+
32+
<br />
33+
34+
<h1>대시보드 수정, 생성</h1>
35+
<UserProfile
36+
nickname={user.nickname}
37+
profileImageUrl={user.profileImageUrl}
38+
/>
39+
40+
<br />
41+
42+
<h1>헤더</h1>
43+
<UserProfile
44+
nickname={user.nickname}
45+
profileImageUrl={user?.profileImageUrl}
46+
type="header"
47+
/>
48+
49+
<br />
50+
51+
<h1>대시보드 상세</h1>
52+
<UserProfile
53+
nickname={user.nickname}
54+
profileImageUrl={user?.profileImageUrl}
55+
type="dashboard_detail"
56+
onlyImg={true}
57+
/>
58+
59+
<br />
60+
61+
<h1>할 일 상세 모달</h1>
62+
<UserProfile
63+
nickname={user.nickname}
64+
profileImageUrl={user?.profileImageUrl}
65+
type="todo_detail"
66+
/>
67+
68+
<br />
69+
70+
<h1>할 일 생성 모달 </h1>
71+
<UserProfile
72+
nickname={user.nickname}
73+
profileImageUrl={user?.profileImageUrl}
74+
type="todo_create"
75+
/>
76+
</>
77+
);
78+
}
79+
80+
export default TestUserProfile;

0 commit comments

Comments
 (0)