Archived
2
0
This repository has been archived on 2024-06-24. You can view files and clone it, but cannot push or open issues or pull requests.
neko-custom/client/src/components/emotes.vue

176 lines
3.5 KiB
Vue
Raw Normal View History

2020-01-23 06:16:40 +13:00
<template>
2020-01-24 04:23:26 +13:00
<div class="emotes">
<ul v-if="!muted">
2020-02-12 07:10:24 +13:00
<li v-for="emote in recent" :key="emote">
<div @click.stop.prevent="sendEmote(emote)" :class="['emote', emote]" />
</li>
<li>
<i @click.stop.prevent="open" class="fas fa-grin-beam"></i>
</li>
2020-01-23 06:16:40 +13:00
</ul>
2020-02-12 07:10:24 +13:00
<vue-context class="context" ref="context">
<li v-for="emote in emotes" :key="emote">
<div @click="sendEmote(emote)" :class="['emote', emote]" />
</li>
</vue-context>
2020-01-23 06:16:40 +13:00
</div>
</template>
<style lang="scss" scoped>
2020-01-24 04:23:26 +13:00
.emotes {
2020-01-23 06:16:40 +13:00
ul {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
li {
font-size: 24px;
margin: 0 5px;
2020-02-12 07:10:24 +13:00
i,
2020-01-24 05:54:32 +13:00
div {
2020-01-23 06:16:40 +13:00
cursor: pointer;
2020-02-12 07:10:24 +13:00
}
}
}
2020-01-24 05:54:32 +13:00
2020-02-12 07:10:24 +13:00
.context {
background-color: $background-floating;
background-clip: padding-box;
border-radius: 0.25rem;
display: flex;
margin: 0;
padding: 5px;
width: 220px;
z-index: 1500;
position: fixed;
list-style: none;
box-sizing: border-box;
max-height: calc(100% - 50px);
color: $interactive-normal;
flex-wrap: wrap;
user-select: none;
box-shadow: $elevation-high;
2020-01-24 05:54:32 +13:00
2020-02-12 07:10:24 +13:00
> li {
margin: 0;
position: relative;
align-content: center;
padding: 5px;
border-radius: 3px;
2020-01-24 05:54:32 +13:00
2020-02-12 07:10:24 +13:00
.emote {
width: 24px;
height: 24px;
}
2020-01-24 05:54:32 +13:00
2020-02-12 07:10:24 +13:00
&:hover,
&:focus {
text-decoration: none;
background-color: $background-modifier-hover;
color: $interactive-hover;
}
2020-01-24 05:54:32 +13:00
2020-02-12 07:10:24 +13:00
&:focus {
outline: 0;
2020-01-23 06:16:40 +13:00
}
}
2020-02-12 07:10:24 +13:00
&:focus {
outline: 0;
}
2020-01-23 06:16:40 +13:00
}
}
</style>
<script lang="ts">
2020-02-12 07:10:24 +13:00
import { Vue, Ref, Component } from 'vue-property-decorator'
import { get, set } from '../utils/localstorage'
// @ts-ignore
import { VueContext } from 'vue-context'
2020-01-23 06:16:40 +13:00
@Component({
2020-01-24 04:23:26 +13:00
name: 'neko-emotes',
2020-02-12 07:10:24 +13:00
components: {
'vue-context': VueContext,
},
2020-01-23 06:16:40 +13:00
})
export default class extends Vue {
2020-02-12 07:10:24 +13:00
@Ref('context') readonly context!: any
recent: string[] = JSON.parse(get('emote_recent', '[]'))
get emotes() {
return [
'anger',
'bomb',
'sleep',
'explode',
'sweat',
'poo',
'hundred',
'alert',
'punch',
'wave',
'okay',
'thumbs-up',
'clap',
'prey',
'celebrate',
'flame',
'goof',
'love',
'cool',
'smerk',
'worry',
'ouch',
'cry',
'surprised',
'quiet',
'rage',
'annoy',
'steamed',
'scared',
'terrified',
'sleepy',
'dead',
'happy',
'roll-eyes',
'thinking',
'clown',
'sick',
'rofl',
'drule',
'sniff',
'sus',
'party',
'odd',
'hot',
'cold',
'blush',
'sad',
].filter(v => !this.recent.includes(v))
}
2020-01-24 04:23:26 +13:00
get muted() {
return this.$accessor.user.muted
}
2020-02-12 07:10:24 +13:00
open(event: MouseEvent) {
this.context.open(event)
}
sendEmote(emote: string) {
if (!this.recent.includes(emote)) {
if (this.recent.length > 4) {
this.recent.shift()
}
this.recent.push(emote)
set('emote_recent', JSON.stringify(this.recent))
}
2020-01-24 04:23:26 +13:00
this.$accessor.chat.sendEmote(emote)
2020-01-23 06:16:40 +13:00
}
}
</script>