-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 체크박스에 레이블을 달 수 있는 CheckboxItem 컴포넌트 작성
- Loading branch information
Showing
2 changed files
with
43 additions
and
0 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,33 @@ | ||
import { ChangeEvent } from 'react'; | ||
|
||
import Checkbox, { CheckboxStyleProps } from '../Checkbox'; | ||
|
||
import * as S from './styles'; | ||
|
||
interface CheckboxItemProps extends CheckboxStyleProps { | ||
id: string; | ||
label: string; | ||
isChecked: boolean; | ||
onChange: (event: ChangeEvent<HTMLInputElement>) => void; | ||
name?: string; | ||
isDisabled?: boolean; | ||
} | ||
const CheckboxItem = ({ id, name, label, isChecked, onChange, isDisabled = false, $style }: CheckboxItemProps) => { | ||
return ( | ||
<S.CheckboxItem> | ||
<S.CheckboxLabel> | ||
<Checkbox | ||
id={id} | ||
name={name} | ||
isChecked={isChecked} | ||
onChange={onChange} | ||
isDisabled={isDisabled} | ||
$style={$style} | ||
/> | ||
{label} | ||
</S.CheckboxLabel> | ||
</S.CheckboxItem> | ||
); | ||
}; | ||
|
||
export default CheckboxItem; |
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,10 @@ | ||
import styled from '@emotion/styled'; | ||
|
||
export const CheckboxItem = styled.div``; | ||
|
||
export const CheckboxLabel = styled.label` | ||
font-weight: ${({ theme }) => theme.fontWeight.bold}; | ||
display: flex; | ||
align-items: center; | ||
gap: 0.7rem; | ||
`; |