1.0.21 • Published 4 years ago

whyseco-modal-simple v1.0.21

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

Modal-Simple

This is a simple quick and customizable modal component that you can use in your App. The modal is based on bootstrap.

Installation

    npm i modal-simple react-bootstrap 

and don't forget to add the bootstrap's stylesheet <link> into your <head> before all other stylesheets to load CSS :

LINK TO BOOTSTRAP STYLESHEET

Demo

Examples

  1. Simple use
```javascript
<Modal title={{ text: "title" }} bodyText="something" />
```

exempl-1

  1. Simple Custom

    <Modal
      open={{
        text: "Open me",
        className: "open",
        variant: "secondary"
      }}
      title={{ text: "title" }}
      closeBtn={{ show: false }}
    >
      <strong>test 2</strong>
    
      <Modal.Footer validate={{ text: "Validate", variant: "primary" }} />
    </Modal>

exemple-2

  1. Hard custom

    state = { show: false };
    modalState = () => {
    this.setState({ show: !this.state.show });
    };
    render() {
        return (
        <div className="App">
            <button className="open" onClick={this.modalState}>
            "Open"
            </button>
            <Modal
                show = {this.state.show}
                onHide = {this.modalState}
                closeBtn = {{ show: true, className: "btn-close" }}
                className = {{
                    modal: "modal-block-App",
                    header: "header-block",
                    body: "body-block",
                    footer: "footer-block"
                }}
                <Modal.Header>
                    <h1 className='title'>Hard Custom</h1>
                </Modal.Header>
                <Modal.Body>
                    <div className="d-flex flex-row body-block">
                        <img src={logo} alt="logo"/>
                        <img src={logo} alt="logo"/>
                        test
                    </div>
                </Modal.Body>
    
                <Modal.Footer
                    validate = {{
                        text: "Validate",
                        action: this.modalState,
                        className: "btn-valid"
                    }} ,
                    cancel = {{
                        text: "Close",
                        action: this.modalState,
                        className: "btn-cancel"
                    }}
                />
            </Modal>
        </div>
        )
    }
```

exemple-3

API

Modal

NameTypeDefaultDescription
showbooleanfalseWhen true the modal willshow itself.
onHidefunctionA callback fired when theheader closeButton or non-static backdrop is clicked. Required if either specified.
titleobjecttext: string className: stringSpecify the header title and className.
closeBtnobjectshow : Boolean className : stringSpecify if you need the close button appear and apply a class.
classNameobjectmodal: stringheader: stringbody: stringfooter: stringAdd a className to each part to be able to custom them.
footerbooleantrueif you don't want the block footer appear set it to false.
openobjecttext: string className: stringvariant: stringYou can custom the provide button by your own text and style.

Modal.Footer

NameTypeDefaultDescription
validateobjecttext: string action: functionclassName:stringvariant:stringYou can custom the provide button by your own text and style.
cancelobjecttext: string action: functionclassName:stringvariant:stringYou can custom the provide button by your own text and style.