Skip to content

A react component for modals and dialogs which allows you to have custom header and super easy overrides of default styles.

License

Notifications You must be signed in to change notification settings

scherler/react-header-modal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-header-modal

React Header-modal is a simple react component for modals and dialogs. Powerful, lightweight and customizable design. It is based on https://github.com/marcio/react-skylight but re-written to use header and body.

NPM

Travis CI Coverage Status Quality dependencies devdependencies

Installation

npm i --save react-header-modal

License

License is MIT

Features

  • Very simple modal/dialog
  • Callback before open
  • Callback after open
  • Callback before close
  • Callback after close
  • Callback on overlay click
  • All styles can be overridden or not used at all

Proptypes

ModalView.propTypes = {
    afterClose: PropTypes.func,
    afterOpen: PropTypes.func,
    beforeClose: PropTypes.func,
    beforeOpen: PropTypes.func,

    title: PropTypes.string,
    body: PropTypes.string,
    children: PropTypes.object,

    onOverlayClicked: PropTypes.func,
    hideOnOverlayClicked: PropTypes.bool,
    showOverlay: PropTypes.bool,
    isVisible: PropTypes.bool,

    styles: React.PropTypes.oneOfType([
        PropTypes.shape({
            closeButtonStyle: PropTypes.object,
            dialogStyles: PropTypes.object,
            overlayStyles: PropTypes.object,
            titleStyle: PropTypes.object
        }),
        PropTypes.bool,
    ]),

}

How to use

import ModalView from 'react-header-modal';

<ModalView />

Default view.

default

import ModalView from 'react-header-modal';

<ModalView 
  hideOnOverlayClicked
  title="Hi, xxx modal"
  body="Simple Text"
/>

Simplest use is to pass the title and the body as an attribute.

simplest

import ModalView, {Body, Header} from 'react-header-modal';

<ModalView hideOnOverlayClicked>
    <Header>
        <ul>
            <li>Lorem ipsum dolor sit amet, impetus dissentiunt vix ne. Vix accumsan adipisci no, ius no
                populo voluptaria, no eam viderer appareat persequeris. Ex harum tollit nullam mea. Mei
                sanctus placerat ut, ad mei recusabo instructior, quo eu nonumes deleniti principes. Ceteros
                oportere aliquando ei pro, et dolores forensibus quo, te zril adolescens vix. Pro at illum
                dicit referrentur, fabellas conclusionemque ne nam.
            </li>
            ...
            <li>Lorem ipsum dolor sit amet, impetus dissentiunt vix ne. Vix accumsan adipisci no, ius no
                populo voluptaria, no eam viderer appareat persequeris. Ex harum tollit nullam mea. Mei
                sanctus placerat ut, ad mei recusabo instructior, quo eu nonumes deleniti principes. Ceteros
                oportere aliquando ei pro, et dolores forensibus quo, te zril adolescens vix. Pro at illum
                dicit referrentur, fabellas conclusionemque ne nam.
            </li>
    
        </ul>
    </Header>
    <Body>
        <ul>
            <li>Lorem ipsum dolor sit amet, impetus dissentiunt vix ne. Vix accumsan adipisci no, ius no
                populo voluptaria, no eam viderer appareat persequeris. Ex harum tollit nullam mea. Mei
                sanctus placerat ut, ad mei recusabo instructior, quo eu nonumes deleniti principes. Ceteros
                oportere aliquando ei pro, et dolores forensibus quo, te zril adolescens vix. Pro at illum
                dicit referrentur, fabellas conclusionemque ne nam.
            </li>
            ...
            <li>Lorem ipsum dolor sit amet, impetus dissentiunt vix ne. Vix accumsan adipisci no, ius no
                populo voluptaria, no eam viderer appareat persequeris. Ex harum tollit nullam mea. Mei
                sanctus placerat ut, ad mei recusabo instructior, quo eu nonumes deleniti principes. Ceteros
                oportere aliquando ei pro, et dolores forensibus quo, te zril adolescens vix. Pro at illum
                dicit referrentur, fabellas conclusionemque ne nam.
            </li>
    
        </ul>
    </Body>
</ModalView>

You can pass anything to header and body.

head_body_lot

import ModalView from 'react-header-modal';

<ModalView 
  hideOnOverlayClicked
  title="Hi, xxx modal"
  body="Simple Text"
  styles={{
    contentStyle: {
      backgroundColor: '#767535'
    }
  }}
/>

Simply override the default styles or turn them off (styles={false}) and use the class name hooks for add the styling.

style

import ModalView from 'react-header-modal';

<ModalView 
  hideOnOverlayClicked
  title="Hi, xxx modal"
  body="Simple Text"
  isVisible={true}
/>

You can show the modal visible when page has loaded, e.g. to show a notice or whatever.

You can use the "ESC" key to close the modal view.

About

A react component for modals and dialogs which allows you to have custom header and super easy overrides of default styles.

Resources

License

Stars

Watchers

Forks

Packages

No packages published