-
Notifications
You must be signed in to change notification settings - Fork 2
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
73826e8
commit 24e5e29
Showing
5 changed files
with
178 additions
and
73 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
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
40 changes: 40 additions & 0 deletions
40
src/components/hackathon/ideaList/filter/SubjectFilterDropdown.tsx
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,40 @@ | ||
import { Dropdown, DropdownToggle, DropdownMenu, DropdownItem, Text } from '@goorm-dev/vapor-components'; | ||
import { useState } from 'react'; | ||
import styles from './styles.module.scss'; | ||
|
||
interface SubjectFilterDropdownProps { | ||
options: { id: number; name: string }[]; | ||
selectedValue: number; | ||
onChange: (value: number) => void; | ||
disabled?: boolean; | ||
} | ||
|
||
export default function SubjectFilterDropdown({ | ||
options, | ||
selectedValue, | ||
onChange, | ||
disabled = false, | ||
}: SubjectFilterDropdownProps) { | ||
const [isOpen, setIsOpen] = useState(false); | ||
const toggle = () => !disabled && setIsOpen(!isOpen); | ||
|
||
// 현재 선택된 주제의 이름 찾기 (id로 매칭) | ||
const selectedTopicName = options.find((topic) => topic.id === selectedValue)?.name || '전체'; | ||
|
||
return ( | ||
<Dropdown direction="down" size="lg" isOpen={isOpen} toggle={toggle} disabled={disabled}> | ||
<DropdownToggle caret color="select" className={styles.dropdown} disabled={disabled}> | ||
<Text typography="body2" fontWeight="medium" className={styles.textSelect}> | ||
{selectedTopicName} | ||
</Text> | ||
</DropdownToggle> | ||
<DropdownMenu> | ||
{options.map((option) => ( | ||
<DropdownItem key={option.id} onClick={() => onChange(option.id)}> | ||
{option.name} | ||
</DropdownItem> | ||
))} | ||
</DropdownMenu> | ||
</Dropdown> | ||
); | ||
} |
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