7.0.4 • Published 5 years ago

@lightspeed/cirrus-modal v7.0.4

Weekly downloads
317
License
MIT
Repository
-
Last release
5 years ago

Modal

Cirrus component for displaying Modals.

Installation

First, make sure you have been through the Getting Started steps of adding Cirrus in your application.

If using Yarn:

yarn add @lightspeed/cirrus-modal

Or using npm:

npm i -S @lightspeed/cirrus-modal

Usage

Import required styles in your .scss:

@import '@lightspeed/cirrus-modal/scss';

React Component

<Modal>

PropTypeDescriptionDefault
isOpenbooleanUsed to show the modalN/A
onAfterOpenfunctionCallback invoked after the modal is shownnull
onRequestClosefunctionCallback invoked when the modal is closednull
closeOnEscbooleanDetermines whether the user can use the ESC key to dismiss the modal.true
shouldCloseOnOverlayClickbooleanDetermines whether the user can dismiss the modal by clicking on the overlay.true
asidebooleanWhen specified indicates that the modal should be displayed as an aside.false

<ModalHeader>

PropTypeDescriptionDefault
childrenReact.ReactNodeThe content to display inside the headerN/A
onCloseClickedfunctionCallback invoked when the close button is clickednull
showCloseButtonbooleanWhen specified indicates that a close button should be displayed.true

<ModalBody>

PropTypeDescriptionDefault
childrenReact.ReactNodeThe content to display inside the modal bodyN/A
scrollbooleanWhen specified indicates tha the modal body content is scrollable.false

<ModalFooter>

PropTypeDescriptionDefault
childrenReact.ReactNodeThe content to display inside the modal footerN/A

Example

import React from 'react';
import Modal, { ModalHeader, ModalBody, ModalFooter } from '@lightspeed/cirrus-modal';
import Button from '@lightspeed/cirrus-button';

class MyModal extends React.Component {
  constructor(props) {
    super(props);

    this.state = {
      isOpen: false,
    };

    this.closeModal = this.closeModal.bind(this);
  }

  closeModal() {
    this.setState({ isOpen: false });
  }

  render() {
    return (
      <div>
        <Modal
          isOpen={this.state.isOpen}
          onRequestClose={this.closeModal}
        >
          <ModalHeader onCloseClicked={this.closeModal}>My Modal</ModalHeader>

          <ModalBody>This is my modal. There are many modals like it but this one is mine.</ModalBody>

          <ModalFooter>
            <Button primary onClick={doSomething}>
              Fly, little Modal, FLY!
            </Button>
          </ModalFooter>
        </Modal>
      </div>;
    );
  }
}

export default MyModal;

CSS Component

Not available.

7.0.4

5 years ago

8.0.0-beta.1

5 years ago

8.0.0-beta.0

5 years ago

8.0.0-alpha.1

5 years ago

8.0.0-alpha.0

5 years ago

7.0.3

6 years ago

7.0.2

6 years ago

7.0.1

6 years ago

7.0.0

6 years ago

6.0.2

6 years ago

6.0.1

6 years ago

6.0.0

6 years ago

5.0.3

6 years ago

5.0.2

6 years ago

5.0.1

6 years ago

5.0.0

6 years ago

4.0.0

6 years ago

3.0.3

6 years ago

3.0.2

6 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago