Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/javadbat/jb-modal-react
react wrapper for jb-modal web-component
https://github.com/javadbat/jb-modal-react
Last synced: 7 days ago
JSON representation
react wrapper for jb-modal web-component
- Host: GitHub
- URL: https://github.com/javadbat/jb-modal-react
- Owner: javadbat
- License: mit
- Created: 2022-09-13T07:54:06.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-13T21:36:46.000Z (2 months ago)
- Last Synced: 2024-10-23T04:12:21.028Z (2 months ago)
- Language: TypeScript
- Size: 6.84 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# JBModal
a react component modal that open different in mobile and desktop
this component is React.js wrapper for [jb-modal](https://www.npmjs.com/package/jb-modal) web component.- open like bottomsheet in mobile and open in center position in desktop
- customizable layout with css variable
- support typescript
- support custom url to adapt "back to close" on android and "auto open modal on refresh"
## installation
```command
npm i jb-modal-react
```in your jsx file
```js
import {JBModal} from 'jb-modal-react'
```
``` jsx
```## use
you can place your modal content in ` ` like:
```jsx
this is the modal content
```### props
- onClose
you can pass a function to onClose props so that when a user click outside of the modal, the modal closes.``` jsx
const [isOpen, setIsOpen] = useState(false);
setIsOpen(false)}>```
- isOpen
you can pass true or false to this props,this way the modal will be open based on the isOpen props.``` jsx
// the modal is open
```- id
you can set a specific id for each one of your modals,this way when the modal is open the id of the modal will be in your url.``` jsx
```- onUrlOpen
when the react copmonent first renders the default state of isModalOpen is false.
when the url contains the id of the modal the function passed to onUrlOpen will update the react state and set the isModalOpen state to true.
example:```jsx
[isModalOpen, setOpen] = useState(false);
setOpen(true)}>
```
## customize modal lookyou can customize modal look by following css properties
| css variable name | description |
| ------------- | ------------- |
| --jb-modal-bg-color | modal background color default is black `#fff` |
| --jb-modal-border-radius | modal border-radius default `24px` |
| --jb-modal-border-radius-mobile | modal border-radius on mobile default is `24px 24px 0 0` |