1.0.14 • Published 5 years ago

react-bootstrap-simple-popup v1.0.14

Weekly downloads
60
License
-
Repository
-
Last release
5 years ago

A simple popup based on bootstrap's modal. I wanted something that allowed the caller to control when it popped up, so on mount it will callback the caller with a set of control functions, open and close.

These do what you'd expect.

This project is built with yarn, but npm should work as well.

To test run npm install and npm run start To build the library run npm run build

Two ways to use it:

Static

let open = () => { };
let close = () => { };

ReactDOM.render(
[
<button onClick={() => {
    open();
}}>Open Popup!</button>,
<Container>
    <SimplePopup title="Test Popup" message="Here's a popup!" buttons={[{
    label: 'Ok!',
    id: 'okButton'
    }]} controls={(c, o) => { close = c; open = o }} on={id => close()}/>
</Container>], document.getElementById("root"));

You can also put components in the children and they will get rendered. So if you want form elements in there you can do:

<SimpleModal ...>
  <input .../>
</SimpleModal>

Dynamic

I also discovered I wanted to do some inline workflow. ie. Do some work, ask the user something and respond.

let open = () => { };
let close = () => { };
let openWithProps = (displayProps) => void;

ReactDOM.render(
[
    <button
      onClick={() => {
        openWithProps({
          title: "Title is set during click",
          message:
            "We modified the title, message, buttons and callbacks!",
          buttons: [
            {
              id: "new1",
              label: "Choice 1"
            },
            {
              id: "new2",
              label: "Choice 2"
            }
          ],
          on: id => {
            alert(id + "was clicked");
            close();
          }
        });
      }}
    >,
<Container>
    <SimplePopup title="Test Popup" message="Here's a popup!" buttons={[{
    label: 'Ok!',
    id: 'okButton'
    }]} controls={(c, o, withProps) => { close = c; open = o, openWithProps = withProps }} on={id => close()}/>
</Container>], document.getElementById("root"));
1.0.14

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago