-
Notifications
You must be signed in to change notification settings - Fork 0
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
[Wip] 공통 컴포넌트 제작(4-1) UserContentBlock #23
Changes from 17 commits
681f8b4
37fe0db
b5e49d4
90662ca
99dba99
8eb509f
3c68ef1
d01af74
a78a73c
e4c5e5d
8cae1a7
c9c6e54
fbf84af
b3c8cc7
254f253
96f4b06
4d42ced
fd1574b
5f65d70
9f0bfbb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import { DEFAULT_PAGE_PADDING, DEFAULT_WIDTH } from '@/constants/style'; | ||
import { | ||
Avatar, | ||
AvatarBadge, | ||
Flex, | ||
FlexProps, | ||
Text, | ||
VStack, | ||
} from '@chakra-ui/react'; | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
interface UserContentBlockProps extends FlexProps { | ||
userImage?: string; | ||
userImageSize?: string | number; | ||
isOnline?: boolean; | ||
username: string; | ||
content: string; | ||
subContent?: string; | ||
usernameFontSize?: string | number; | ||
contentFontSize?: string | number; | ||
href?: string; | ||
onSubContentClick?: () => void; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 정말 별건 아니지만... username , content 관련 속성들이 정렬되면 좋을 것 같습니다
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 음 이거는 컨벤션으로 정해도 될만큼 중요해보이네요 |
||
|
||
const UserContentBlock = ({ | ||
userImage = '', | ||
userImageSize = '50px', | ||
href, | ||
content, | ||
isOnline, | ||
subContent, | ||
onSubContentClick, | ||
username = '테스트용', | ||
usernameFontSize = '1.4rem', | ||
contentFontSize = '1.2rem', | ||
...props | ||
}: UserContentBlockProps) => { | ||
const navigate = useNavigate(); | ||
const onNavigate = () => navigate(`${href}`); | ||
return ( | ||
<Flex | ||
w={DEFAULT_WIDTH} | ||
align="center" | ||
gap="17px" | ||
onClick={() => href && onNavigate()} | ||
cursor="pointer" | ||
pl={DEFAULT_PAGE_PADDING} | ||
pr={DEFAULT_PAGE_PADDING} | ||
{...props} | ||
> | ||
<Avatar | ||
src={userImage} | ||
boxSize={ | ||
userImageSize && typeof userImageSize === 'string' | ||
? userImageSize | ||
: `${userImageSize}px` | ||
} | ||
Comment on lines
+49
to
+52
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 부분이 하나의 함수로 처리되어도 좋을 것 같습니다 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 좋습니다 numberToPixel 이런 함수로 만들어서 사용해보겠습니다 ㅎㅎ |
||
boxShadow="0px 5px 15px -5px gray" | ||
> | ||
{isOnline ? ( | ||
<AvatarBadge | ||
boxSize="14px" | ||
border="2px solid white" | ||
bg="green.100" | ||
right="5%" | ||
bottom="5%" | ||
/> | ||
) : null} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. isOnline && 이런 식으로 처리해도 좋을 것 같습니다 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 넵 수정사항 반영하겠습니다 |
||
</Avatar> | ||
<VStack flex="1" align="left" color="black"> | ||
<Flex w="100%" position="relative"> | ||
<Text | ||
fontWeight="semibold" | ||
fontSize={ | ||
typeof usernameFontSize === 'string' | ||
? usernameFontSize | ||
: `${usernameFontSize}px` | ||
} | ||
> | ||
{username} | ||
</Text> | ||
<Text | ||
fontSize="1.2rem" | ||
position="absolute" | ||
right="0" | ||
zIndex="normal" | ||
cursor={onSubContentClick && 'pointer'} | ||
onClick={() => onSubContentClick && onSubContentClick()} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 지금 최상위 컴포넌트에도 click 이벤트가 있고, Text에도 이벤트가 있는데 관련해서 문제는 없는지 궁금합니다. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 기획중 둘을 동시에 사용하는 경우가 없었습니다. 아직 정해지지 않은 부분이기도 하구요
|
||
> | ||
{subContent} | ||
</Text> | ||
</Flex> | ||
<Text | ||
fontSize={ | ||
typeof contentFontSize === 'string' | ||
? contentFontSize | ||
: `${contentFontSize}px` | ||
} | ||
> | ||
{content} | ||
</Text> | ||
</VStack> | ||
</Flex> | ||
); | ||
}; | ||
|
||
export default UserContentBlock; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import UserContentBlock from '@/components/common/UserContentBlock'; | ||
import { Meta, StoryObj } from '@storybook/react'; | ||
import { withRouter } from 'storybook-addon-react-router-v6'; | ||
const meta: Meta<typeof UserContentBlock> = { | ||
component: UserContentBlock, | ||
decorators: [withRouter], | ||
argTypes: { | ||
width: { | ||
control: 'number', | ||
}, | ||
height: { | ||
control: 'number', | ||
}, | ||
username: { | ||
control: 'text', | ||
}, | ||
content: { | ||
control: 'text', | ||
}, | ||
isOnline: { | ||
control: 'boolean', | ||
}, | ||
userImage: { | ||
control: 'text', | ||
}, | ||
usernameFontSize: { | ||
control: 'number', | ||
}, | ||
contentFontSize: { | ||
control: 'number', | ||
}, | ||
subContent: { | ||
control: 'text', | ||
}, | ||
}, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof UserContentBlock>; | ||
|
||
export const Deafult: Story = { | ||
args: { | ||
width: 428, | ||
height: 80, | ||
username: '테스트닉', | ||
content: '테스트용 내용', | ||
isOnline: true, | ||
subContent: '7일 전', | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,9 @@ export const theme = extendTheme({ | |
red: { | ||
100: '#EF4444', | ||
}, | ||
green: { | ||
100: '#44DE82', | ||
}, | ||
black: '#222222', | ||
|
||
white: '#FFFFFF', | ||
|
@@ -64,4 +67,7 @@ export const theme = extendTheme({ | |
sizes: { | ||
icon: '2.4rem', | ||
}, | ||
zIndices: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이건 z-index를 의미하는 것이겠죠 ??!? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 네 맞습니다 chakra ui 링크에서 theme-key로 되어있는 부분이 테마변수명입니다! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아하 확인했습니다 !! |
||
normal: 100, | ||
}, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FlexProps 로 받아주면 ...props 도 대처가 되는군요 !! 유익한 기능을 알아갑니다 :)