Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

boundless-modal

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

boundless-modal

A blocking, focus-stealing container.

latest
Source
npmnpm
Version
1.1.0
Version published
Weekly downloads
2
100%
Maintainers
1
Weekly downloads
 
Created
Source

Modal

Modal is an enhancement upon Dialog. Typically, a masking layer is provided to obscure the rest of the page in some fashion, while also blocking outside click and keystroke access until the modal is dismissed.

Installation

npm i boundless-modal --save

Then use it like:

/** @jsx createElement */

import { createElement, PureComponent } from 'react';
import Button from 'boundless-button';
import Modal from 'boundless-modal';

export default class ModalDemo extends PureComponent {
    state = {
        showModal: false,
    }

    toggleModal = () => {
        this.setState({ showModal: !this.state.showModal });
    }

    renderModal() {
        if (this.state.showModal) {
            return (
                <Modal className='demo-modal'>
                    <h3>Account Deletion</h3>

                    <p>Are you sure you want to remove your account permanently?</p>

                    <Button onPressed={this.toggleModal}>Yes</Button>
                    <Button className='demo-modal-cancel-button' onPressed={this.toggleModal}>No</Button>
                </Modal>
            );
        }
    }

    render() {
        return (
            <div>
                <Button ref='trigger' onPressed={this.toggleModal}>
                    Delete Account
                </Button>
                {this.renderModal()}
            </div>
        );
    }
}

Modal can also just be directly used from the main Boundless library. This is recommended when you're getting started to avoid maintaining the package versions of several components:

npm i boundless --save

the ES6 import statement then becomes like:

import { Modal } from 'boundless';

Props

Note: only top-level props are in the README, for the full list check out the website.

Required Props

There are no required props.

Optional Props

  • * · any React-supported attribute

    ExpectsDefault Value
    anyn/a
  • after · arbitrary content to be rendered after the dialog in the DOM

    ExpectsDefault Value
    any renderablenull
  • before · arbitrary content to be rendered before the dialog in the DOM

    ExpectsDefault Value
    any renderablenull
  • captureFocus · determines if focus is allowed to move away from the dialog

    ExpectsDefault Value
    booltrue
  • closeOnEscKey · enable detection of "Escape" keypresses to trigger props.onClose; if a function is provided, the return value determines if the dialog will be closed

    ExpectsDefault Value
    bool or functionfalse
  • closeOnInsideClick · enable detection of clicks inside the dialog area to trigger props.onClose; if a function is provided, the return value determines if the dialog will be closed

    ExpectsDefault Value
    bool or functionfalse
  • closeOnOutsideClick · enable detection of clicks outside the dialog area to trigger props.onClose; if a function is provided, the return value determines if the dialog will be closed

    ExpectsDefault Value
    bool or functionfalse
  • closeOnOutsideFocus · enable detection of focus outside the dialog area to trigger props.onClose; if a function is provided, the return value determines if the dialog will be closed

    ExpectsDefault Value
    bool or functionfalse
  • closeOnOutsideScroll · enable detection of scroll and mousewheel events outside the dialog area to trigger props.onClose; if a function is provided, the return value determines if the dialog will be closed

    ExpectsDefault Value
    bool or functionfalse
  • component · override the type of .b-dialog-wrapper HTML element

    ExpectsDefault Value
    string'div'
  • dialogComponent · override the type of .b-dialog HTML element

    ExpectsDefault Value
    string'div'
  • dialogProps

    ExpectsDefault Value
    object{}
  • maskProps

    ExpectsDefault Value
    object{}
  • modalProps

    ExpectsDefault Value
    object{}
  • onClose · a custom event handler that is called to indicate that the dialog should be unrendered by its parent; the event occurs if one or more of the "closeOn" props (closeOnEscKey, closeOnOutsideClick, etc.) are passed as true and the dismissal criteria are satisfied

    ExpectsDefault Value
    function() => {}
  • portalProps

    ExpectsDefault Value
    object{}

Reference Styles

Stylus

You can see what variables are available to override in variables.styl.

// Redefine any variables as desired, e.g:
color-accent = royalblue

// Bring in the component styles; they will be autoconfigured based on the above
@require "node_modules/boundless-modal/style"

CSS

If desired, a precompiled plain CSS stylesheet is available for customization at /build/style.css, based on Boundless's default variables.

Keywords

react

FAQs

Package last updated on 06 Jun 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts