Skip to content

Commit

Permalink
docs: ✏️ Installation & usage
Browse files Browse the repository at this point in the history
  • Loading branch information
vctrtvfrrr committed Mar 3, 2021
1 parent f9a3c95 commit 990c3f8
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
56 changes: 56 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,62 @@

> Lightweight toast-notification plugin for Vue 3
## Installation

```bash
npm install @meforma/vue-toaster
```

## Usage

Import in your main.js

```js
import Toaster from "@incuca/vue3-toaster";

createApp(App)
.use(Toaster)
.mount("#app");
```

Usage in your components with Options API

```js
this.$toast.show(message, { ...options });
this.$toast.success(`Hey! I'm here`);
this.$toast.error(`Hey! I'm here`);
this.$toast.warning(`Hey! I'm here`);
this.$toast.info(`Hey! I'm here`);
// Close all opened toasts after 3000ms
setTimeout(this.$toast.clear, 3000);
```

Usage with Composition API

```js
import { inject } from "vue";
const toast = inject("toast");
toast.show(message, { ...options });
```

## Available options

The API methods accepts these options:

| Attribute | Type | Default | Description |
| :------------ | :--------------: | :------------: | :---------------------------------------------------------------------------- |
| message | String | -- | Message text/html (required) |
| type | String | `default` | `success`, `info`, `warning`, `error` or `default` |
| position | String | `bottom-right` | `top`, `bottom`, `top-right`, `bottom-right`,`top-left` or `bottom-left` |
| duration | Number/Boolean | `4000` | Visibility duration in milliseconds or `false` that disables duration |
| dismissible | Boolean | `true` | Allow user close by clicking |
| onClick | Function | -- | Do something when user clicks |
| onClose | Function | -- | Do something after toast gets dismissed |
| queue | Boolean | `false` | Wait for existing to close before showing new |
| maxToasts | Number/Boolean | `false` | Defines the max of toasts showed in simultaneous |
| pauseOnHover | Boolean | `true` | Pause the timer when mouse hover a toast |
| useDefaultCss | Boolean | `true` | Use default css styles |

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@incuca/vue-toaster",
"name": "@incuca/vue3-toaster",
"version": "1.0.0",
"description": "Lightweight toast-notification plugin for Vue 3",
"license": "MIT",
Expand Down

0 comments on commit 990c3f8

Please sign in to comment.