1.7.0 • Published 2 years ago

react-win-dialog v1.7.0

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

react-win-dialog

An attempt to recreate the Dialog element from WinJS, with full TypeScript definitions.

Screeshot of React Win Dialog

Installation

With Yarn:

yarn install react-win-dialog

Or from NPM:

npm install react-win-dialog --save

Importing

Import React-Win-Dialog via ES6 default import:

import Dialog from "react-win-dialog";

Or via Node's require:

const Dialog = require("react-win-dialog").default;

Example

import Dialog from "react-win-dialog";

render() {
    return (
        <Dialog
            open={this.state.dialogOpen}
            title={`React Win Dialog`}
            primaryText={`Save Changes`}
            secondaryText={`Close`}
            onSecondaryClick={e => this.setState({dialogOpen: false})}>
            <p>{`Wolf kogi whatever cold-pressed.  Nihil artisan semiotics williamsburg nulla.`}</p>
            <div className={`control-group`}>
                <label>{`Username`}</label>
                <input type={`text`} placeholder={`john.doe@example.com`} />
            </div>
            <div className={`control-group`}>
                <label>{`Password`}</label>
                <input type={`password`} />
            </div>
        </Dialog>
    )
}

Props

Note: React-Win-Dialog has full TypeScript definitions! You should automatically receive intellisense for all of the props documented below:

NameTypeRequiredDescription
titlestringtrueThe dialog's title.
openbooleantrueWhether the dialog is open or not.
childrenelementtrueThe dialog's content body.
dangerbooleanfalseChange's the dialog's outline and primary button color to red when true.
primaryTextstringfalseThe dialog's primary (right) button text.
secondaryTextstringfalseThe dialog's secondary (left) button text.
onPrimaryClickfunctionfalseEvent handler called when the primary (right) button is clicked.
onSecondaryClickfunctionfalseEvent handler called when the secondary (left) button is clicked.
loadingbooleanfalseIndicates that data is being loaded or saved. Default false.
loadingComponentReact.ReactNodefalseA custom component to use as the loading indicator when loading is true. Defaults to a <progress /> element.
loadingHidesButtonsbooleanfalseWhether the dialog should hide its primary and secondary buttons when loading is true. Defaults to true.
overlayStyleobjectfalseCSS style object applied to the overlay container.
containerStyleobjectfalseCSS style object applied to the dialog container.
dialogStyleobjectfalseCSS style object applied to the dialog.
idstringfalseElement id applied to the dialog container.
classNamestringfalseCSS classnames applied to the dialog container.

Styling

If you'd like to style the modal buttons yourself, just use the following CSS rules:

.react-win-dialog-overlay {
    /* This styles the semi-transparent background overlay.
     * Note that the dialog itself is *not* a child of this element.
     */
}

.react-win-dialog-container .react-win-dialog .btn.react-win-dialog-secondary-command {
    /* This styles the secondary (left) button. */
}

.react-win-dialog-container .react-win-dialog .btn.primary.react-win-dialog-primary-command {
    /* This styles the primary (primary) button. */
}

.react-win-dialog-container .react-win-dialog.danger {
    /* This styles the dialog when `danger=true` is passed to the component. */
}

.react-win-dialog-container .react-win-dialog.danger .btn.danger.react-win-dialog-primary-command {
    /* This styles the primary (right) button when `danger=true` is passed to the component. */
}

.react-win-dialog-container .react-win-dialog .react-win-dialog-content .react-win-dialog-loading-container {
    /* This styles the loading indicator container when `loading=true` is passed to the component. */
}

.react-win-dialog-container .react-win-dialog .react-win-dialog-content .react-win-dialog-loading-container progress.react-win-dialog-loading-bar {
    /* This styles the default progress bar used as the loading indicator when `loading=true` is passed to the component without a custom loading indicator component. */
}
1.7.0

2 years ago

1.6.0

2 years ago

1.5.0

2 years ago

1.4.0

6 years ago

1.3.0

7 years ago

1.2.0

7 years ago

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