-
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
Implement several major in ResultCategoryCard/#87 #89
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
104ea1b
feat: implement color type based on complete
yougyung df0ddce
feat: add outlined button
yougyung 78c2802
feat: add major button in ResultCategoryComponent
yougyung 7829983
feat: add storybook test ResultCategoryComponent
yougyung 63a0933
fix: change to component outside filterSeveralMajor
yougyung 8272373
fix: add role attr in several major button
yougyung 6bd06f5
chore: commit for merge
yougyung f548a85
rename: change test title
yougyung 50e168c
fix: remove to useRouter category query parameter
yougyung 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
This file contains 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 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 was deleted.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
app/ui/result/result-category-card/result-category-card.stories.tsx
This file contains 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 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import ResultCategoryCard from './result-category-card'; | ||
import { RESULT_CATEGORY } from '@/app/utils/key/result-category.key'; | ||
|
||
const meta = { | ||
title: 'ui/result/category-card', | ||
component: ResultCategoryCard, | ||
decorators: [(Story) => <Story />], | ||
} as Meta<typeof ResultCategoryCard>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
category: RESULT_CATEGORY.COMMON_CULTURE, | ||
totalCredit: 40, | ||
takenCredit: 30, | ||
completed: false, | ||
}, | ||
}; | ||
|
||
export const CompletedSubMajor: Story = { | ||
args: { | ||
category: RESULT_CATEGORY.SUB_MAJOR, | ||
totalCredit: 40, | ||
takenCredit: 40, | ||
completed: true, | ||
}, | ||
}; | ||
|
||
export const UncompletedDualMajor = { | ||
args: { | ||
category: RESULT_CATEGORY.DUAL_BASIC_ACADEMICAL_CULTURE, | ||
totalCredit: 70, | ||
takenCredit: 40, | ||
completed: false, | ||
}, | ||
}; |
90 changes: 90 additions & 0 deletions
90
app/ui/result/result-category-card/result-category-card.tsx
This file contains 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,90 @@ | ||
'use client'; | ||
import { cn } from '@/app/utils/shadcn/utils'; | ||
|
||
import Book from '@/public/assets/book.svg'; | ||
import Image from 'next/image'; | ||
import useDialog from '@/app/hooks/useDialog'; | ||
import * as React from 'react'; | ||
import { DIALOG_KEY } from '@/app/utils/key/dialog-key.util'; | ||
import Link from 'next/link'; | ||
import { useSetAtom } from 'jotai'; | ||
import { isDialogOpenAtom } from '@/app/store/dialog'; | ||
import Button from '../../view/atom/button/button'; | ||
import PieChart from '../../view/molecule/pie-chart/pie-chart'; | ||
import { RESULT_CATEGORY, RESULT_CATEGORY_KO, ResultCategoryKey } from '@/app/utils/key/result-category.key'; | ||
|
||
interface ResultCategoryCardProps { | ||
category: ResultCategoryKey; | ||
totalCredit: number; | ||
takenCredit: number; | ||
completed?: boolean; | ||
} | ||
|
||
const filterSeveralMajor = (category: ResultCategoryKey) => { | ||
const { DUAL_MANDATORY_MAJOR, DUAL_ELECTIVE_MAJOR, DUAL_BASIC_ACADEMICAL_CULTURE, SUB_MAJOR } = RESULT_CATEGORY; | ||
|
||
switch (category) { | ||
case DUAL_MANDATORY_MAJOR: | ||
case DUAL_ELECTIVE_MAJOR: | ||
case DUAL_BASIC_ACADEMICAL_CULTURE: | ||
return <Button label="복수전공" variant="outlined" size="xs" role="none presentation" />; | ||
case SUB_MAJOR: | ||
return <Button label="부전공" variant="outlined" size="xs" role="none presentation" />; | ||
default: | ||
return <></>; | ||
} | ||
}; | ||
|
||
function ResultCategoryCard({ category, totalCredit, takenCredit }: ResultCategoryCardProps) { | ||
const { toggle } = useDialog(DIALOG_KEY.RESULT_CATEGORY); | ||
const setIsOpenDialog = useSetAtom(isDialogOpenAtom); | ||
|
||
const percentage = Number(((takenCredit / totalCredit) * 100).toFixed(0)); | ||
|
||
function handleClickButton() { | ||
toggle(); | ||
setIsOpenDialog(true); | ||
} | ||
return ( | ||
<div | ||
className={cn('flex flex-col gap-6 zIndex-1 rounded-xl shadow-lg bg-white p-[0.4rem]', 'md:w-80 md:p-[1.8rem]')} | ||
> | ||
<div className="flex justify-between items-center"> | ||
<div className={cn('flex gap-4 font-bold text-sm', 'md:text-xl')}> | ||
<Image src={Book} width={24} height={24} alt="category-img" /> | ||
<h3>{RESULT_CATEGORY_KO[category]}</h3> | ||
</div> | ||
{filterSeveralMajor(category)} | ||
</div> | ||
<div className="m-auto"> | ||
<PieChart percentage={percentage} /> | ||
</div> | ||
<div className={cn('flex text-xs font-medium justify-between items-end', 'md:gap-4 md:text-base md:px-2')}> | ||
<div> | ||
<div className={cn('flex', 'md:gap-2')}> | ||
<span>기준학점</span> | ||
<span className="font-bold">{totalCredit}</span> | ||
</div> | ||
<div className={cn('flex', 'md:gap-2')}> | ||
<span>이수학점</span> | ||
<span className={cn('font-bold', percentage === 100 ? 'text-point-blue' : 'text-etc-red')}> | ||
{takenCredit} | ||
</span> | ||
</div> | ||
</div> | ||
<Link | ||
href={{ | ||
pathname: '/result', | ||
query: { | ||
category: 'COMMON_CULTURE', | ||
}, | ||
}} | ||
> | ||
<Button size="sm" label="과목 확인" onClick={handleClickButton} /> | ||
</Link> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default ResultCategoryCard; |
This file contains 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 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 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 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 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 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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
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.
해당 네이밍은 기존에 존재하던 variant로 새롭게 추가 된 것이 아닙니다
outlined를 추가하며 함께 업데이트만 진행했어요 !