-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UI: #127 프로젝트 상태 radio input 컴포넌트 분리
- Loading branch information
Showing
2 changed files
with
51 additions
and
28 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import type { UseFormRegisterReturn } from 'react-hook-form'; | ||
import type { ProjectStatus } from '@/types/ProjectStatusType'; | ||
|
||
type StatusRadioProps = { | ||
statusList: ProjectStatus[]; | ||
selectedStatusId: ProjectStatus['statusId']; | ||
errorMessage?: string; | ||
register: UseFormRegisterReturn; | ||
}; | ||
|
||
export default function StatusRadio({ statusList, selectedStatusId, errorMessage, register }: StatusRadioProps) { | ||
return ( | ||
<> | ||
{/* ToDo: 상태 선택 리팩토링 할 것 */} | ||
<div className="flex items-center justify-start gap-4"> | ||
{statusList.map((status) => { | ||
const { statusId, statusName, colorCode } = status; | ||
const isChecked = selectedStatusId === statusId; | ||
return ( | ||
<label | ||
key={statusId} | ||
htmlFor={statusName} | ||
className={`flex cursor-pointer items-center rounded-lg border px-5 py-3 text-emphasis ${isChecked ? 'border-input bg-white' : 'bg-button'}`} | ||
> | ||
<input | ||
id={statusName} | ||
type="radio" | ||
className="invisible h-0 w-0" | ||
value={statusId} | ||
checked={isChecked} | ||
{...register} | ||
/> | ||
<div style={{ borderColor: colorCode }} className="mr-3 h-8 w-8 rounded-full border" /> | ||
<h3 className="text-xs">{statusName}</h3> | ||
</label> | ||
); | ||
})} | ||
</div> | ||
<div className={`my-5 h-10 grow text-xs text-error ${errorMessage ? 'visible' : 'invisible'}`}> | ||
{errorMessage} | ||
</div> | ||
</> | ||
); | ||
} |
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