Skip to content

Commit

Permalink
Feat: Drop다운 구현 및 DROPDOWN_INFO 수정 (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
nakyoung98 authored Mar 21, 2024
1 parent 960a27d commit 7ebcdb2
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 4 deletions.
42 changes: 42 additions & 0 deletions co-kkiri/src/components/commons/DropDowns/Dropdown.tsx
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;
`;
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import styled, { css } from "styled-components";
import DESIGN_TOKEN from "@/styles/tokens";

interface DropdownMenuProps {
options: string[] | number[];
handleSelectOption: (option: string | number) => void;
options: string[];
handleSelectOption: (option: string) => void;
isOpen: boolean;
$borderType: "round" | "square";
}
Expand All @@ -24,7 +24,7 @@ interface ContainerProps {
export default function DropMenu({ options, isOpen, handleSelectOption, $borderType }: DropdownMenuProps) {
return (
<Container $isOpen={isOpen} $borderType={$borderType}>
{options.map((option: string | number) => (
{options.map((option: string) => (
<Option
$borderType={$borderType}
onClick={() => {
Expand Down
4 changes: 3 additions & 1 deletion co-kkiri/src/constants/dropDown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const DROPDOWN_INFO = {
career: {
defaultValue: "경력",
options: ["신입", "1년차", "2년차", "3년차", "4년차", "5년차", "5년차 이상"],
values: [0, 1, 2, 3, 4, 5, 999],
},
},
recruitment: {
Expand All @@ -24,7 +25,8 @@ export const DROPDOWN_INFO = {
},
capacity: {
defaultValue: "모집 인원",
options: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
options: ["1명", "2명", "3명", "4명", "5명", "6명", "7명", "8명", "9명", "10명 이상"],
values: [1, 2, 3, 4, 5, 6, 7, 8, 9, 999],
},
contactWay: {
defaultValue: "연락 방식",
Expand Down

0 comments on commit 7ebcdb2

Please sign in to comment.