From 2f3076e3ac643e41f0e33deb366fd2ea6d10b0ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=ED=86=A0?= <59536977+seongjin2427@users.noreply.github.com> Date: Tue, 5 Nov 2024 21:38:14 +0900 Subject: [PATCH] =?UTF-8?q?[feat]=20=ED=86=A0=EB=A1=A0=20=ED=94=BC?= =?UTF-8?q?=EB=93=9C=20=EC=83=81=EC=84=B8=20=EB=AA=A8=EB=8B=AC=20=EC=9D=BD?= =?UTF-8?q?=EA=B8=B0=20=EC=A0=84=EC=9A=A9=20UI=20=EA=B5=AC=ED=98=84=20(#27?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [feat] added FeedWrapper Component - FeedWrapper depends on whether there is pathname value "p" or not - If pathname "p" value of browser navigation is existed, FeedWrapper render children props * [fix] fixed commit error - The folder name included "@" caused error when committing - The folder name to start "@" means slot router * [feat] added compactTimeFormatter util for feed created time * [feat] added FeedWrapper, ReadOnlyCommonFeed, FeedTextContent Component - FeedWrapper depends on whether or not browser navigation has value of key "f" - ReadOnlyCommonFeed is only rendering from props information about common feed - FeedTextContent is rendering feed information (profile, content, username etc.) * [style] added "flex-wrap: wrap;" style at .hashtag_wrapper in FeedTextContent Component * [feat] added FeedComment, FeedCommentList - not included server request logic * [feat] added FeedLikeBox Component and svg heart icon * [feat] added LikeButton Component * [feat] added FeedCommentWriteInput Component and useAutoResizeTextArea hook * [feat] added Slide Component - added height, maxHeight props at Modal Component * [feat] added FeedReplyWriteInput Component - update useAutoResizeTextArea hook (not use row count, use scrollHeight) * [feat] added ReadOnlyDebateFeed Component * [feat] added DebateContent Component * [feat] completed ReadOnlyDebateFeed Component and Refactoring --- .../DebateContent/DebateContent.module.scss | 56 +++++++++++ .../DebateContent/DebateContent.tsx | 84 ++++++++++++++++ .../components/DebateContent/index.ts | 1 + .../components/FeedComment/FeedComment.tsx | 4 +- .../FeedCommentList/FeedCommentList.tsx | 1 + .../FeedCommentWriteInput.module.scss | 13 ++- .../FeedCommentWriteInput.tsx | 9 +- .../components/FeedLikeBox/FeedLikeBox.tsx | 10 +- .../FeedTextContent.module.scss | 17 +++- .../FeedTextContent/FeedTextContent.tsx | 18 ++-- .../components/LikeButton/LikeButton.tsx | 31 +++--- .../ReadOnlyCommonFeed.module.scss | 8 +- .../ReadOnlyCommonFeed/ReadOnlyCommonFeed.tsx | 87 ++++++++++------- .../ReadOnlyDebateFeed.module.scss | 33 +++++++ .../ReadOnlyDebateFeed/ReadOnlyDebateFeed.tsx | 90 ++++++++++++++++++ .../components/ReadOnlyDebateFeed/index.ts | 1 + src/app/(MainLayout)/page.tsx | 66 ++++++++++++- src/app/(MainLayout)/types/feed.ts | 51 +++++++++- src/assets/icons/blue_flag_fill.svg | 3 + src/assets/icons/red_flag.png | Bin 0 -> 340 bytes src/assets/icons/red_flag_fill.svg | 3 + .../FeedWrapper/FeedWrapper.module.scss | 30 ++++++ .../common/FeedWrapper/FeedWrapper.tsx | 7 +- 23 files changed, 545 insertions(+), 78 deletions(-) create mode 100644 src/app/(MainLayout)/components/DebateContent/DebateContent.module.scss create mode 100644 src/app/(MainLayout)/components/DebateContent/DebateContent.tsx create mode 100644 src/app/(MainLayout)/components/DebateContent/index.ts create mode 100644 src/app/(MainLayout)/components/ReadOnlyDebateFeed/ReadOnlyDebateFeed.module.scss create mode 100644 src/app/(MainLayout)/components/ReadOnlyDebateFeed/ReadOnlyDebateFeed.tsx create mode 100644 src/app/(MainLayout)/components/ReadOnlyDebateFeed/index.ts create mode 100644 src/assets/icons/blue_flag_fill.svg create mode 100644 src/assets/icons/red_flag.png create mode 100644 src/assets/icons/red_flag_fill.svg diff --git a/src/app/(MainLayout)/components/DebateContent/DebateContent.module.scss b/src/app/(MainLayout)/components/DebateContent/DebateContent.module.scss new file mode 100644 index 0000000..5038f4d --- /dev/null +++ b/src/app/(MainLayout)/components/DebateContent/DebateContent.module.scss @@ -0,0 +1,56 @@ +@use '../../../../styles/helpers/index' as *; + +.blue { + background-color: rgba(43, 89, 195, 0.3); +} + +.red { + background-color: rgba(211, 101, 130, 0.3); +} + +.container { + flex: 1; + border-right: 1px solid $COLOR_GRAY_2; + + &:last-of-type { + border-right: none; + } + + .debate_container { + position: relative; + height: 200px; + border-bottom: 1px solid $COLOR_GRAY_2; + + @include flex-center; + + h2 { + font-size: $FONT_SIZE_32; + font-weight: bold; + color: $COLOR_GRAY_2; + } + + .vote_count { + position: absolute; + top: 20px; + left: 20px; + gap: 5px; + + @include flex-center; + } + + .vote { + position: absolute; + width: 100%; + height: 200px; + top: 0; + left: 0; + opacity: 0.5; + border-right: 1px solid $COLOR_GRAY_2; + } + } + + .comment_container { + height: 539px; + overflow: scroll; + } +} diff --git a/src/app/(MainLayout)/components/DebateContent/DebateContent.tsx b/src/app/(MainLayout)/components/DebateContent/DebateContent.tsx new file mode 100644 index 0000000..7a25a11 --- /dev/null +++ b/src/app/(MainLayout)/components/DebateContent/DebateContent.tsx @@ -0,0 +1,84 @@ +import clsx from 'clsx'; + +import { digitNumberFormatter } from '@/utils/formatter'; + +import BlueFlag from '@/assets/icons/blue_flag.svg'; +import BlueFillFlag from '@/assets/icons/blue_flag_fill.svg'; +import RedFlag from '@/assets/icons/red_flag.svg'; +import RedFillFlag from '@/assets/icons/red_flag_fill.svg'; +import FeedCommentList from '../FeedCommentList'; + +import styles from './DebateContent.module.scss'; +import FeedCommentWriteInput from '../FeedCommentWriteInput'; +import { DebateOptionType } from '../../types/feed'; + +interface DebateContentProps { + postId: number; + index: number; + option: DebateOptionType; + isSelected?: boolean; + ratio: number; + disabled?: boolean; +} + +const FLAG_SET = { + BLUE: { + NORMAL: BlueFlag, + FILL: BlueFillFlag, + }, + RED: { + NORMAL: RedFlag, + FILL: RedFillFlag, + }, +}; + +const DebateContent = ({ + postId, + index, + option, + ratio, + isSelected, + disabled, +}: DebateContentProps) => { + const { optionContent, voteCount } = option; + + const currentFlagType = index === 1 ? 'BLUE' : ('RED' as const); + const FLAG = FLAG_SET[currentFlagType]; + + const currentColor = currentFlagType === 'BLUE' ? styles.blue : styles.red; + + return ( +
{nickname}
-{feedContent}
diff --git a/src/app/(MainLayout)/components/FeedCommentList/FeedCommentList.tsx b/src/app/(MainLayout)/components/FeedCommentList/FeedCommentList.tsx index ea3226e..d3bf7d1 100644 --- a/src/app/(MainLayout)/components/FeedCommentList/FeedCommentList.tsx +++ b/src/app/(MainLayout)/components/FeedCommentList/FeedCommentList.tsx @@ -20,6 +20,7 @@ const makeMockData = (id: number) => ({ createdAt: '2024-10-25 20:08:22', updatedAt: '2024-10-28 21:29:22', likeCount: 1357345 + id, + isLike: false, childFeedComments: +id < 4 ? [4, 5, 6] : [], }); diff --git a/src/app/(MainLayout)/components/FeedCommentWriteInput/FeedCommentWriteInput.module.scss b/src/app/(MainLayout)/components/FeedCommentWriteInput/FeedCommentWriteInput.module.scss index 6ffe10a..84a54c6 100644 --- a/src/app/(MainLayout)/components/FeedCommentWriteInput/FeedCommentWriteInput.module.scss +++ b/src/app/(MainLayout)/components/FeedCommentWriteInput/FeedCommentWriteInput.module.scss @@ -8,10 +8,21 @@ padding: 18px 0 18px 18px; border-top: 1px solid $COLOR_GRAY_2; + &:has(.comment_textarea:disabled) { + & * { + color: $COLOR_GRAY_2; + } + + .submit_button { + cursor: default; + } + } + .comment_textarea { flex: 1; - color: $COLOR_GRAY_2; + height: 20px; line-height: 1.25rem; + color: $COLOR_GRAY_2; white-space: pre-wrap; word-wrap: break-word; } diff --git a/src/app/(MainLayout)/components/FeedCommentWriteInput/FeedCommentWriteInput.tsx b/src/app/(MainLayout)/components/FeedCommentWriteInput/FeedCommentWriteInput.tsx index cfb7e02..ca60096 100644 --- a/src/app/(MainLayout)/components/FeedCommentWriteInput/FeedCommentWriteInput.tsx +++ b/src/app/(MainLayout)/components/FeedCommentWriteInput/FeedCommentWriteInput.tsx @@ -12,12 +12,14 @@ interface FeedCommentWriteInputProps { postId: number; parentId?: number; placeholder?: string; + disabled?: boolean; } const FeedCommentWriteInput = ({ postId, parentId, placeholder = '댓글 달기...', + disabled, }: FeedCommentWriteInputProps) => { const { textareaContent, setTextareaContent, textareaRef } = useAutoResizeTextArea({ maxLine: 3, lineHeight: 20 }); @@ -44,8 +46,13 @@ const FeedCommentWriteInput = ({ onChange={changeHandler} value={textareaContent} ref={textareaRef} + disabled={disabled} + /> + - diff --git a/src/app/(MainLayout)/components/FeedLikeBox/FeedLikeBox.tsx b/src/app/(MainLayout)/components/FeedLikeBox/FeedLikeBox.tsx index 08e243b..6fc8874 100644 --- a/src/app/(MainLayout)/components/FeedLikeBox/FeedLikeBox.tsx +++ b/src/app/(MainLayout)/components/FeedLikeBox/FeedLikeBox.tsx @@ -9,14 +9,20 @@ interface FeedLikeBoxProps { postId: number; likeCount: number; commentCount: number; + isLike: boolean; } -const FeedLikeBox = ({ postId, likeCount, commentCount }: FeedLikeBoxProps) => { +const FeedLikeBox = ({ + postId, + likeCount, + commentCount, + isLike, +}: FeedLikeBoxProps) => { return ({username}
-- {compactTimeFormatter(updatedAt ?? createdAt)} -
+{userName}
+{compactTimeFormatter(createdAt)}
{content}
#{hashtag}
))}