thelounge/client/components/Username.vue

54 lines
1 KiB
Vue
Raw Normal View History

<template>
<span
:class="['user', nickColor, {active: active}]"
:data-name="user.nick"
role="button"
2020-01-27 09:44:36 +00:00
v-on="onHover ? {mouseenter: hover} : {}"
2019-11-23 14:26:20 +00:00
@click.prevent="openContextMenu"
@contextmenu.prevent="openContextMenu"
><slot>{{ mode }}{{ user.nick }}</slot></span
2019-07-17 09:33:59 +00:00
>
</template>
<script>
2020-03-16 17:58:40 +00:00
import eventbus from "../js/eventbus";
2019-11-16 17:24:03 +00:00
import colorClass from "../js/helpers/colorClass";
export default {
name: "Username",
props: {
user: Object,
active: Boolean,
2018-07-10 23:25:21 +00:00
onHover: Function,
2020-04-24 07:20:40 +00:00
channel: Object,
network: Object,
2018-07-10 23:25:21 +00:00
},
computed: {
mode() {
// Message objects have a singular mode, but user objects have modes array
if (this.user.modes) {
return this.user.modes[0];
}
return this.user.mode;
},
nickColor() {
return colorClass(this.user.nick);
},
},
2018-07-10 23:25:21 +00:00
methods: {
hover() {
return this.onHover(this.user);
2018-07-10 23:25:21 +00:00
},
2019-11-23 14:26:20 +00:00
openContextMenu(event) {
2020-03-16 17:58:40 +00:00
eventbus.emit("contextmenu:user", {
2019-11-23 14:26:20 +00:00
event: event,
user: this.user,
2020-04-24 07:20:40 +00:00
network: this.network,
channel: this.channel,
2019-11-23 14:26:20 +00:00
});
2019-11-09 22:21:34 +00:00
},
},
};
</script>