-
Notifications
You must be signed in to change notification settings - Fork 6
[Feat] 문의내역 상세 카드 컴포넌트 #143
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
43e0e30
refactor: QuestionCard 공통 스타일 mixin으로 분리 (#140)
devdeun 40c11bf
refactor: QuestionCard 공통 Props 분리 (#140)
devdeun cc6c803
feat: QuestionDetailCard 컴포넌트 추가 (#140)
devdeun 82d3039
feat: QuestionDetailCard 스토리북 추가 (#140)
devdeun be9553c
feat: use client 추가 (#140)
devdeun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
app/(dashboard)/my/questions/[questionId]/_ui/question-detail-card/index.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| 'use client' | ||
|
|
||
| import classNames from 'classnames/bind' | ||
|
|
||
| import { QuestionStatusType } from '@/shared/types/questions' | ||
| import Avatar from '@/shared/ui/avatar' | ||
| import Label from '@/shared/ui/label' | ||
| import { formatDateTime } from '@/shared/utils/format' | ||
|
|
||
| import { QuestionCardProps } from '../../../_ui/question-card' | ||
| import styles from './styles.module.scss' | ||
|
|
||
| const cx = classNames.bind(styles) | ||
|
|
||
| type QuestionDetailCardType = 'question' | 'answer' | ||
|
|
||
| interface Props extends QuestionCardProps { | ||
| type?: QuestionDetailCardType | ||
| strategyName?: string | ||
| title?: string | ||
| status?: QuestionStatusType | ||
| isAuthor: boolean | ||
| onDelete?: () => void | ||
| } | ||
|
|
||
| const QuestionDetailCard = ({ | ||
| profileImage, | ||
| nickname, | ||
| contents, | ||
| type = 'question', | ||
| status, | ||
| strategyName, | ||
| title = '답변', | ||
| createdAt, | ||
| isAuthor, | ||
| onDelete, | ||
| }: Props) => { | ||
| return ( | ||
| <div className={cx('card-container')}> | ||
| <div className={cx('card-header')}> | ||
| {type === 'question' && ( | ||
| <div className={cx('top-wrapper')}> | ||
| <strong className={cx('strategy-name')}>{strategyName}</strong> | ||
| <Label color={status === '답변 완료' ? 'indigo' : 'orange'}>{status}</Label> | ||
| </div> | ||
| )} | ||
| <h2 className={cx('title', type)}>{title}</h2> | ||
| <div className={cx('bottom-wrapper')}> | ||
| <div className={cx('avatar-wrapper')}> | ||
| <Avatar src={profileImage} size="medium" /> | ||
| <span>{nickname}</span> | ||
| <span className={cx('created-at')}>ㅣ {formatDateTime(createdAt)}</span> | ||
| </div> | ||
| {isAuthor && ( | ||
| <button type="button" className={cx('delete-button')} onClick={onDelete}> | ||
| 삭제 | ||
| </button> | ||
| )} | ||
| </div> | ||
| </div> | ||
| <div className={cx('card-contents')}>{contents}</div> | ||
| </div> | ||
| ) | ||
| } | ||
|
|
||
| export default QuestionDetailCard | ||
57 changes: 57 additions & 0 deletions
57
...oard)/my/questions/[questionId]/_ui/question-detail-card/question-detail-card.stories.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| import { Meta, StoryFn } from '@storybook/react' | ||
|
|
||
| import QuestionDetailCard from '.' | ||
|
|
||
| const meta: Meta = { | ||
| title: 'Components/QuestionDetailCard', | ||
| component: QuestionDetailCard, | ||
| tags: ['autodocs'], | ||
| } | ||
|
|
||
| const Template: StoryFn<typeof QuestionDetailCard> = (args) => ( | ||
| <div style={{ width: '900px', padding: '20px', backgroundColor: '#f8f9fa' }}> | ||
| <QuestionDetailCard {...args} /> | ||
| </div> | ||
| ) | ||
|
|
||
| export const Question = Template.bind({}) | ||
| Question.args = { | ||
| type: 'question', | ||
| strategyName: '엄청난 전략', | ||
| title: '미국발 경제악화가 한국 증시에 미치는 영향은 무엇인가요?', | ||
| contents: | ||
| '안녕하세요. 주식투자를 시작하려고 하는데 미국의 경제 상황이 좋지 않다고 들었습니다. 이런 상황에서 한국 증시는 어떤 영향을 받을까요? 구체적인 설명 부탁드립니다.', | ||
| nickname: '투자초보', | ||
| profileImage: '', | ||
| createdAt: '2024-11-03T15:00:00', | ||
| status: '답변 대기', | ||
| isAuthor: false, | ||
| onDelete: () => alert('삭제 버튼 클릭'), | ||
| } | ||
|
|
||
| export const QuestionWithDeleteButton = Template.bind({}) | ||
| QuestionWithDeleteButton.args = { | ||
| ...Question.args, | ||
| isAuthor: true, | ||
| } | ||
|
|
||
| export const Answer = Template.bind({}) | ||
| Answer.args = { | ||
| type: 'answer', | ||
| title: '답변', | ||
| contents: | ||
| '안녕하세요. 문의하신 내용에 대해 답변드리겠습니다. 미국과 한국 증시는 높은 상관관계를 보이고 있어 미국의 경제 상황이 한국 증시에 큰 영향을 미칠 수 있습니다. 구체적으로는...', | ||
| nickname: '전문가', | ||
| profileImage: '', | ||
| createdAt: '2024-11-03T16:30:00', | ||
| isAuthor: false, | ||
| onDelete: () => alert('삭제 버튼 클릭'), | ||
| } | ||
|
|
||
| export const AnswerWithDeleteButton = Template.bind({}) | ||
| AnswerWithDeleteButton.args = { | ||
| ...Answer.args, | ||
| isAuthor: true, | ||
| } | ||
|
|
||
| export default meta |
54 changes: 54 additions & 0 deletions
54
app/(dashboard)/my/questions/[questionId]/_ui/question-detail-card/styles.module.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| @import '../../../_ui/question-card/card-mixins.scss'; | ||
|
|
||
| .card-container { | ||
| @include card-base; | ||
| padding: 35px 40px; | ||
| } | ||
|
|
||
| .top-wrapper { | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: space-between; | ||
|
|
||
| .strategy-name { | ||
| @include card-subtitle; | ||
| } | ||
| } | ||
|
|
||
| .title { | ||
| @include card-title; | ||
| margin-bottom: 18px; | ||
|
|
||
| &.answer { | ||
| @include typo-b1; | ||
| } | ||
| } | ||
|
|
||
| .bottom-wrapper { | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: space-between; | ||
| padding-bottom: 12px; | ||
| margin-bottom: 24px; | ||
| border-bottom: 1px solid $color-gray-300; | ||
|
|
||
| .delete-button { | ||
| @include typo-c1; | ||
| background-color: transparent; | ||
| } | ||
| } | ||
|
|
||
| .avatar-wrapper { | ||
| @include avatar-group; | ||
|
|
||
| .created-at { | ||
| margin-left: -8px; | ||
| color: $color-gray-400; | ||
| } | ||
| } | ||
|
|
||
| .card-contents { | ||
| color: $color-gray-600; | ||
| @include typo-b3; | ||
| line-height: 140%; | ||
| } |
40 changes: 40 additions & 0 deletions
40
app/(dashboard)/my/questions/_ui/question-card/card-mixins.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| @mixin card-base { | ||
| padding: 24px 40px 16px; | ||
| border-radius: 8px; | ||
| background-color: $color-white; | ||
| } | ||
|
|
||
| @mixin card-subtitle { | ||
| @include typo-b2; | ||
| color: $color-orange-600; | ||
| } | ||
|
|
||
| @mixin card-created-at { | ||
| @include typo-b3; | ||
| color: $color-gray-400; | ||
| } | ||
|
|
||
| @mixin card-top { | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: space-between; | ||
| } | ||
|
|
||
| @mixin card-title { | ||
| margin: 12px 0 8px; | ||
| @include typo-h4; | ||
| } | ||
|
|
||
| @mixin card-bottom { | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: space-between; | ||
| } | ||
|
|
||
| @mixin avatar-group { | ||
| display: flex; | ||
| align-items: center; | ||
| gap: 16px; | ||
| color: $color-gray-600; | ||
| @include typo-b3; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.