-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7838f75
commit c6db2a4
Showing
3 changed files
with
197 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Pedro Henrique Pires | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,89 @@ | ||
<div align="center"> | ||
<img src="./docs/logo.svg" width="600" /><br /><br /> | ||
<a href="https://github.com/pedrohenriquepires/react-simple-dialogs/actions/workflows/build.yml" about="_blank"><img alt="Build" src="https://github.com/pedrohenriquepires/react-simple-dialogs/actions/workflows/build.yml/badge.svg"></a> | ||
<img alt="License MIT" src="https://img.shields.io/badge/License-MIT-blue"> | ||
<img alt="NPM Downloads" src="https://img.shields.io/npm/dt/react-simple-dialogs"> | ||
<img alt="NPM Version" src="https://img.shields.io/npm/v/react-simple-dialogs"> | ||
</div> | ||
|
||
# React Simple Dialogs | ||
|
||
> Work In Progress | ||
Beautiful dialogs with a simple usage. No unnecessary settings, native-like usage, **simple**. You can make it work in less than 10 seconds! | ||
|
||
# Instalation | ||
|
||
```bash | ||
# npm | ||
npm install react-simple-dialogs | ||
# yarn | ||
yarn add react-simple-dialogs | ||
# pnpm | ||
pnpm add react-simple-dialogs | ||
``` | ||
|
||
## Container | ||
|
||
In order to correctly render the dialogs, you must place the `SimpleDialogContainer` near to your root component. | ||
|
||
## Example | ||
|
||
```tsx | ||
import React from 'react' | ||
|
||
import { SimpleDialogContainer, simpleAlert } from 'react-simple-dialogs' | ||
|
||
function App() { | ||
const alert = () => simpleAlert('Easy peasy lemon squeezy!') | ||
|
||
return ( | ||
<div> | ||
<button onClick={alert}>Alert!</button> | ||
<SimpleDialogContainer /> | ||
</div> | ||
) | ||
} | ||
``` | ||
|
||
# Simple Usage | ||
|
||
Use the dialogs is almost like use the dialogs native function (`alert`, `confirm` and `prompt`). | ||
|
||
> All dialog function will return an `Promise` that only resolves when the user interacts with the dialog, so you can wait for the user interaction to continue your code execution. | ||
## Alert Dialog | ||
|
||
```tsx | ||
import { simpleAlert } from 'react-simple-dialogs' | ||
|
||
const showAlert = async () => { | ||
await simpleAlert("You can't do this right now.") | ||
|
||
console.log('Alert closed') | ||
} | ||
``` | ||
|
||
## Confirm Dialog | ||
|
||
```tsx | ||
import { simpleConfirm } from 'react-simple-dialogs' | ||
|
||
const showConfirmation = async () => { | ||
if (await simpleConfirm('Please confirm something')) { | ||
console.log('Confirmed! 😄') | ||
} else { | ||
console.log('Not confirmed. 🥲') | ||
} | ||
} | ||
``` | ||
|
||
## Prompt Dialog | ||
|
||
```tsx | ||
import { simplePrompt } from 'react-simple-dialogs' | ||
|
||
const showPrompt = async () => { | ||
const name = await simplePrompt('Please inform your name') | ||
|
||
console.log(`User name is ${name || 'a mistery'}`) | ||
} | ||
``` |
Oops, something went wrong.