-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7d71755
commit 3332300
Showing
10 changed files
with
76 additions
and
51 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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
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,30 @@ | ||
'use client'; | ||
|
||
import { useState } from 'react'; | ||
import { Box } from './ui/box'; | ||
import { CheckBox } from './ui/check-box'; | ||
|
||
export function SelectBox() { | ||
const [select, setSelect] = useState<string>(''); | ||
|
||
return ( | ||
<div className="flex flex-col gap-2.5"> | ||
<Box | ||
className="flex w-full items-center gap-3 md:w-[8.25rem]" | ||
onClick={() => setSelect('agree')} | ||
isActive={select === 'agree'} | ||
> | ||
<CheckBox isChecked={select === 'agree'} /> | ||
<span className="body3 text-[#3B404E]">네, 동의합니다.</span> | ||
</Box> | ||
<Box | ||
className="flex w-full items-center gap-3 md:w-[8.25rem]" | ||
onClick={() => setSelect('disagree')} | ||
isActive={select === 'disagree'} | ||
> | ||
<CheckBox isChecked={select === 'disagree'} /> | ||
<span className="body3 text-[#3B404E]">아니요, 동의하지 않습니다.</span> | ||
</Box> | ||
</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
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 |
---|---|---|
@@ -1,48 +1,28 @@ | ||
'use client'; | ||
|
||
import { cn } from '@/lib/utils'; | ||
import { ComponentProps, useEffect, useState } from 'react'; | ||
import Image from 'next/image'; | ||
import { ComponentProps } from 'react'; | ||
import { Button } from './button'; | ||
|
||
type CheckBoxProps = Omit<ComponentProps<'button'>, 'onClick'> & { | ||
initialChecked?: boolean; | ||
onValueChange?: (isChecked: boolean) => void; | ||
isEditable?: boolean; | ||
isChecked: boolean; | ||
}; | ||
|
||
export function CheckBox({ | ||
initialChecked = false, | ||
onValueChange, | ||
isEditable = true, | ||
...props | ||
}: CheckBoxProps) { | ||
const [isChecked, setIsChecked] = useState<boolean>(initialChecked); | ||
|
||
useEffect(() => { | ||
if (onValueChange) { | ||
onValueChange(isChecked); | ||
} | ||
}, [isChecked, onValueChange]); | ||
|
||
const handleClick = () => { | ||
if (!isEditable) { | ||
return; | ||
} | ||
setIsChecked(prev => !prev); | ||
}; | ||
|
||
export function CheckBox({ isChecked, ...props }: CheckBoxProps) { | ||
return ( | ||
<Button | ||
variant="outline" | ||
size="icon" | ||
className={cn( | ||
'h-5 w-5 rounded-full transition-colors', | ||
isChecked | ||
? 'border-none bg-gray-100 hover:bg-gray-100' | ||
? 'border-none bg-primary hover:bg-primary' | ||
: 'border-[#898F9F] bg-transparent hover:bg-transparent' | ||
)} | ||
onClick={handleClick} | ||
{...props} | ||
/> | ||
> | ||
{isChecked ? ( | ||
<Image src="/check.svg" alt="check" width={10} height={10} /> | ||
) : null} | ||
</Button> | ||
); | ||
} |
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