Skip to content

Commit cb04c1f

Browse files
authored
Merge pull request #28 from nguswjd/feat/profile
feat: 유저 프로필 컴포넌트 작가, aside 유형 추가
2 parents c599c80 + 392603c commit cb04c1f

File tree

4 files changed

+111
-13
lines changed

4 files changed

+111
-13
lines changed

src/components/aside/aside.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useState } from 'react';
22
import { useNavigate, useLocation } from 'react-router';
33

4-
import UserProfile from './user-profile';
4+
import UserProfile from '../user-profile';
55
import { Asidetab } from './aside-tab-menu';
66

77
import { MessageCircleMore } from 'lucide-react';
@@ -201,7 +201,12 @@ const Aside: React.FC = () => {
201201
/>
202202
</section>
203203

204-
<UserProfile className="mt-auto" />
204+
<UserProfile
205+
className="mt-auto"
206+
variant="aside"
207+
userName="김자까"
208+
userId="jakka@gmail.com"
209+
/>
205210
</aside>
206211
);
207212
};

src/components/aside/user-profile.tsx

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import type { Meta, StoryObj } from '@storybook/react-vite';
2+
import UserProfile from './user-profile';
3+
4+
const meta = {
5+
title: 'Components/UserProfile',
6+
component: UserProfile,
7+
tags: ['autodocs'],
8+
argTypes: {
9+
variant: {
10+
control: 'select',
11+
options: ['author', 'aside'],
12+
},
13+
},
14+
} satisfies Meta<typeof UserProfile>;
15+
16+
export default meta;
17+
type Story = StoryObj<typeof meta>;
18+
19+
export const Author: Story = {
20+
args: {
21+
variant: 'author',
22+
userName: '김자까',
23+
userImage: '',
24+
isSelected: false,
25+
},
26+
};
27+
28+
export const Aside: Story = {
29+
args: {
30+
variant: 'aside',
31+
userName: '김자까',
32+
userId: 'jakka@gmail.com',
33+
userImage: '',
34+
},
35+
};

src/components/user-profile.tsx

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import React from 'react';
2+
3+
interface UserProfileProps {
4+
variant?: 'author' | 'aside';
5+
userName: string;
6+
userId?: string;
7+
userImage?: string;
8+
postTime?: string;
9+
className?: string;
10+
isSelected?: boolean;
11+
onAction?: () => void;
12+
}
13+
14+
const UserProfile: React.FC<UserProfileProps> = ({
15+
variant,
16+
userName,
17+
userId,
18+
userImage,
19+
className = '',
20+
isSelected = false,
21+
onAction,
22+
}) => {
23+
const defaultImage = '';
24+
25+
if (variant === 'author') {
26+
return (
27+
<div className={`flex flex-col items-center ${className}`}>
28+
<div className="relative cursor-pointer" onClick={onAction}>
29+
<img
30+
src={userImage || defaultImage}
31+
alt={userName}
32+
className={`h-28 w-28 rounded-full object-cover transition-all ${
33+
isSelected ? 'ring-2 ring-blue-100' : ''
34+
}`}
35+
/>
36+
</div>
37+
<span
38+
className={`mt-4 text-sm transition-colors ${
39+
isSelected ? 'text-gray-900' : 'text-gray-500'
40+
}`}
41+
>
42+
{userName}
43+
</span>
44+
</div>
45+
);
46+
}
47+
48+
if (variant === 'aside') {
49+
return (
50+
<div className={`flex items-center gap-[10px] ${className}`}>
51+
<img
52+
src={userImage || defaultImage}
53+
alt={userName}
54+
className="h-[42px] w-[42px] rounded-full object-cover"
55+
/>
56+
<div className="flex flex-col">
57+
<span className="text-base font-normal text-gray-200">
58+
{userName}
59+
</span>
60+
<span className="text-xs text-gray-300">{userId}</span>
61+
</div>
62+
</div>
63+
);
64+
}
65+
66+
return null;
67+
};
68+
69+
export default UserProfile;

0 commit comments

Comments
 (0)