diff --git a/src/components/common/PostListItem/index.tsx b/src/components/common/PostListItem/index.tsx new file mode 100644 index 00000000..4ec1a97e --- /dev/null +++ b/src/components/common/PostListItem/index.tsx @@ -0,0 +1,93 @@ +import { DEFAULT_PAGE_PADDING, DEFAULT_WIDTH } from '@/constants/style'; +import { Flex, FlexProps, HStack, Text, VStack } from '@chakra-ui/react'; +import TextIconButton from '../TextIconButton'; +import { MdArticle, MdFavoriteBorder } from 'react-icons/md'; + +interface PostListItemProps extends FlexProps { + title: string; + body?: string; + username: string; + timeAgo: string; + likeCount: number; + commentCount: number; +} + +const PostListItem = ({ + title, + body, + username, + timeAgo, + likeCount = 0, + commentCount = 0, + ...props +}: PostListItemProps) => { + return ( + + + + {title} + + + {body} + + + + {username} + + + {timeAgo} + + + + + + + + + ); +}; + +export default PostListItem; diff --git a/src/components/common/TextIconButton/index.tsx b/src/components/common/TextIconButton/index.tsx index 0b2fccbd..cca0f99a 100644 --- a/src/components/common/TextIconButton/index.tsx +++ b/src/components/common/TextIconButton/index.tsx @@ -1,21 +1,73 @@ -import { Flex, Icon, IconButton, Text } from '@chakra-ui/react'; +import { + Flex, + FlexProps, + Icon, + IconButton, + IconProps, + Text, + TextProps, +} from '@chakra-ui/react'; import { IconType } from 'react-icons'; -interface TextIconButtonProps { +interface TextIconButtonProps extends FlexProps { TheIcon: IconType; textContent: string; + boxSize?: IconProps['boxSize']; + textLocation?: 'left' | 'right' | 'top' | 'bottom'; + fontSize?: TextProps['fontSize']; + iconColor?: IconProps['color']; + textColor?: TextProps['color']; + fontWeight?: TextProps['fontWeight']; } -const TextIconButton = ({ TheIcon, textContent }: TextIconButtonProps) => { +const TextIconButton = ({ + TheIcon, + textContent, + textLocation = 'bottom', + fontSize = 'sm', + textColor = 'black', + fontWeight = '800', + boxSize = 'icon', + iconColor = 'black', + ...props +}: TextIconButtonProps) => { + const calculateFlexDir = ( + textLocation: TextIconButtonProps['textLocation'], + ) => { + switch (textLocation) { + case 'bottom': + return 'column'; + case 'top': + return 'column-reverse'; + case 'left': + return 'row-reverse'; + case 'right': + return 'row'; + default: + return 'column'; + } + }; return ( - + } + icon={} bg="transparent" _groupHover={{ background: 'gray.450' }} /> - + {textContent} diff --git a/src/components/common/UserList/index.tsx b/src/components/common/UserListItem/index.tsx similarity index 89% rename from src/components/common/UserList/index.tsx rename to src/components/common/UserListItem/index.tsx index 3c0a743b..34525896 100644 --- a/src/components/common/UserList/index.tsx +++ b/src/components/common/UserListItem/index.tsx @@ -9,20 +9,20 @@ import { } from '@chakra-ui/react'; import { MdArrowForwardIos } from 'react-icons/md'; -interface UserListProps extends FlexProps { +interface UserListItemProps extends FlexProps { username: string; userImage?: string; userImageSize?: SystemProps['boxSize']; content?: string; } -const UserList = ({ +const UserListItem = ({ username, userImage, userImageSize = '40px', content, ...props -}: UserListProps) => { +}: UserListItemProps) => { return ( = { + component: PostListItem, + argTypes: { + title: { + control: 'text', + }, + body: { + control: 'text', + }, + username: { + control: 'text', + }, + timeAgo: { + control: 'text', + }, + likeCount: { + control: 'number', + }, + commentCount: { + control: 'number', + }, + }, +}; + +export default meta; +type Story = StoryObj; + +export const Deafult: Story = { + args: { + title: '제목입니다제목입니다제목입니다제목입니다제목입니다', + body: '내용이에요내용이에요내용이에요내용이에요내용이에요내용이에', + username: '올챙이', + timeAgo: '2일전', + likeCount: 10, + commentCount: 20, + }, +}; diff --git a/src/stories/components/TextIconButton.stories.ts b/src/stories/components/TextIconButton.stories.ts index 802f6921..fcefc03e 100644 --- a/src/stories/components/TextIconButton.stories.ts +++ b/src/stories/components/TextIconButton.stories.ts @@ -8,6 +8,25 @@ const meta: Meta = { textContent: { control: 'text', }, + boxSize: { + control: 'text', + }, + textLocation: { + options: ['top', 'bottom', 'left', 'right'], + control: 'select', + }, + fontSize: { + control: 'text', + }, + fontWeight: { + control: 'text', + }, + textColor: { + control: 'text', + }, + iconColor: { + control: 'text', + }, }, }; diff --git a/src/stories/components/UserList.stories.ts b/src/stories/components/UserListItem.stories.ts similarity index 71% rename from src/stories/components/UserList.stories.ts rename to src/stories/components/UserListItem.stories.ts index 02cc0e09..fcf2d071 100644 --- a/src/stories/components/UserList.stories.ts +++ b/src/stories/components/UserListItem.stories.ts @@ -1,8 +1,8 @@ -import UserList from '@/components/common/UserList'; +import UserListItem from '@/components/common/UserListItem'; import { Meta, StoryObj } from '@storybook/react'; -const meta: Meta = { - component: UserList, +const meta: Meta = { + component: UserListItem, argTypes: { width: { control: 'text', @@ -23,7 +23,7 @@ const meta: Meta = { }; export default meta; -type Story = StoryObj; +type Story = StoryObj; export const Deafult: Story = { args: {