diff --git a/README.md b/README.md index 9f03ba04..e1a44a9c 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ MVP example, showing what you get by implementing `open`, `onDismiss` and a sing ## [Snap points & overflow](https://react-spring-bottom-sheet.cocody.dev/fixtures/scrollable) -> [View demo code](/pages/fixtures/scrollable.tsx#L85-L95) +> [View demo code](/pages/fixtures/scrollable.tsx#L86-L97) A more elaborate example that showcases how snap points work. It also shows how it behaves if you want it to be open by default, and not closable. Notice how it responds if you resize the window, or scroll to the bottom and starts adjusting the height of the sheet without scrolling back up first. diff --git a/docs/fixtures/CloseExample.tsx b/docs/fixtures/CloseExample.tsx new file mode 100644 index 00000000..9149ebb6 --- /dev/null +++ b/docs/fixtures/CloseExample.tsx @@ -0,0 +1,29 @@ +import cx from 'classnames/dedupe' +import { forwardRef } from 'react' +import Link from 'next/link' + +type Props = { + className?: Parameters[0] +} & Omit< + React.PropsWithoutRef, + 'children' | 'className' +> + +const CloseExample = forwardRef( + ({ className, ...props }, ref) => ( + + + Close example + + + ) +) + +export default CloseExample diff --git a/docs/fixtures/Container.tsx b/docs/fixtures/Container.tsx index df8defb0..4654ed3e 100644 --- a/docs/fixtures/Container.tsx +++ b/docs/fixtures/Container.tsx @@ -1,7 +1,7 @@ import cx from 'classnames/dedupe' import { useEffect } from 'react' import { useDetectEnv } from './hooks' -import Link from 'next/link' +import CloseExample from './CloseExample' export default function Container({ children, @@ -29,11 +29,7 @@ export default function Container({ className )} > - - - Close example - - + {children} ) diff --git a/pages/fixtures/scrollable.tsx b/pages/fixtures/scrollable.tsx index ce44da8b..109687e0 100644 --- a/pages/fixtures/scrollable.tsx +++ b/pages/fixtures/scrollable.tsx @@ -3,6 +3,7 @@ import type { NextPage } from 'next' import { useRef } from 'react' import scrollIntoView from 'smooth-scroll-into-view-if-needed' import Button from '../../docs/fixtures/Button' +import CloseExample from '../../docs/fixtures/CloseExample' import Code from '../../docs/fixtures/Code' import Container from '../../docs/fixtures/Container' import ScrollUp from '../../docs/fixtures/ScrollUp' @@ -84,6 +85,7 @@ const ScrollableFixturePage: NextPage = ({ } ref={sheetRef} initialFocusRef={focusRef} defaultSnap={({ maxHeight }) => maxHeight / 2} diff --git a/src/BottomSheet.tsx b/src/BottomSheet.tsx index 400dfe6f..30561697 100644 --- a/src/BottomSheet.tsx +++ b/src/BottomSheet.tsx @@ -39,6 +39,7 @@ export const BottomSheet = React.forwardRef< >(function BottomSheetInternal( { children, + sibling, className, footer, header, @@ -565,6 +566,7 @@ export const BottomSheet = React.forwardRef< pointerEvents: !ready || off ? 'none' : undefined, }} > + {sibling} {blocking ? (