-
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.
* chore: 펀잇 디자인 시스템 버전 업데이트 * feat: 리뷰 정렬 옵션 상수 추가 및 정렬 옵션 타입 추가 * refactor: SortButton에서 BottomSheet 제거 * refactor: SortOptionList에서 options prop 추가 * refactor: BottomSheet 페이지로 이동 * style: SortOption -> SortOptionButton으로 수정 * feat: SortButton 스토리에 args 추가 * refactor: useSortOption 커스텀 훅 분리
- Loading branch information
1 parent
f34d1f7
commit d7c95de
Showing
11 changed files
with
133 additions
and
84 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,31 @@ | ||
import { BottomSheet, Button, Text, theme } from '@fun-eat/design-system'; | ||
import { useState } from 'react'; | ||
import { Button, Text, useTheme } from '@fun-eat/design-system'; | ||
import styled from 'styled-components'; | ||
|
||
import BottomSheetContent from '../SortOptionList/SortOptionList'; | ||
import SvgIcon from '../Svg/SvgIcon'; | ||
|
||
import { SORT_OPTIONS } from '@/constants'; | ||
import useBottomSheet from '@/hooks/useBottomSheet'; | ||
interface SortButtonProps { | ||
option: string; | ||
onClick: () => void; | ||
} | ||
|
||
const SortButton = () => { | ||
const { ref, handleOpenBottomSheet, handleCloseBottomSheet } = useBottomSheet(); | ||
const [selectedOption, setSelectedOption] = useState(0); | ||
|
||
const selectSortOption = (optionIndex: number) => { | ||
setSelectedOption(optionIndex); | ||
}; | ||
const SortButton = ({ option, onClick }: SortButtonProps) => { | ||
const theme = useTheme(); | ||
|
||
return ( | ||
<> | ||
<Button color="white" variant="filled" onClick={handleOpenBottomSheet}> | ||
<SortButtonWrapper> | ||
<SvgIcon variant="sort" color={theme.textColors.info} width={18} height={18} /> | ||
<Text element="span" weight="bold" color={theme.textColors.info}> | ||
{SORT_OPTIONS[selectedOption].label} | ||
</Text> | ||
</SortButtonWrapper> | ||
</Button> | ||
<BottomSheet ref={ref} close={handleCloseBottomSheet}> | ||
<BottomSheetContent | ||
selectedOption={selectedOption} | ||
selectSortOption={selectSortOption} | ||
close={handleCloseBottomSheet} | ||
/> | ||
</BottomSheet> | ||
</> | ||
<SortButtonContainer color="white" variant="filled" onClick={onClick}> | ||
<SvgIcon variant="sort" color={theme.textColors.info} width={18} height={18} /> | ||
<Text as="span" weight="bold" color={theme.textColors.info}> | ||
{option} | ||
</Text> | ||
</SortButtonContainer> | ||
); | ||
}; | ||
|
||
export default SortButton; | ||
|
||
const SortButtonWrapper = styled.div` | ||
const SortButtonContainer = styled(Button)` | ||
display: flex; | ||
align-items: center; | ||
gap: 3px; | ||
column-gap: 4px; | ||
padding: 0; | ||
`; |
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,13 @@ | ||
import { useState } from 'react'; | ||
|
||
const useSortOption = (initialOption: string) => { | ||
const [selectedOption, setSelectedOption] = useState(initialOption); | ||
|
||
const selectSortOption = (selectedOptionLabel: string) => { | ||
setSelectedOption(selectedOptionLabel); | ||
}; | ||
|
||
return { selectedOption, selectSortOption }; | ||
}; | ||
|
||
export default useSortOption; |
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