react-mobile-modals

Made with create-react-library

Usage no npm install needed!

<script type="module">
  import reactMobileModals from 'https://cdn.skypack.dev/react-mobile-modals';
</script>

README

React mobile modals

Made with create-react-library

NPM JavaScript Style Guide

Use with webview for creation pretty navigation 📱

example

Install

npm install --save react-mobile-modals

or

yarn add react-mobile-modals

Usage

import React from 'react'

import { ModalsProvider, useModals } from 'react-mobile-modals'
import 'react-mobile-modals/dist/index.css'

const SecondPage = () => {
  const { closeModal } = useModals();

  return (
    <div className="page">
      <button onClick={closeModal}>
        Back
      </button>
    </div>  
  )
}

const FirstPage = () => {
  const { openModal } = useModals();

  const openSecondPage = () => openModal({ component: <SecondPage />, direction: "vertical" });

  return (
    <div className="page">
      <button onClick={openSecondPage}>
        Open second page
      </button>
    </div>  
  )
}


const MainWindow = () => {
  const { openModal } = useModals();

  const openFirstPage = () => openModal({ component: <FirstPage /> });

  return (
    <div className="page main">
      <button onClick={openFirstPage}>
        Open first page
      </button>
    </div>
  )
}

const App = () => {
  render() {
    return (
      <ModalsProvider>
        <MainWindow />
      </ModalsProvider>
    )
  }
}

openModal(modalProps)

modalProps

  • component: ReactNode;
  • direction: horizontal(default), vertical;

Example https://skilldill.github.io/react-mobile-modals/

License

MIT ©