1.0.4 • Published 4 years ago

@denkschuldt/react-dialog v1.0.4

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

@denkschuldt/react-dialog

A simple to use and customizable react dialog implementation.

Installation

# NPM
$ npm install --save @denkschuldt/react-dialog
VersionCompatibility
1.xReact ˆ16.8+

Basic usage

import ReactDOM from 'react-dom';
import React, { useState } from 'react';
import Dialog from '@denkschuldt/react-dialog';

const App = () => {
  const [ isVisible, setIsVisible ] = useState(false);
  return (
    <div>
      <button
        type='button'
        onClick={() => setIsVisible(true)}>
        Show dialog
      </button>
      {
        isVisible &&
        <Dialog
          title='Dialog'
          onCancelClick={() => {}}
          onConfirmClick={() => {}}
          onCloseClick={() => setIsVisible(false)}>
          <span>
            This is the body
          </span>
        </Dialog>
      }
    </div>
  );
}

ReactDOM.render(<App/>, document.getElementById('root'));

See more examples at @DenkSchuldt/react-dialog

Props

NameTypeRequiredDescriptionDefault
widthNumberDialog width
heightNumberDialog height
titleStringDialog title
draggableBooleanAllows dialog dragtrue
classNameStringComponent class to override styles
slideInStringInitial animation: top, bottom, left, right
cancelableOutsideBooleanWhether the dialogs closes by clicking outside or notfalse
closeOnEscPressBooleanWhether the dialogs closes by pressing escapefalse
hideCloseButtonBooleanHides the close buttonfalse
onCloseClickfunction:white_check_mark:Close button click function
cancelTextStringNegative button text'CANCEL'
onCancelClickfunctionNegative button click function
cancelDisabledBooleanNegative button disabled propfalse
confirmTextStringPositive button text'OK'
onConfirmClickfunctionPositive button click function
confirmDisabledBooleanPositive button disabled propfalse

Styling

Use the className prop to override dialogs classes:

.your-css-class {
  .dnk-dialog-content {
    /* The dialog card */
    .dnk-dialog-close {
      /* The close button */
    }
    .dnk-dialog-body {
      .dnk-dialog-body-buttons {
        /* The buttons div container */
        button {
          /* cancel button */
          &.dnk-btn-primary {
            /* confirm button */
          }
        }
      }
    }
  }
}

Contributing

  • Fork the project
  • Make changes and include tests
  • Update README, CHANGELOG with detailed info
  • Send me a PR :bowtie:

License

MIT