Skip to content

Instantly share code, notes, and snippets.

@TheDutchCoder
Created January 18, 2017 16:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TheDutchCoder/c46a1f5c4926a4def91e0ca49df0fdef to your computer and use it in GitHub Desktop.
Save TheDutchCoder/c46a1f5c4926a4def91e0ca49df0fdef to your computer and use it in GitHub Desktop.
<template>
<div class="notifications">
<notification-item v-for="item in notificationsItems" v-if="$index === 0" :item="item" :index="$index"></notification-item>
</div>
</template>
<script>
// Imports.
import notificationItem from './notificationItem'
// Getters.
import {
notificationsItems,
notificationsHasItems
} from '../../vuex/getters'
// Component export.
export default {
/**
* Vuex actions & getters.
*
* @type {Object}
*/
vuex: {
getters: {
notificationsItems,
notificationsHasItems
}
},
/**
* Used child components.
*
* @type {Object}
*/
components: {
notificationItem
},
/**
* The initial component data.
*
* @return {Object} The component's data.
*/
data() {
return {}
},
/**
* Computed properties.
*
* @type {Object}
*/
computed: {
/**
* Generates a list of classes to use on the component.
*
* @return {Object} A map of classes to use.
*/
classList() {
return {
'notification--good': this.item.type === 'good',
'notification--bad': this.item.type === 'bad',
'notification--warn': this.item.type === 'warn'
}
}
},
/**
* Component methods.
*
* @type {Object}
*/
methods: {
/**
* Removes a notification.
*
* @param {Number} index The index of the notification to remove.
*/
remove(index) {
this.notificationsRemove(index)
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment