2.0.0-rc.15 • Published 22 days ago

@corasan/modal-sheet v2.0.0-rc.15

Weekly downloads
-
License
MIT
Repository
github
Last release
22 days ago

!WARNING This package is still in development and not fully featured yet (experimental). Please use with caution.

Installation

npm install @corasan/modal-sheet
yarn add @corasan/modal-sheet
bun add @corasan/modal-sheet

Usage

First, wrap your application with the ModalSheetProvider component.

import { ModalSheetProvider } from '@corasan/modal-sheet';

function App() {
  return (
    <ModalSheetProvider>
      <YourApp />
    </ModalSheetProvider>
  );
}

Use refs to expand and minimize the modal sheet.

import { ModalSheet, ModalSheetRef, ModalSheetStackRef } from '@corasan/modal-sheet';

function YourComponent() {
  const modalRef = useRef<ModalSheetRef>()
  const modalSheetRef = useRef<ModalSheetRef>()

  return (
    <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
      <Butto title="Open Modal Sheet" onClick={() => modalRef.current.extend())} />

      <ModalSheet ref={modalRef} name="modal-drawer" sizes={[100, 300, 600]}>
        <View style={{ flex: 1 }}>
          <View style={{ flexDirection: "row", justifyContent: "center" }}>
            <Text style={{ fontWeight: "500", fontSize: 18 }}>Title</Text>
          </View>

          <View
            style={{
              paddingVertical: 40,
              alignItems: "center",
              justifyContent: "center",
            }}
          >
            <Button
              title="Close Modal"
              onPress={() => {
                modalRef.current.minimize();
              }}
            />
          </View>
        </View>
      </ModalSheet>
      <ModalSheet ref={modalSheetRef} name="modal-sheet" sizes={[100, 300, 600]}>
        <View style={{ flex: 1 }}>
          <View style={{ flexDirection: "row", justifyContent: "center" }}>
            <Text style={{ fontWeight: "500", fontSize: 18 }}>Title</Text>
          </View>

          <View
            style={{
              paddingVertical: 40,
              alignItems: "center",
              justifyContent: "center",
            }}
          >
            <Button
              title="Close Modal"
              onPress={() => {
                modalRef.current.minimize();
              }}
            />
          </View>
        </View>
      </ModalSheet>
    </View>
  );
}

Props

ModalSheet

The ModalSheet component is a modal sheet that can be expanded and minimized. It can be used to create a drawer-type of modal sheet and can be stacked on top of each other.

NameTypeDefaultDescriptionRequired
refReact.RefObject\-Ref for the modal sheetYes
namestring-The name of the modal sheetYes
childrenReactNode-The children componentsKinda yeah
containerStylestring-Styles for the modal sheet containerNo
noHandlebooleanfalseHide the handleNo
sizesnumber[]100, 300, 600The sizes the modal can be expanded toNo
backdropColorstring"black"The color of the backdropNo
backdropOpacitynumber0.4The opacity of the backdropNo
offsetnumber0Add an offset at the bottom of the modal sheet when it's minimizedNo
<!--disableSheetStackEffectboolean-Disable sheet stack effectNo
onGestureUpdate(e: GestureUpdateEvent\) => void-Custom callback to handle gesture updatesNo
onGestureBegin(e: GestureStateChangeEvent\) => void-Custom callback to handle on gesture beginNo
onGestureEnd(e: GestureStateChangeEvent\) => void-Custom callback to handle on gesture endNo
onGestureStart(e: GestureStateChangeEvent\) => void-Custom callback to handle on gesture startNo
onGestureFinalize(e: GestureStateChangeEvent\) => void-Custom callback to handle on gesture finalizeNo
onGestureTouchesDown(e: GestureTouchEvent) => void-Custom callback to handle on gesture touch downNo
onGestureTouchesUp(e: GestureTouchEvent) => void-Custom callback to handle on gesture touch upNo
onGestureTouchesMove(e: GestureTouchEvent) => void-Custom callback to handle on gesture touch moveNo
onGestureTouchesCancelled(e: GestureTouchEvent) => void-Custom callback to handle on gesture touch cancelledNo-->

ModalSheetStack

The ModalSheetStack component is a modal sheet that can be opened and dismissed. It creates a modal sheet effect similar to the iOS modal sheet.

NameTypeDefaultDescriptionRequired
refReact.RefObject\-Ref for the modal sheetYes
namestring-The name of the modal sheetYes
childrenReactNode-The children componentsKinda yeah
containerStylestring-Styles for the modal sheet containerNo
noHandlebooleanfalseHide the handleNo
backdropColorstring"black"The color of the backdropNo
backdropOpacitynumber0.4The opacity of the backdropNo
2.0.0-rc.15

22 days ago

2.0.0-rc.14

22 days ago

2.0.0-rc.13

25 days ago

2.0.0-rc.11

26 days ago

2.0.0-rc.12

26 days ago

2.0.0-rc.10

26 days ago

2.0.0-rc.9

26 days ago

2.0.0-rc.8

27 days ago

2.0.0-rc.5

29 days ago

2.0.0-rc.6

29 days ago

2.0.0-rc.7

29 days ago

2.0.0-rc.3

1 month ago

2.0.0-rc.4

1 month ago

2.0.0-rc.2

1 month ago

2.0.0-rc.0

1 month ago

2.0.0-rc.1

1 month ago

1.4.2

1 month ago

1.4.1

1 month ago

1.4.0

1 month ago

1.3.0

1 month ago

1.2.0

2 months ago

1.1.0

2 months ago

1.0.1

2 months ago

1.0.0

2 months ago