1.0.1-readme • Published 3 years ago

react-simple-bottom-sheet v1.0.1-readme

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

React Simple Bottom Sheet 🎉

A simple bottom sheet component for your React apps - best for PWAs 🔥

Preview

Installation 🚀

This library is built with framer-motion and styled-components therefore you have to install first these two dependencies on your project.

npm install framer-motion styled-components or yarn add framer-motion styled-components

then

npm install react-simple-bottom-sheet or yarn add react-simple-bottom-sheet

Sample Usage 💻

import React from "react";
import { bottomSheet } from "react-simple-bottom-sheet";

export  default  function App() {
    const handleOpen = () => bottomSheet.create({
	    content: (<p>Hello world!</p>),
    });
    return <button onClick={handleOpen}>Open</button>
}

You can check example/src folder to know more!

API 👋

  • bottomSheet.create(createConfig)
  • bottomSheet.close(closeConfig)
  • bottomSheet.isOpen(id)

The properties of config are as follows:

create({...})

PropertyDescriptionTypeDefault
idUnique identifier of the bottom sheetstring"default"
contentMain content of bottom sheet (required)ReactNode-
headerHeader content of bottom sheetReactNode-
footerFooter content of bottom sheetReactNode-
dragHandleDraggable elements of bottom sheet['content' \| 'header \| 'footer' \| 'mask']['header', 'mask']
onClosefunctionTrigger when bottom sheet is closed-
onOpenfunctionTrigger when bottom sheet is opened-
darkModebooleanChanges the appearance of bottom sheet to dark modefalse
maskClosablebooleanWhether to close the modal dialog when the mask (area outside the bottom sheet) is clickedtrue
debugbooleanEnables debug mode to show the draggable areasfalse

close({...})

PropertyDescriptionTypeDefault
idUnique identifier of the bottom sheet that needs to be closedstring"default"
callbackSpecifies the function that will be called after the bottom sheet is closedfunction-

isOpen(id)

PropertyDescriptionTypeDefault
idUnique identifier of the bottom sheet that needs to be checked if it's open.string"default"

Note 🗒

Putting clickable elements such as Buttons, Inputs, etc. on draggable areas is not possible as of the moment - still working on it.

Donation 🙏

If this project help you reduce time to develop, you can give me a cup of ☕️ or ☕️ :)

Paypal donate button

License 🙌

Copyright (c) 2021 chcepe.github.io

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.