https://github.com/jrop/react-toolbox-dialogs
https://github.com/jrop/react-toolbox-dialogs
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/jrop/react-toolbox-dialogs
- Owner: jrop
- Created: 2016-09-30T21:48:29.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2017-09-01T17:30:11.000Z (almost 9 years ago)
- Last Synced: 2023-12-25T16:28:34.360Z (over 2 years ago)
- Language: JavaScript
- Size: 2.51 MB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# React-Toolbox Dialogs
A Promise-API for common dialogs (alert/confirm/prompt)

# Installation
```sh
npm install --save-dev react-toolbox-dialogs
```
# Usage
```js
import 'normalize.css'
import 'react-toolbox/lib/commons.scss'
import 'babel-polyfill'
import React from 'react'
import ReactDOM from 'react-dom'
import AppBar from 'react-toolbox/lib/app_bar'
import { Button } from 'react-toolbox/lib/button'
import * as dialogs from 'react-toolbox-dialogs'
class App extends React.Component {
constructor(props) {
super(props)
this.state = { result: null }
}
async onAlert() {
await dialogs.alert('My Alert', 'My message.')
this.setState({ result: 'Alert closed' })
}
async onConfirm() {
const result = await dialogs.confirm('My Confirm', 'Are you sure?')
this.setState({ result: result ? 'Confirmed' : 'Canceled' })
}
async onPrompt() {
const result = await dialogs.prompt('My Prompt', 'Enter a string:', 'default')
this.setState({ result: result ? `"${result}"` : 'Canceled' })
}
render() {
return
{this.state.result &&
Result: {this.state.result}}
}
}
window.addEventListener('load', function () {
ReactDOM.render(, document.getElementById('react'))
})
```
# License (ISC)
Copyright (c) 2016, Company or Person's Name
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.