Skip to content

Commit 025f680

Browse files
committed
fix: 아바타 컴포넌트 props제거 및 사이드바에서 로고 스타일 적용
1 parent 1451fb7 commit 025f680

File tree

4 files changed

+24
-13
lines changed

4 files changed

+24
-13
lines changed

src/components/common/avatar/Avatar.styled.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
11
import styled from 'styled-components';
22
import { AvatarProps } from './Avatar';
33

4-
interface AvatarContainerProps extends Omit<AvatarProps, 'image'> {
5-
$isMainLogo?: boolean;
6-
}
7-
8-
export const AvatarContainer = styled.div<AvatarContainerProps>`
4+
export const AvatarContainer = styled.div<Omit<AvatarProps, 'image'>>`
95
width: ${({ size }) => size};
106
height: ${({ size }) => size};
11-
border-radius: ${({ $isMainLogo }) => ($isMainLogo ? '0' : '50%')};
12-
border: ${({ $isMainLogo, theme }) =>
13-
$isMainLogo ? 'none' : `1px solid ${theme.color.border}`};
7+
border-radius: 50%;
8+
border: 1px solid ${({ theme }) => theme.color.border};
149
1510
.avatar {
1611
width: 100%;
1712
height: 100%;
18-
border-radius: ${({ $isMainLogo }) => ($isMainLogo ? '0' : '50%')};
13+
border-radius: 50%;
1914
}
2015
2116
@media screen and ${({ theme }) => theme.mediaQuery.tablet} {

src/components/common/avatar/Avatar.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
import { ReactNode } from 'react';
22
import * as S from './Avatar.styled';
33
import defaultImg from '../../../assets/defaultImg.png';
4-
import MainLogo from '../../../assets/mainlogo.svg';
54

65
export interface AvatarProps {
76
size: string;
87
image: string | ReactNode;
98
}
109

1110
function Avatar({ size, image }: AvatarProps) {
12-
const isMainLogo = image === MainLogo;
1311
const releasedImg =
1412
typeof image === 'string' && image.trim() ? image : defaultImg;
1513
return (
16-
<S.AvatarContainer size={size} $isMainLogo={isMainLogo}>
14+
<S.AvatarContainer size={size}>
1715
{typeof image === 'string' || !image ? (
1816
<img className='avatar' src={releasedImg} alt='Avatar' />
1917
) : (

src/components/common/sidebar/Sidebar.styled.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@ export const Container = styled.div`
1212
padding-bottom: 1rem;
1313
`;
1414

15+
export const LogoContainer = styled.div`
16+
width: 110px;
17+
height: 110px;
18+
19+
img {
20+
width: 100%;
21+
height: 100%;
22+
object-fit: contain;
23+
}
24+
`;
25+
1526
export const AvartarContainer = styled.div`
1627
width: 100%;
1728
display: flex;

src/components/common/sidebar/Sidebar.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as S from './Sidebar.styled';
44
import React, { useCallback } from 'react';
55
import EditMyProfileImg from './editMyProfileImg/EditMyProfileImg';
66
import useAuthStore from '../../../store/authStore';
7+
import MainLogo from '../../../assets/mainlogo.svg';
78

89
interface MenuItem {
910
label: string;
@@ -34,7 +35,13 @@ const Sidebar = ({ menuItems, profileImage, nickname }: SidebarProps) => {
3435
<S.Container>
3536
<S.AvartarContainer>
3637
<S.AvartarWrapper>
37-
<Avatar size='120px' image={profileImage} />
38+
{profileImage === MainLogo ? (
39+
<S.LogoContainer>
40+
<img src={MainLogo} alt='main logo' />
41+
</S.LogoContainer>
42+
) : (
43+
<Avatar size='120px' image={profileImage} />
44+
)}
3845
{isMyProfile && <EditMyProfileImg />}
3946
</S.AvartarWrapper>
4047
<span>{nickname ? nickname : ''}</span>

0 commit comments

Comments
 (0)