Skip to content

Commit

Permalink
Refactor: 전체 동의 체크박스 내부 컨텐츠 작성 가능하게 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
gaori committed Jan 11, 2024
1 parent d9b21ee commit ef7b432
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
14 changes: 12 additions & 2 deletions src/components/input/Checkbox/AllConsentCheckbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import { ChangeEvent, useState } from "react";
import * as S from "./allConsentCheckbox.style";
import CheckIcon from "@assets/icons/checkbox_Check.svg?react";

const AllConsentCheckbox = () => {
export interface AllConsentCheckboxProps {
content?: string;
}

const AllConsentCheckbox = ({ content }: AllConsentCheckboxProps) => {
const [checked, setChecked] = useState(false);

const handleCheck = (e: ChangeEvent<HTMLInputElement>) => {
Expand All @@ -18,7 +22,13 @@ const AllConsentCheckbox = () => {
</S.Icon>
</S.IconWrapper>
<S.Label htmlFor="agreement">
전체 동의 <span>(선택 포함)</span>
{content ? (
<p className="content">{content}</p>
) : (
<p>
전체 동의 <span>(선택 포함)</span>
</p>
)}
</S.Label>
</S.Wrapper>
);
Expand Down
8 changes: 8 additions & 0 deletions src/components/input/Checkbox/allConsentCheckbox.style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ export const Icon = styled.div`
export const Label = styled.label`
font-size: ${({ theme }) => theme.text.button1.fontSize};
font-weight: ${({ theme }) => theme.text.button1.fontWeight};
cursor: pointer;
.content {
opacity: 0.5;
}
`;

export const IconWrapper = styled.div`
Expand All @@ -39,6 +45,8 @@ export const IconWrapper = styled.div`
align-items: center;
margin-right: 8px;
cursor: pointer;
`;

export const Input = styled.input`
Expand Down
8 changes: 4 additions & 4 deletions src/components/input/Checkbox/index.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import AllConsentCheckbox from "./AllConsentCheckbox";
import AllConsentCheckbox, { AllConsentCheckboxProps } from "./AllConsentCheckbox";
import IndividualConsentCheckbox, {
type IndividualConsentCheckboxProps
} from "./IndividualConsentCheckbox";

type CheckboxProps =
| { variant: "all" }
| (AllConsentCheckboxProps & { variant: "all" })
| (IndividualConsentCheckboxProps & { variant: "individual" });

const Checkbox = ({ variant = "all", ...individualProps }: CheckboxProps) => {
const Checkbox = ({ variant = "all", content, ...individualProps }: CheckboxProps) => {
switch (variant) {
case "all":
return <AllConsentCheckbox />;
return <AllConsentCheckbox content={content} />;
case "individual":
return <IndividualConsentCheckbox {...(individualProps as IndividualConsentCheckboxProps)} />;
default:
Expand Down

0 comments on commit ef7b432

Please sign in to comment.