Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CLIENT] 공통 컴포넌트 - 아바타, 커뮤니티 아바타, 유저 아바타 작성 #45

Merged
merged 5 commits into from
Nov 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions client/src/common/components/Avatar/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import React from 'react';

export interface AvatarProps {
size: 'small' | 'medium';
variant: 'circle' | 'rectangle';
name: string;
url?: string;
}

const ROUNDED = {
rectangle: 'rounded-2xl',
circle: 'rounded-full',
};

const WH = {
small: 'w-[57px] h-[57px]',
medium: 'w-[65px] h-[65px]',
};

const Avatar: React.FC<AvatarProps> = ({ name, url, size, variant }) => {
return (
<div
className={`flex justify-center items-center ${WH[size]} border border-line ${ROUNDED[variant]} text-s24 italic font-bold overflow-hidden select-none`}
>
{url ? (
<img
className="object-cover"
src={url}
alt={`커뮤니티 ${name}의 프로필 이미지`}
/>
) : (
name.at(0)
)}
</div>
);
};

export default Avatar;
13 changes: 13 additions & 0 deletions client/src/common/components/CommunityAvatar/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Avatar, { AvatarProps } from '@components/Avatar';
import React from 'react';

const CommunityAvatar: React.FC<AvatarProps> = ({
variant = 'rectangle',
size = 'medium',
name,
url,
}) => {
return <Avatar variant={variant} size={size} name={name} url={url} />;
};

export default CommunityAvatar;
13 changes: 13 additions & 0 deletions client/src/common/components/UserAvatar/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Avatar, { AvatarProps } from '@components/Avatar';
import React from 'react';

const UserAvatar: React.FC<AvatarProps> = ({
variant = 'circle',
size = 'small',
name,
url,
}) => {
return <Avatar variant={variant} size={size} name={name} url={url} />;
};

export default UserAvatar;