yumechi-no-kuni/src/client/app/desktop/views/components/ui.header.notifications.vue

137 lines
2.6 KiB
Vue
Raw Normal View History

2018-02-12 06:10:16 -06:00
<template>
2018-02-20 07:53:34 -06:00
<div class="notifications">
2018-04-14 11:04:40 -05:00
<button :data-active="isOpen" @click="toggle" title="%i18n:@title%">
2018-05-28 11:22:39 -05:00
%fa:R bell%<template v-if="hasUnreadNotification">%fa:circle%</template>
2018-02-12 06:10:16 -06:00
</button>
2018-02-20 07:53:34 -06:00
<div class="pop" v-if="isOpen">
2018-02-12 06:10:16 -06:00
<mk-notifications/>
</div>
</div>
</template>
<script lang="ts">
import Vue from 'vue';
import contains from '../../../common/scripts/contains';
export default Vue.extend({
data() {
return {
2018-05-28 11:22:39 -05:00
isOpen: false
2018-02-12 06:10:16 -06:00
};
},
2018-05-28 11:22:39 -05:00
computed: {
hasUnreadNotification(): boolean {
return this.$store.getters.isSignedIn && this.$store.state.i.hasUnreadNotification;
2018-02-12 06:10:16 -06:00
}
},
methods: {
toggle() {
this.isOpen ? this.close() : this.open();
},
open() {
this.isOpen = true;
Array.from(document.querySelectorAll('body *')).forEach(el => {
el.addEventListener('mousedown', this.onMousedown);
});
},
close() {
this.isOpen = false;
Array.from(document.querySelectorAll('body *')).forEach(el => {
el.removeEventListener('mousedown', this.onMousedown);
});
},
onMousedown(e) {
e.preventDefault();
if (!contains(this.$el, e.target) && this.$el != e.target) this.close();
return false;
}
}
});
</script>
<style lang="stylus" scoped>
2018-03-02 22:47:55 -06:00
@import '~const.styl'
2018-04-19 17:45:37 -05:00
root(isDark)
2018-02-12 06:10:16 -06:00
> button
display block
margin 0
padding 0
width 32px
color #9eaba8
border none
background transparent
cursor pointer
*
pointer-events none
&:hover
&[data-active='true']
2018-04-19 17:45:37 -05:00
color isDark ? #fff : darken(#9eaba8, 20%)
2018-02-12 06:10:16 -06:00
&:active
2018-04-19 17:45:37 -05:00
color isDark ? #fff : darken(#9eaba8, 30%)
2018-02-12 06:10:16 -06:00
> [data-fa].bell
font-size 1.2em
line-height 48px
> [data-fa].circle
margin-left -5px
vertical-align super
font-size 10px
color $theme-color
2018-02-20 07:53:34 -06:00
> .pop
2018-04-19 17:45:37 -05:00
$bgcolor = isDark ? #282c37 : #fff
2018-02-12 06:10:16 -06:00
display block
position absolute
top 56px
right -72px
width 300px
2018-04-19 17:45:37 -05:00
background $bgcolor
2018-02-12 06:10:16 -06:00
border-radius 4px
2018-04-28 18:51:17 -05:00
box-shadow 0 1px 4px rgba(#000, 0.25)
2018-02-12 06:10:16 -06:00
&:before
content ""
pointer-events none
display block
position absolute
top -28px
right 74px
border-top solid 14px transparent
border-right solid 14px transparent
2018-04-28 18:51:17 -05:00
border-bottom solid 14px rgba(#000, 0.1)
2018-02-12 06:10:16 -06:00
border-left solid 14px transparent
&:after
content ""
pointer-events none
display block
position absolute
top -27px
right 74px
border-top solid 14px transparent
border-right solid 14px transparent
2018-04-19 17:45:37 -05:00
border-bottom solid 14px $bgcolor
2018-02-12 06:10:16 -06:00
border-left solid 14px transparent
2018-02-16 12:01:00 -06:00
> .mk-notifications
2018-02-12 06:10:16 -06:00
max-height 350px
font-size 1rem
overflow auto
2018-04-19 17:45:37 -05:00
.notifications[data-darkmode]
root(true)
.notifications:not([data-darkmode])
root(false)
2018-02-12 06:10:16 -06:00
</style>