File tree Expand file tree Collapse file tree 4 files changed +111
-13
lines changed
Expand file tree Collapse file tree 4 files changed +111
-13
lines changed Original file line number Diff line number Diff line change 11import React , { useState } from 'react' ;
22import { useNavigate , useLocation } from 'react-router' ;
33
4- import UserProfile from './user-profile' ;
4+ import UserProfile from '.. /user-profile' ;
55import { Asidetab } from './aside-tab-menu' ;
66
77import { 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} ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 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+ } ;
Original file line number Diff line number Diff line change 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 ;
You can’t perform that action at this time.
0 commit comments