Files
habitica/website/client/components/snackbars/notification.vue
Keith Holliday 39d7581c6c Merge Develop onto Release (#9123)
* Some random quick (#9111)

* Switch group button directions

* Allowed admins to export challenges

* Added scoping to some stable styles

* Fixed challenge cloning

* Tasks tags (#9112)

* Added auto apply and exit

* Add challenge tag editing

* Fixed lint

* Skill fixes (#9113)

* Added local storage setting for spell drawer

* Added new spell styles

* Fixed typo

* Reset local creds if access is denied (#9114)

* various fixes: group leader's name at top of edit drop-down; Members List; etc (#9117)

* fix text describing location of subscription/gem gift box

* disable Copy As To-Do in Tavern, guilds, party because it's not working

* change members label on group pages to Member List

* remove outdated info about seeing number of Gems available to buy

* allow Danger Zone to be seen by players without local authentication

Also add an hr because the Danger Zone heading was crammed up against the button above it.

* put current group leader's name at top of Leader change drop-down

* Client Fixes (#9120)

* unduplicate logout code

* re-enable debug menu

* fix pets badge and equipping mounts

* close gift modal after sending gems

* armoire notifications

* Oct 1 fixes (#9121)

* Added default tags to task

* Added seasonal gear check and show spooky

* Disabled spooky sparkles

* Fixed challenge remove tasks modal

* Hid checklist

* Added group gems modal

* Purchase with amazon

* Added check for user health

* Added missing notification file
2017-10-01 20:42:02 -05:00

162 lines
4.0 KiB
Vue

<template lang="pug">
transition(name="fade")
.notification.callout.animated(:class="classes", v-if='show', @click='show = false')
.row(v-if='notification.type === "error"')
.text.col-12
div(v-html='notification.text')
.row(v-if='["hp", "gp", "xp", "mp"].indexOf(notification.type) !== -1')
.text.col-7.offset-1
div
| {{message}}
.icon.col-4
div.svg-icon(v-html="icons.health", v-if='notification.type === "hp"')
div.svg-icon(v-html="icons.gold", v-if='notification.type === "gp"')
div.svg-icon(v-html="icons.star", v-if='notification.type === "xp"')
div.svg-icon(v-html="icons.mana", v-if='notification.type === "mp"')
div(v-html='notification.text')
.row(v-if='["info", "success", "crit", "lvl"].indexOf(notification.type) !== -1')
.text.col-12
div(v-html='notification.text')
.row(v-if='notification.type === "drop"')
.col-2
.icon-item
div(:class='notification.icon')
.text.col-9
div(v-html='notification.text')
</template>
<style lang="scss" scoped>
.notification {
border-radius: 1000px;
background-color: #24cc8f;
box-shadow: 0 2px 2px 0 rgba(26, 24, 29, 0.16), 0 1px 4px 0 rgba(26, 24, 29, 0.12);
color: white;
width: 300px;
margin-left: 1em;
margin-bottom: 1em;
}
.info {
max-height: 56px;
background-color: #46a7d9;
padding-top: .5em;
}
.error {
background-color: #f74e52;
color: #fff;
}
.negative {
background-color: #f74e52;
}
.text {
text-align: center;
padding: .5em;
}
.svg-icon {
width: 20px;
margin-right: .5em;
}
.hp .icon {
color: #f74e52;
}
.mp .icon {
color: #2995cd;
}
.icon {
background: #fff;
color: #ffa623;
border-radius: 0 1000px 1000px 0;
padding: .5em;
div {
display: inline-block;
vertical-align: bottom;
}
}
.drop {
background-color: #4e4a57;
}
.icon-item {
width: 64px;
height: 64px;
background-color: #ffffff;
box-shadow: 0 2px 2px 0 rgba(26, 24, 29, 0.16), 0 1px 4px 0 rgba(26, 24, 29, 0.12);
border-radius: 50%;
}
.fade-enter-active, .fade-leave-active {
transition: opacity .5s
}
.fade-enter, .fade-leave-to /* .fade-leave-active below version 2.1.8 */ {
opacity: 0
}
</style>
<script>
import health from 'assets/svg/health.svg';
import gold from 'assets/svg/gold.svg';
import star from 'assets/svg/star.svg';
import mana from 'assets/svg/mana.svg';
export default {
props: ['notification'],
data () {
return {
timer: null,
icons: Object.freeze({
health,
gold,
star,
mana,
}),
show: true,
};
},
created () {
// @TODO the notifications always close even if timeout is false
let timeout = this.notification.hasOwnProperty('timeout') ? this.notification.timeout : true;
if (timeout) {
let delay = this.notification.delay || 1000;
delay += this.$store.state.notificationStore.length * 1000;
setTimeout(() => {
this.show = false;
}, delay);
}
},
watch: {
show () {
setTimeout(() => {
this.$store.state.notificationStore.splice(0, 1);
}, 1000);
},
},
computed: {
message () {
let localeKey = this.negative === 'negative' ? 'lost' : 'gained';
if (this.notification.type === 'hp') localeKey += 'Health';
if (this.notification.type === 'mp') localeKey += 'Mana';
if (this.notification.type === 'xp') localeKey += 'Experience';
if (this.notification.type === 'gp') localeKey += 'Gold';
return this.$t(localeKey);
// This requires eight translatable strings, but that gives the translators the most flexibility for matching gender/number and for using idioms for lost/spent/used/gained.
},
negative () {
return this.notification.sign === '-' ? 'negative' : 'positive';
},
classes () {
return `${this.notification.type} ${this.negative}`;
},
},
};
</script>