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

tg-modal

v0.9.1

Published

Universal controlled modals for React

Downloads

1,577

Readme

tg-modal

Introduction

tg-modal is a react component for Modals. It aims to provide a standalone Modal without the need of adding a big UI library to your dependencies.

NPM version Build Status Coverage Dependency Status Greenkeeper badge Downloads

Installation

npm install tg-modal

Import

import Modal from 'tg-modal';

Styles

To get the actual modal working (it might be invisible without styles), one should import default styles to your own assets. The default styles are available as:

CSS: node_modules/dist/default.css SCSS: tg-modal/dist/default.scss

Custom styles

To use your own styles, the current recommendation is importing the default styles, and customizing them.

Usage

Assuming you have included the style-sheet, you can render a simple modal like this:

// Import the modal
import Modal from 'tg-modal';

<Modal isOpen={true} title="First modal" isStatic>
    Modal body...
</Modal>

This will render a static modal, which cannot be hidden by the user.

PropTypes

Modal

| Property | Type | Description |---------------------|--------|------------ | onCancel | func | Called when the user cancels the modal (Close button, backdrop click or ESC pressed). function (event, keyboard) {} | onConfirm | func | Called after confirming the modal (Currently only by pressing ENTER) function () {} | | isOpen | bool | Should the modal be visible | title | node | When set, Modal will render this as child of Modal.Header element. | isStatic | bool | Is the modal Static (backdrop click won't trigger onCancel) | isBasic | bool | Is the modal Basic (backdrop only, best for confirms) | keyboard | bool? | Should the modal listen to keyboard events (ENTER or ESCAPE press) [default: isOpen] | autoWrap | bool | If true, children will be wrapped inside Modal.Body [default: false] | onToggle | func | Function called after the modal is toggled. function (isOpen, props) { } | transitionName | string | Name of animation to use for open/close (to see how to define custom ones, see default styles) [default: tg-modal-fade] | transitionDuration | int | Duration of the transition in milliseconds [default: 300] | className | string | Extra classnames to use for modal [default: ] | dialogClassName | string | Classname to use for `ModalDialog` [default: tg-modal-dialog] | wrapperClassName | string | Extra classnames to use for modal wrapper [default: ]

Props not specified here are considered internal, and are prone to change.

Modal.Header

| Property | Type | Description |---------------------|-------------|-------------- | children | node | Contents | className | string | Class name to add to the wrapper div [default: tg-modal-header] | isStatic | bool | If true, the close button won't trigger onCancel | addClose | bool | Show the close button [default: true] | onCancel | func | Callback to trigger when the close button is clicked

Modal.Body

| Property | Type | Description |---------------------|-------------|-------------------------------- | children | node | Contents | className | string | Class name to add to the wrapper div [default: tg-modal-body]

Examples

Examples are available here.

Troubleshooting

If you encounter a problem, please file an issue.

License

MIT © Thorgate