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: 체크박스 배경, 폰트 조절 props 추가 #32

Merged
merged 1 commit into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/components/input/Checkbox/AllConsentCheckbox.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
/** @jsxImportSource @emotion/react */
import { ChangeEvent, useState } from "react";
import * as S from "./allConsentCheckbox.style";
import CheckIcon from "@assets/icons/checkbox_Check.svg?react";

export interface AllConsentCheckboxProps {
content?: string;
transparent?: boolean;
fontSize?: string;
fontWeight?: string;
color?: string;
}

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

const handleCheck = (e: ChangeEvent<HTMLInputElement>) => {
setChecked(e.target.checked);
};

return (
<S.Wrapper>
<S.Wrapper transparent={transparent}>
<S.IconWrapper>
<S.Input id="agreement" type="checkbox" checked={checked} onChange={handleCheck} />
<S.Icon>
Expand All @@ -23,7 +32,7 @@ const AllConsentCheckbox = ({ content }: AllConsentCheckboxProps) => {
</S.IconWrapper>
<S.Label htmlFor="agreement">
{content ? (
<p className="content">{content}</p>
<p css={{ ...props }}>{content}</p>
) : (
<p>
전체 동의 <span>(선택 포함)</span>
Expand Down
9 changes: 3 additions & 6 deletions src/components/input/Checkbox/allConsentCheckbox.style.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import styled from "@emotion/styled";

export const Wrapper = styled.div`
export const Wrapper = styled.div<{ transparent?: boolean }>`
display: flex;
align-items: center;

padding: 12px 8px;

border-radius: 5px;
background-color: ${({ theme }) => theme.colors.gray[100]};
background-color: ${({ theme, transparent }) =>
transparent ? "transparent" : theme.colors.gray[100]};

span {
font-size: 14px;
Expand All @@ -33,10 +34,6 @@ export const Label = styled.label`
font-weight: ${({ theme }) => theme.text.button1.fontWeight};

cursor: pointer;

.content {
opacity: 0.5;
}
`;

export const IconWrapper = styled.div`
Expand Down
6 changes: 3 additions & 3 deletions src/components/input/Checkbox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ type CheckboxProps =
| (AllConsentCheckboxProps & { variant: "all" })
| (IndividualConsentCheckboxProps & { variant: "individual" });

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