import React from 'react' import classNames from 'classnames' import { CloseModalButton, Modal, NextButton, PreviousButton } from '../Modal/Modal' import { BottomSheet as ReactSpringBottomSheet, BottomSheetProps as ReactSpringBottomSheetProps } from 'react-spring-bottom-sheet' import { SnapPointProps } from 'react-spring-bottom-sheet/dist/types' import { ScreenSize, useScreenSize } from '../../hooks/useScreenSize' /** * @notice This component is a wrapper around react-spring-bottom-sheet */ export interface BottomSheetProps extends Omit { isOpen: boolean closeModal: () => void className?: string label: string hideCloseButton?: boolean // Modal specific props, pull from ModalProps as needed maxWidthClassName?: string widthClassName?: string maxHeightClassName?: string paddingClassName?: string bgClassName?: string roundedClassName?: string shadowClassName?: string overflowClassName?: string modalHeightClassName?: string style?: object onPreviousClick?: () => void onNextClick?: () => void } export const BottomSheet = (props: BottomSheetProps) => { const { children, isOpen, closeModal, className, label, header, hideCloseButton, maxWidthClassName, shadowClassName, widthClassName, maxHeightClassName, paddingClassName, modalHeightClassName, bgClassName, roundedClassName, overflowClassName, style, onPreviousClick, onNextClick, ...sheetProps } = props const size = useScreenSize() if (size > ScreenSize.sm) { return ( {children} ) } return ( } > {/* */}
{children}
) } BottomSheet.defaultProps = { label: 'bottom-sheet', overflowClassName: 'overflow-y-auto minimal-scrollbar' } export const snapTo90 = (snapPoints: SnapPointProps) => snapPoints.maxHeight * 0.9 export const snapToFull = (snapPoints: SnapPointProps) => { return snapPoints.maxHeight } // const CloseBottomSheetButton: React.FC<{ closeModal: () => void; hide: boolean }> = (props) => { // const { closeModal, hide } = props // if (hide) return null // return ( // // ) // } const BottomSheetHeader = (props: { header: React.ReactNode closeModal: () => void onPreviousClick: () => void onNextClick: () => void }) => { const { header, closeModal, onPreviousClick, onNextClick } = props return (
{!!onPreviousClick && } {!!onNextClick && }
{header}
) }