Skip to content

Commit

Permalink
feat: 체크박스에 레이블을 달 수 있는 CheckboxItem 컴포넌트 작성
Browse files Browse the repository at this point in the history
  • Loading branch information
ImxYJL committed Aug 7, 2024
1 parent 967fa74 commit 8fb70af
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
33 changes: 33 additions & 0 deletions frontend/src/components/common/CheckboxItem/index.tsx
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;
10 changes: 10 additions & 0 deletions frontend/src/components/common/CheckboxItem/styles.ts
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;
`;

0 comments on commit 8fb70af

Please sign in to comment.