Created
January 18, 2017 16:50
-
-
Save TheDutchCoder/c46a1f5c4926a4def91e0ca49df0fdef to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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