An open API service indexing awesome lists of open source software.

https://github.com/sebastiansulinski/vue-notification

Component for displaying notifications with help of also included Vuex module.
https://github.com/sebastiansulinski/vue-notification

vue-composition-api vue-notification vuejs vuejs3 vuex

Last synced: 4 months ago
JSON representation

Component for displaying notifications with help of also included Vuex module.

Awesome Lists containing this project

README

        

# Vue Notification

Component for displaying notifications with help of also included Vuex module.

> Please note that this component uses Vue 3 composition api

## Installation

```bash
npm install -D @ssdcode/vue-notification
```

## Usage

First register the module with your vuex store - there are 2 options:

**notification**: displays only a single notification at any given time replacing previous with the new one

```javascript
import Vue from 'vue';
import Vuex from 'vuex';
import { notification } from '@ssdcode/vue-notification';

Vue.use(Vuex);

export default new Vuex.Store({
modules: { notification },
});
```

**notifications**: displays multiple notifications as they are dispatched

```javascript
import Vue from 'vue';
import Vuex from 'vuex';
import { notifications } from '@ssdcode/vue-notification';

Vue.use(Vuex);

export default new Vuex.Store({
modules: { notification: notifications },
});
```

Register `NotificationContainer` component and add it to your application's html structure.

```javascript
import { NotificationContainer } from '@ssdcode/vue-notification';

new Vue({
store,
components: { NotificationContainer },
render: h => h(App),
}).$mount('#app');
```

Example layout using [tailwindcss](https://tailwindcss.com/):

```html
















```

You can now call it from anywhere using:

```vue

SHOW NOTIFICATION

import { mapActions } from 'vuex';

export default {
name: 'DemoComponent',
setup() {
const { add } = mapActions('notification', ['add']);

return { add };
},
};

```

## Tests

You can execute tests by calling

```bash
npm run test:unit
```

## Contributions

Contributions are welcome - please make sure all PRs have their associated test.