Skip to content

Commit

Permalink
Merge pull request #45 from UnicornGlobal/dev
Browse files Browse the repository at this point in the history
v1.1.0
  • Loading branch information
darrynten authored Dec 18, 2018
2 parents bb5adf3 + bdbefe6 commit 113dc23
Show file tree
Hide file tree
Showing 22 changed files with 12,893 additions and 1 deletion.
30 changes: 30 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"env": {
"development": {
"presets": [
[
"@babel/preset-env",
{
"modules": false
}
]
]
},
"test": {
"presets": [
[
"@babel/preset-env",
{
"modules": false,
"targets": {
"node": "current"
}
}
]
],
"plugins": [
"istanbul"
]
}
}
}
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/build/
/config/
/dist/
/*.js
/test/unit/coverage/
34 changes: 34 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// https://eslint.org/docs/user-guide/configuring

module.exports = {
root: true,
parser: 'babel-eslint',
parserOptions: {
sourceType: 'module'
},
env: {
browser: true,
},
// https://github.com/standard/standard/blob/master/docs/RULES-en.md
extends: 'standard',
// required to lint *.vue files
plugins: [
'html'
],
'settings': {
'html/html-extensions': ['.html', '.vue']
},
// add your custom rules here
'rules': {
'no-trailing-spaces': 1,
'space-before-function-paren': 1,
'space-before-blocks': 1,
'keyword-spacing': 1,
// allow paren-less arrow functions
'arrow-parens': 0,
// allow async-await
'generator-star-spacing': 0,
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
}
}
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.DS_Store
node_modules/
dist/
npm-debug.log
yarn-error.log
.tmp
.nyc_output
coverage

# Editor directories and files
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw[po]
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
dist: trusty
language: node_js
node_js:
- 9
before_install:
- npm install
- npm test
after_success:
- codecov coverage/lcov.info -t ${CODECOV_TOKEN}
- echo 'Done!'
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 Unicorn Global et al

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.
110 changes: 109 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,110 @@
# vue-toaster
Toaster that makes Toast

[![Build Status](https://travis-ci.com/darrynten/vue-toaster.svg?token=2azvxgpyzAkLb1UEKNft&branch=dev)](https://travis-ci.com/darrynten/vue-toaster)
[![codecov](https://codecov.io/gh/darrynten/vue-toaster/branch/dev/graph/badge.svg?token=gkxihPWHlk)](https://codecov.io/gh/darrynten/vue-toaster)

> A toaster that makes toast
## Installation

```
npm install --save vue-toaster
```

## Setup

In your `main.js` file,

```
import { ToasterEvents } from 'vue-toaster'
```

Add the toaster events to your vue instance as shown below:

```
Vue.prototype.$toaster = ToasterEvents
```
## Usage

Import the `Toaster` component in your App.vue and configure it using the example below

`App.vue`

```
<template>
<div id="app">
<toaster></toaster>
<div><img src="./assets/logo.png"></div>
<HelloWorld/>
</div>
</template>
<script>
import HelloWorld from './components/HelloWorld'
import { Toaster } from 'vue-toaster
export default {
name: 'App',
components: {
Toaster,
HelloWorld
}
}
</script>
```

### Basic

The Toaster can be called anywhere in your app by doing `this.$toaster.addToast(options)`.
Here is an example.

`Test.vue`

```
<script>
export default {
name: 'Test',
methods: {
submit() {
if (!this.name) {
this.$toaster.addToast({
type: 'error',
title: 'Invalid Name',
message: 'Please add a name'
})
return
}
...
}
}
}
</script>
```

This will display an error toast with the message to the user.

### Advanced

You can configure the timeout of the toast by adding a `timeOut` property
E.g.

```
this.$toaster.addToast({
type: 'info',
title: 'Secret Key',
message: 'Please configure your secret key in the security section of the dashboard.',
timeOut: 5000
})
```

## Details

It displays a toast depending on the type specified in the toast options. It makes use of an `EventEmitter` behind the scene and it emits an event whenever the `addToast` method is called. The toast is then added to an array of toasts; gets displayed on the screen and removed from the araay after the timeout. The default `timeOut` of a toast is `3500` (3.5s) and it can be configure to be higher or lower.

# Roadmap

- [ ] - Enable users to configure toast colors

# Contributors

[Bamidele Daniel](https://github.com/humanityjs)
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Toaster from './src/Toaster.vue'
import ToasterEvents from './src/ToasterEvents.js'
export {
Toaster,
ToasterEvents
}
Loading

0 comments on commit 113dc23

Please sign in to comment.