2.0.4 • Published 10 months ago

@corasan/modal-sheet v2.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

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 { ModalSheetStackRef, ModalSheetStack } from '@corasan/modal-sheet';

function YourComponent() {
  const modalRef = useRef<ModalSheetStackRef>()

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

      <ModalSheetStack ref={modalRef} name="modal-drawer">
        <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.dismiss();
              }}
            />
          </View>
        </View>
      </ModalSheetStack>
    </View>
  );
}

Components

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.

Props

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
onDismiss() => void-Callback when the modal sheet is dismissedNo
enableDragToDismissbooleantrueEnable dragging to dismiss the modal sheetNo
<!--backdropColorstring"black"The color of the backdropNo
backdropOpacitynumber0.4The opacity of the backdropNo-->

Methods

NameTypeDescription
open() => voidOpen the modal sheet
dismiss() => voidDismiss the modal sheet
2.0.3

10 months ago

2.0.2

11 months ago

2.0.4

10 months ago

2.0.0-rc.17

1 year ago

2.0.0-rc.18

1 year ago

2.0.0-rc.16

1 year ago

2.0.1

11 months ago

2.0.0

1 year ago

2.0.0-rc.15

1 year ago

2.0.0-rc.14

1 year ago

2.0.0-rc.13

1 year ago

2.0.0-rc.11

1 year ago

2.0.0-rc.12

1 year ago

2.0.0-rc.10

1 year ago

2.0.0-rc.9

1 year ago

2.0.0-rc.8

1 year ago

2.0.0-rc.5

1 year ago

2.0.0-rc.6

1 year ago

2.0.0-rc.7

1 year ago

2.0.0-rc.3

1 year ago

2.0.0-rc.4

1 year ago

2.0.0-rc.2

1 year ago

2.0.0-rc.0

1 year ago

2.0.0-rc.1

1 year ago

1.4.2

1 year ago

1.4.1

1 year ago

1.4.0

1 year ago

1.3.0

1 year ago

1.2.0

1 year ago

1.1.0

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago