5.0.2 • Published 5 years ago

@lightspeed/cirrus-dialog v5.0.2

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

Dialog

Reusable and structured dialog box.

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-dialog

Or using npm:

npm i -S @lightspeed/cirrus-dialog

Usage

Import required styles in your .scss:

@import '@lightspeed/cirrus-dialog/Dialog.scss';

React Component

Props

PropTypeDefaultRequiredDescription
typestringdefaultnoOne of default, primary, secondary, danger
messagestringyesString shown in the ModalBody as the message, required
titlestringnoString shown in the ModalHeader as title
isOpenboolfalsenoState to determine if <Dialog> should be displayed
isLoadingboolfalsenoState to determine if the actions buttons should be disabled while some promise is getting resolved
scrollboolfalsenoState to determine if the body of the modal should be scrollable or not
onCancelfuncyesFunction called when the cancel button is clicked, required
onConfirmfuncyesFunction called when the confirm button is clicked, required
cancelTextstring'Cancel'noString shown on the cancel button
confirmTextstring'Ok'noString shown on the confirm button
cancelRestobjectnoShape with any object pass to the cancel button, e.g({data-test: 'dialog-cancel-button'})
confirmRestobjectnoShape with any object pass to the confirm button, e.g({data-test: 'dialog-cancel-button'})

Example

import React from 'react';
import Dialog from '@lightspeed/cirrus-dialog';

const MyComponent = () => (
  <Dialog
    title="Title"
    message="Messsage"
    isOpen={this.state.isOpen}
    isLoading={this.state.isLoading}
    onCancel={this.onCancel}
    onConfirm={this.onConfirm}
    cancelText="No"
    confirmText="Yes"
    type="danger"
  />
);

export default MyComponent;

CSS Component

Classes

TypeClass
base.cr-dialog
base.cr-dialog__actions

Example

<div class="cr-dialog">
    <div class="cr-modal__header">
        <div class="cr-modal__header__content-wrap">Dialog Prompt ''</div>
        <div class="cr-modal__close-wrap"></div>
    </div>
    <div class="cr-modal__body">
        <p class="cr-text-base cr-text--body">Are you sure, are you really really sure? It's your call. </p>
    </div>
    <div class="cr-modal__footer">
        <div class="cr-group cr-dialog__actions">
            <div class="cr-group__item">
                <button type="button" class="cr-button"><span class="cr-button__content">No</span></button>
            </div>
            <div class="cr-group__item">
                <button type="button" class="cr-button cr-button--fill"><span class="cr-button__content">Yes</span></button>
            </div>
        </div>
    </div>
</div>
5.0.2

5 years ago

6.0.0-beta.1

5 years ago

6.0.0-beta.0

5 years ago

6.0.0-alpha.1

5 years ago

6.0.0-alpha.0

5 years ago

5.0.1

5 years ago

5.0.0

6 years ago

4.0.14

6 years ago

4.0.13

6 years ago

4.0.12

6 years ago

4.0.11

6 years ago

4.0.10

6 years ago

4.0.9

6 years ago

4.0.8

6 years ago

4.0.7

6 years ago

4.0.6

6 years ago

4.0.5

6 years ago

4.0.4

6 years ago

4.0.3

6 years ago

4.0.2

6 years ago

4.0.1

6 years ago

4.0.0

6 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.0.5

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.1.0

6 years ago