npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-bootstrap-quick-modal

v0.0.5

Published

React / Bootstrap modals with fewer keystrokes

Downloads

7

Readme

react-bootstrap-quick-modal

This is a helper component for creating modals in React/Bootstrap. There are two things you should care about:

Modal

<Modal title="Test modal">
  <div>
    <h1>My content</h1>
    <MySubComponent />
  </div>
</Modal>

You can customize all of the visual details about the modal via props. One other important detail is that children are passed a reference to the parent modal via the modal prop. This can be used to, for instance, call setState or class methods on the parent modal. I use this for toggling the confirmation button on the modal based on whether a form validation succeeded or failed.

You can also pass stateManager prop to the modal to get the same reference from a parent prop.

Refer below for a full list of props.

Modal Launcher Button

<ModalLauncher component={<SubComponent />} buttonText="Let's do this." />

This is a convenience method for both creating the button that you launch the modal with and adding the modal. It gives you all of the same facilities for managing / customizing the modal (with a few slight differences), as well as the ability to customize the button.

Refer below for a full list of props.

Props

Auto generated using React Docgen.

Modal

{
  "show": {
    "type": {
      "name": "bool"
    },
    "required": false,
    "description": "whether or not the component should be shown on load",
    "defaultValue": {
      "value": "true",
      "computed": false
    }
  },
  "onHide": {
    "type": {
      "name": "func"
    },
    "required": false,
    "description": "called when the modal is closed",
    "defaultValue": {
      "value": "()=>{ console.info('Provide onHide for callback on hide.'); }",
      "computed": false
    }
  },
  "title": {
    "type": {
      "name": "string"
    },
    "required": false,
    "description": "the title for the modal",
    "defaultValue": {
      "value": "'Modal title'",
      "computed": false
    }
  },
  "closeText": {
    "type": {
      "name": "string"
    },
    "required": false,
    "description": "text for close button",
    "defaultValue": {
      "value": "'Close'",
      "computed": false
    }
  },
  "onConfirm": {
    "type": {
      "name": "func"
    },
    "required": false,
    "description": "called when confirm button is clicked",
    "defaultValue": {
      "value": "()=>{ console.info('Provide onConfirm for callback on confirm.'); }",
      "computed": false
    }
  },
  "confirmText": {
    "type": {
      "name": "string"
    },
    "required": false,
    "description": "text for confirm button",
    "defaultValue": {
      "value": "'Confirm'",
      "computed": false
    }
  },
  "confirmBSStyle": {
    "type": {
      "name": "string"
    },
    "required": false,
    "description": "Bootstrap style for confirm button",
    "defaultValue": {
      "value": "'primary'",
      "computed": false
    }
  },
  "confirmDisabled": {
    "type": {
      "name": "bool"
    },
    "required": false,
    "description": "Should confirm be disabled by default?",
    "defaultValue": {
      "value": "false",
      "computed": false
    }
  },
  "hideConfirm": {
    "type": {
      "name": "bool"
    },
    "required": false,
    "description": "Hide confirm button by default",
    "defaultValue": {
      "value": "false",
      "computed": false
    }
  },
  "hideOnConfirm": {
    "type": {
      "name": "bool"
    },
    "required": false,
    "description": "Should confirmation hide the modal?",
    "defaultValue": {
      "value": "true",
      "computed": false
    }
  },
  "stateManager": {
    "type": {
      "name": "func"
    },
    "required": false,
    "description": "This method will be bound to the context",
    "defaultValue": {
      "value": "()=>{}",
      "computed": false
    }
  }
}

Modal Launch

{
  "style": {
    "type": {
      "name": "object"
    },
    "required": false,
    "description": "",
    "defaultValue": {
      "value": "{}",
      "computed": false
    }
  },
  "show": {
    "type": {
      "name": "bool"
    },
    "required": false,
    "description": "whether or not the component should be shown on load",
    "defaultValue": {
      "value": "false",
      "computed": false
    }
  },
  "onHide": {
    "type": {
      "name": "func"
    },
    "required": false,
    "description": "called when the modal is closed",
    "defaultValue": {
      "value": "()=>{ console.info(\"Provide onHide to have a callback when modal closes.\") }",
      "computed": false
    }
  },
  "buttonClassName": {
    "type": {
      "name": "string"
    },
    "required": false,
    "description": "Custom class name used on the button",
    "defaultValue": {
      "value": "''",
      "computed": false
    }
  },
  "buttonBSStyle": {
    "type": {
      "name": "string"
    },
    "required": false,
    "description": "Bootstrap class to be used on the button",
    "defaultValue": {
      "value": "'primary'",
      "computed": false
    }
  },
  "buttonBSSize": {
    "type": {
      "name": "string"
    },
    "required": false,
    "description": "Button size",
    "defaultValue": {
      "value": "'sm'",
      "computed": false
    }
  },
  "buttonStyle": {
    "type": {
      "name": "object"
    },
    "required": false,
    "description": "Custom css to be applied to the button",
    "defaultValue": {
      "value": "{}",
      "computed": false
    }
  },
  "buttonText": {
    "type": {
      "name": "string"
    },
    "required": false,
    "description": "Text to show in the button",
    "defaultValue": {
      "value": "'Launch Modal'",
      "computed": false
    }
  },
  "alternateButtonElement": {
    "type": {
      "name": "any"
    },
    "required": false,
    "description": "An alternate button to show",
    "defaultValue": {
      "value": "false",
      "computed": false
    }
  },
  "component": {
    "type": {
      "name": "element"
    },
    "required": false,
    "description": "component to be rendered inside the modal",
    "defaultValue": {
      "value": "'<div>component will be rendered here</div>'",
      "computed": false
    }
  },
  "title": {
    "type": {
      "name": "string"
    },
    "required": false,
    "description": "The title displayed in the modal",
    "defaultValue": {
      "value": "'title'",
      "computed": false
    }
  },
  "closeText": {
    "type": {
      "name": "string"
    },
    "required": false,
    "description": "Text to be shown in the close button",
    "defaultValue": {
      "value": "'Close'",
      "computed": false
    }
  },
  "hideConfirm": {
    "type": {
      "name": "bool"
    },
    "required": false,
    "description": "Should the confirm button of the modal be hidden?",
    "defaultValue": {
      "value": "false",
      "computed": false
    }
  },
  "hideOnConfirm": {
    "type": {
      "name": "bool"
    },
    "required": false,
    "description": "Should the modal be hidden on confirm?",
    "defaultValue": {
      "value": "true",
      "computed": false
    }
  },
  "confirmText": {
    "type": {
      "name": "string"
    },
    "required": false,
    "description": "Text to be shown in the confirm button",
    "defaultValue": {
      "value": "'Submit'",
      "computed": false
    }
  },
  "confirmBSStyle": {
    "type": {
      "name": "string"
    },
    "required": false,
    "description": "Bootstrap style for confirm button",
    "defaultValue": {
      "value": "''",
      "computed": false
    }
  },
  "confirmDisabled": {
    "type": {
      "name": "bool"
    },
    "required": false,
    "description": "Should confirm be disabled by default?",
    "defaultValue": {
      "value": "false",
      "computed": false
    }
  },
  "modalStateManager": {
    "type": {
      "name": "func"
    },
    "required": false,
    "description": "A method which will have it's context bound to the modal and can be used to manage its state from other components",
    "defaultValue": {
      "value": "()=>{}",
      "computed": false
    }
  }
}