0.9.1 • Published 4 years ago

tg-modal v0.9.1

Weekly downloads
524
License
MIT
Repository
github
Last release
4 years ago

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

PropertyTypeDescription
onCancelfuncCalled when the user cancels the modal (Close button, backdrop click or ESC pressed). function (event, keyboard) {}
onConfirmfuncCalled after confirming the modal (Currently only by pressing ENTER) function () {}
isOpenboolShould the modal be visible
titlenodeWhen set, Modal will render this as child of Modal.Header element.
isStaticboolIs the modal Static (backdrop click won't trigger onCancel)
isBasicboolIs the modal Basic (backdrop only, best for confirms)
keyboardbool?Should the modal listen to keyboard events (ENTER or ESCAPE press) default: isOpen
autoWrapboolIf true, children will be wrapped inside Modal.Body default: false
onTogglefuncFunction called after the modal is toggled. function (isOpen, props) { }
transitionNamestringName of animation to use for open/close (to see how to define custom ones, see default styles) default: tg-modal-fade
transitionDurationintDuration of the transition in milliseconds default: 300
classNamestringExtra classnames to use for modal default:
dialogClassNamestringClassname to use for ModalDialog default: tg-modal-dialog
wrapperClassNamestringExtra classnames to use for modal wrapper default:

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

Modal.Header

PropertyTypeDescription
childrennodeContents
classNamestringClass name to add to the wrapper div default: tg-modal-header
isStaticboolIf true, the close button won't trigger onCancel
addCloseboolShow the close button default: true
onCancelfuncCallback to trigger when the close button is clicked

Modal.Body

PropertyTypeDescription
childrennodeContents
classNamestringClass 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

0.9.1-alpha.1

4 years ago

0.9.1

4 years ago

0.9.0

5 years ago

0.9.0-beta.3

5 years ago

0.9.0-beta.2

5 years ago

0.9.0-beta.1

5 years ago

0.9.0-beta.0

5 years ago

0.8.0

6 years ago

0.8.0-alpha.3

7 years ago

0.8.0-alpha.2

7 years ago

0.8.0-alpha.1

7 years ago

0.7.1

7 years ago

0.7.0

7 years ago

0.6.0

7 years ago

0.5.0

8 years ago

0.4.1

8 years ago

0.4.0

8 years ago

0.4.0-rc-1

8 years ago

0.3.2

8 years ago

0.3.1

8 years ago

0.3.0

8 years ago

0.2.10

8 years ago

0.2.9

8 years ago

0.2.8

8 years ago

0.2.7

9 years ago

0.2.6

9 years ago

0.2.5

9 years ago

0.2.3

9 years ago

0.2.2

9 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.2.0-dev

9 years ago