Demo: http://vue-notification.yev.io/
InstallHow tonpm install --save vue-notification
In main.js:
import Vue           from 'vue'
import Notifications from 'vue-notification'
Â
Â
Vue.use(Notifications)
In App.vue:
<notifications group="foo" />
In any of your vue files:
this.$notify({
  group: 'foo',
  title: 'Important message',
  text: 'Hello user! This is a notification!'
});
Anywhere else:
Custom instance configurationimport Vue from 'vue'
Â
Vue.notify({
  group: 'foo',
  title: 'Important message',
  text: 'Hello user! This is a notification!'
})
All configurations are optional.
Name Type Default Description name String notify Defines the instance name. It's prefixed with the dollar sign. E.g.$notify
componentName String notifications The component's name Props
All props are optional.
Name Type Default Description group String null Name of the notification holder, if specified type String null Class that will be assigned to the notification width Number/String 300 Width of notification holder, can be%
, px
string or number.
css
and velocity
animation-name String null Animation name required for css
animation animation Object $
* Animation configuration for Velocity
animation duration Number 3000 Time (ms) animation stays visible (if negative - notification will stay forever or until clicked) speed Number 300 Speed of animation showing/hiding max Number Infinity Maximum number of notifications that can be shown in notification holder reverse Boolean false Show notifications in reverse order ignoreDuplicates Boolean false Ignore repeated instances of the same notification closeOnClick Boolean true Close notification when clicked
$ = {enter: {opacity: [1, 0]}, leave: {opacity: [0, 1]}}
  this.$notify({
   Â
   Â
    group: 'foo',
Â
   Â
   Â
    type: 'warn',
Â
   Â
   Â
    title: 'This is title',
Â
   Â
    text: 'This is <b> content </b>',
Â
   Â
   Â
    duration: 10000,
Â
   Â
   Â
    speed: 1000
Â
   Â
   Â
    data: {}
  })
Title and Text can be HTML strings.
Also you can use simplified version:
GroupsIf you are planning to use notification
component for 2 or more completely different types of notifications (for example, authentication error messages in top center and generic app notifications in bottom-right corner) - you can specify group
property which is essentially a name of notification holder.
Example:
<notifications group="auth"/>
<notifications group="app"/>
Positionthis.$notify({ group: 'auth', text: 'Wrong password, please try again later' })
Position
property requires a string with 2 keywords for vertical and horizontal postion.
Format: "<vertical> <horizontal>"
.
left
, center
, right
top
, bottom
Default is "top right".
Example:
Style<notifications position="top left"/>
You can write your own css styles for notifications:
Structure:
Â
.my-style {
Â
  .notification-title {
  }
Â
  .notification-content {
  }
Â
  &.my-type {
  }
}
To apply this style you will have to specify "classes" property:
  <notifications classes="my-style"/>
Default:
Custom template (slot).vue-notification {
  padding: 10px;
  margin: 0 5px 5px;
Â
  font-size: 12px;
Â
  color: #ffffff;
  background: #44A4FC;
  border-left: 5px solid #187FE7;
Â
  &.warn {
    background: #ffb648;
    border-left-color: #f48a06;
  }
Â
  &.error {
    background: #E54D42;
    border-left-color: #B82E24;
  }
Â
  &.success {
    background: #68CD86;
    border-left-color: #42A85F;
  }
}
Optional scope slot named "body" is supported.
Scope props:
Name Type Description item Object notification object close Function when called closes the notificationExample:
Width<notifications group="custom-template" Â
               position="bottom right">
   <template slot="body" slot-scope="props">
    <div>
        <a class="title">
          {{props.item.title}}
        </a>
        <a class="close" @click="props.close">
          <i class="fa fa-fw fa-close"></i>
        </a>
        <div v-html="props.item.text">
        </div>
    </div>
  </template>
</notifications>
Width can be set using a string with a percent or pixel extension (if simple number is not enough).
Examples: '100%', '50px', '50', 50
Velocity AnimationPlugin can use use Velocity
library to make js-powered animations. To start using it you will have to manually install velocity-animate
& supply the librarty to vue-notification
plugin (reason for doing that is to reduce the size of this plugin).
In your main.js
:
import Vue           from 'vue'
import Notifications from 'vue-notification'
import velocity      from 'velocity-animate'
Â
Vue.use(Notifications, { velocity })
In the template you will have to set animation-type="velocity"
.
<notifications animation-type="velocity"/>
The animation configuration consists of 2 objects/functions: enter
and leave
.
Example:
animation = {
  enter (element) {
    Â
     let height = element.clientHeight
Â
     return {
      Â
       height: [height, 0],
Â
      Â
       opacity: [Math.random() * 0.5 + 0.5, 0]
     } Â
  },
  leave: {
    height: 0,
    opacity: 0
  }
}
Cleaning<notifications
  animation-type="velocity"
  animation="animation"/>
To remove all notifications, use clean: true
parameter.
FAQthis.$notify({
  group: 'foo',
  clean: true
})
Check closed issues with FAQ
label to get answers for most asked questions.
To run an example:
Â
Â
cd vue-notification
npm install
npm run build
Â
Â
cd demo
npm install
npm run dev
Â
npm run test
Â
npm run unit:watch
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4