-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Drop다운 구현 및 DROPDOWN_INFO 수정 (#126)
- Loading branch information
1 parent
960a27d
commit 7ebcdb2
Showing
3 changed files
with
48 additions
and
4 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,42 @@ | ||
import useOpenToggle from "@/hooks/useOpenToggle"; | ||
import SquareDropButton from "./commons/SquareDropButton"; | ||
import DropMenu from "./commons/DropMenu"; | ||
import styled from "styled-components"; | ||
|
||
interface DropdownProps { | ||
placeholder?: string; | ||
selectedOption?: string; | ||
options: string[]; | ||
onSelect: (option: string) => void; | ||
} | ||
|
||
export default function Dropdown({ placeholder, selectedOption, options, onSelect }: DropdownProps) { | ||
const { isOpen, openToggle: toggleDropdown, ref } = useOpenToggle(); | ||
|
||
const handleSelectOption = (option: string) => { | ||
onSelect(option); | ||
toggleDropdown(); | ||
}; | ||
|
||
return ( | ||
<Container ref={ref}> | ||
<SquareDropButton | ||
selectOption={selectedOption || placeholder || ""} | ||
onClick={toggleDropdown} | ||
$isSelected={!!selectedOption} | ||
$iconType="default" | ||
/> | ||
<DropMenu isOpen={isOpen} handleSelectOption={handleSelectOption} $borderType="square" options={options} /> | ||
</Container> | ||
); | ||
} | ||
|
||
const Container = styled.div` | ||
width: 100%; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: end; | ||
position: relative; | ||
padding: 0; | ||
gap: 0.8rem; | ||
`; |
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