7.0.4 • Published 6 years ago
@lightspeed/cirrus-modal v7.0.4
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>
Prop | Type | Description | Default |
---|---|---|---|
isOpen | boolean | Used to show the modal | N/A |
onAfterOpen | function | Callback invoked after the modal is shown | null |
onRequestClose | function | Callback invoked when the modal is closed | null |
closeOnEsc | boolean | Determines whether the user can use the ESC key to dismiss the modal. | true |
shouldCloseOnOverlayClick | boolean | Determines whether the user can dismiss the modal by clicking on the overlay. | true |
aside | boolean | When specified indicates that the modal should be displayed as an aside. | false |
<ModalHeader>
Prop | Type | Description | Default |
---|---|---|---|
children | React.ReactNode | The content to display inside the header | N/A |
onCloseClicked | function | Callback invoked when the close button is clicked | null |
showCloseButton | boolean | When specified indicates that a close button should be displayed. | true |
<ModalBody>
Prop | Type | Description | Default |
---|---|---|---|
children | React.ReactNode | The content to display inside the modal body | N/A |
scroll | boolean | When specified indicates tha the modal body content is scrollable. | false |
<ModalFooter>
Prop | Type | Description | Default |
---|---|---|---|
children | React.ReactNode | The content to display inside the modal footer | N/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
6 years ago
8.0.0-beta.1
6 years ago
8.0.0-beta.0
6 years ago
8.0.0-alpha.1
6 years ago
8.0.0-alpha.0
6 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
7 years ago
6.0.0
7 years ago
5.0.3
7 years ago
5.0.2
7 years ago
5.0.1
7 years ago
5.0.0
7 years ago
4.0.0
7 years ago
3.0.3
7 years ago
3.0.2
7 years ago
3.0.1
7 years ago
3.0.0
7 years ago
2.0.2
7 years ago
2.0.1
7 years ago
2.0.0
7 years ago
1.0.4
7 years ago
1.0.3
7 years ago
1.0.2
7 years ago
1.0.1
7 years ago
1.0.0
7 years ago
0.2.2
7 years ago
0.2.1
7 years ago
0.2.0
7 years ago
0.1.1
7 years ago
0.1.0
7 years ago