Skip to content
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

feat: 공통 컴포넌트 Progress bar #30

Merged
merged 9 commits into from
Sep 9, 2024
4 changes: 4 additions & 0 deletions public/icons/check-circle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions public/icons/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import IconCaret from './caret.svg';
import IconCheck from './check.svg';
import IconCheckBoxDefault from './checkbox-default.svg';
import IconCheckBoxActive from './checkbox-active.svg';
import IconCheckCircle from './check-circle.svg';
import IconDalaemfit from './dalaemfit.svg';
import IconHeart from './heart.svg';
import IconX from './icon-x.svg';
Expand All @@ -26,6 +27,7 @@ export {
IconCheck,
IconCheckBoxDefault,
IconCheckBoxActive,
IconCheckCircle,
IconDalaemfit,
IconHeart,
IconX,
Expand Down
4 changes: 2 additions & 2 deletions public/icons/person.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
74 changes: 74 additions & 0 deletions src/app/components/ProgressBar/ProgressBar.tsx
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 컴포넌트에서의 variation은 아래와 같은 조건으로 결정이 됩니다.

  1. isOpeningConfirmed (개설확정)
  2. isClosedGathering (모집 종료)
  3. hasParticipantNumber (인원 수 보일지 말지)
  4. hasOpeningConfirmed (개설확정 배지 보일지 말지)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

16가지 버전 만들 수 있어요!

Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// 개설 확정은 참여 인원수가 최소 인원 수(5명)을 충족한 경우 자동 확정 처리됩니다.
'use client';

import { IconArrow, IconCheckCircle, IconPerson } from '@/public/icons';

/**
* ProgressBar component
* @param {number} participantNumber - 참여 인원 수
* @param {boolean} hasParticipantNumber - 참여 인원 수 렌더링 여부
* @param {boolean} hasOpeningConfirmed - 개설 확정 렌더링 여부
*/
Comment on lines +6 to +11
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이런 doc의 경우 vscode extension 사용하시나요? 궁금해용

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저는 수제로 만들긴 했습니다 😂


interface ProgressBarProps {
participantNumber: number;
capacity: number;
hasParticipantNumber: boolean;
hasOpeningConfirmed: boolean;
}

const ProgressBar = ({
participantNumber,
capacity,
hasParticipantNumber,
hasOpeningConfirmed,
}: ProgressBarProps) => {
const isOpeningConfirmed = participantNumber >= 5; // 개설 확정 여부 (boolean)
const isClosedGathering = participantNumber === capacity; // 참여 인원이 다 찬 경우 (boolean)
Comment on lines +13 to +27
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수용인원 관련한 코드 추가했습니다.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


return (
<div className='flex gap-24'>
<div className='flex w-full flex-col gap-12'>
{/* gathering information */}
<div className='flex items-center gap-8'>
{/* 참가 인원 렌더링 선택 */}
{hasParticipantNumber && (
<div
className={`text-14 flex items-center gap-[2px] font-medium ${isClosedGathering ? 'text-var-orange-400' : 'text-var-black'}`}
>
<IconPerson className='h-16 w-16' />
{`${participantNumber} / 20`}
</div>
)}
{/* 개설확정 렌더링 선택 */}
{hasOpeningConfirmed && isOpeningConfirmed && !isClosedGathering && (
<div className='text-14 flex items-center gap-4 text-var-orange-400'>
<IconCheckCircle className='h-24 w-24' />
개설확정
</div>
)}
</div>
{/* progress bar */}
<div className='flex h-4 w-full rounded-md bg-var-orange-100'>
<div
className={`h-full ${isClosedGathering ? 'bg-var-orange-400' : 'bg-var-orange-600'} transition-all ease-in-out`}
style={{ width: `${(participantNumber / capacity) * 100}%` }}
></div>
</div>
</div>
{/* user action */}
{isClosedGathering ? (
<div className='text-16 flex items-center font-semibold text-var-orange-400'>
Closed
</div>
) : (
<div className='text-16 flex items-center gap-8 whitespace-nowrap font-semibold text-var-orange-600'>
join now
<IconArrow className='h-[18px] w-[18px]' />
</div>
)}
</div>
);
};

export default ProgressBar;
Loading