-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #100 from YAPP-Github/feature/FE-061
Feature/fe-061 Dropdown 수정사항 반영
- Loading branch information
Showing
19 changed files
with
506 additions
and
172 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,15 @@ | ||
'use client'; | ||
import { HTMLAttributes } from 'react'; | ||
import cx from 'classnames'; | ||
import { titleWrapper, background, wrap } from './BottomSheet.css'; | ||
import IconButton from '../IconButton/IconButton'; | ||
import { useLockScroll } from '@/hooks'; | ||
|
||
import { ComponentProps } from 'react'; | ||
import BottomSheetView from './BottomSheetView'; | ||
import { useModalControl } from './hooks'; | ||
|
||
type BottomSheetProps = { | ||
onClose: () => void; | ||
title?: string; | ||
} & HTMLAttributes<HTMLDivElement>; | ||
type BottomSheetProps = Omit<ComponentProps<typeof BottomSheetView>, 'isOpen'>; | ||
|
||
const BottomSheet = ({ className, onClose, title, children, ...rest }: BottomSheetProps) => { | ||
useLockScroll(); | ||
const BottomSheet = ({ title, onClose, ...rest }: BottomSheetProps) => { | ||
const { ref, isOpen, closeModalWithTransition } = useModalControl({ onClose }); | ||
|
||
return ( | ||
<> | ||
<div className={cx(background({ open: isOpen }))} data-testid="outside"></div> | ||
<div className={cx(wrap({ open: isOpen }), className)} {...rest} ref={ref}> | ||
<div className={titleWrapper}> | ||
<div>{title}</div> | ||
<IconButton iconType="close" width={36} height={36} onClick={closeModalWithTransition}></IconButton> | ||
</div> | ||
{children} | ||
</div> | ||
</> | ||
); | ||
return <BottomSheetView ref={ref} title={title} isOpen={isOpen} onClose={closeModalWithTransition} {...rest} />; | ||
}; | ||
|
||
export default BottomSheet; |
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,39 @@ | ||
import { HTMLAttributes, forwardRef } from 'react'; | ||
import cx from 'classnames'; | ||
import { IconButton } from '@/components'; | ||
import { useLockScroll } from '@/hooks'; | ||
import { titleWrapper, background, wrap } from './BottomSheet.css'; | ||
|
||
interface Props extends HTMLAttributes<HTMLDivElement> { | ||
/** BottomSheet 제목으로 표시할 텍스트 */ | ||
title?: string; | ||
|
||
/** bottomsheet 열림/닫힘 상태 */ | ||
isOpen: boolean; | ||
|
||
/** bottomsheet 닫을때 호출되는 함수 */ | ||
onClose: () => void; | ||
} | ||
|
||
const BottomSheetView = forwardRef<HTMLDivElement, Props>( | ||
({ title, isOpen, children, onClose, className, ...rest }, ref) => { | ||
useLockScroll(); | ||
|
||
return ( | ||
<> | ||
<div className={cx(background({ open: isOpen }))} data-testid="outside" onClick={onClose}></div> | ||
<div className={cx(wrap({ open: isOpen }), className)} {...rest} ref={ref}> | ||
<div className={titleWrapper}> | ||
<div>{title}</div> | ||
<IconButton iconType="close" width={36} height={36} onClick={onClose}></IconButton> | ||
</div> | ||
{children} | ||
</div> | ||
</> | ||
); | ||
}, | ||
); | ||
|
||
BottomSheetView.displayName = 'BottomSheetView'; | ||
|
||
export default BottomSheetView; |
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,56 @@ | ||
'use client'; | ||
|
||
import cx from 'classnames'; | ||
import BottomSheetView from '@/components/BottomSheet/BottomSheetView'; | ||
import { HTMLAttributes, useMemo, forwardRef, useImperativeHandle, ComponentProps } from 'react'; | ||
import { useDropdownContext } from './contexts/DropdownContext'; | ||
import { type DropdownMenuContextValue, DropdownMenuContextProvider } from './contexts/DropdownMenuContext'; | ||
import useDropdownBottomSheet from './hooks/useDropdownBottomSheet/useDropdownBottomSheet'; | ||
|
||
interface Props | ||
extends HTMLAttributes<HTMLDivElement>, | ||
Partial<DropdownMenuContextValue>, | ||
Omit<ComponentProps<typeof BottomSheetView>, 'isOpen' | 'onClose'> {} | ||
|
||
export interface DropdownMenuHandle { | ||
/** menu를 닫는다 */ | ||
close: () => void; | ||
} | ||
|
||
const DropdownBottomSheet = forwardRef<DropdownMenuHandle, Props>( | ||
({ children, className, selectable = false, selectedItemKey = null, onSelectChange = () => null, ...rest }, ref) => { | ||
const { isOpen: isDropdownOpen, closeDropdown } = useDropdownContext(); | ||
|
||
const [bottomSheetRef, isBottmSheetOpen, , closeBottomSheet] = useDropdownBottomSheet({ | ||
isDropdownOpen, | ||
onClose: closeDropdown, | ||
}); | ||
|
||
const menuContextValue = useMemo( | ||
() => ({ selectable, selectedItemKey, onSelectChange, closeDropdown: closeBottomSheet }), | ||
[selectable, selectedItemKey, onSelectChange, closeBottomSheet], | ||
); | ||
|
||
useImperativeHandle(ref, () => ({ | ||
close: closeBottomSheet, | ||
})); | ||
|
||
return ( | ||
<DropdownMenuContextProvider value={menuContextValue}> | ||
<BottomSheetView | ||
ref={bottomSheetRef} | ||
isOpen={isBottmSheetOpen} | ||
onClose={closeBottomSheet} | ||
className={cx(className)} | ||
{...rest} | ||
> | ||
{children} | ||
</BottomSheetView> | ||
</DropdownMenuContextProvider> | ||
); | ||
}, | ||
); | ||
|
||
DropdownBottomSheet.displayName = 'DropdownBottomSheet'; | ||
|
||
export default DropdownBottomSheet; |
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
Oops, something went wrong.