thelounge/client/components/ChannelWrapper.vue

57 lines
1.2 KiB
Vue
Raw Normal View History

<template>
<div
2019-07-17 09:33:59 +00:00
v-if="
!network.isCollapsed ||
channel.highlight ||
channel.type === 'lobby' ||
(activeChannel && channel === activeChannel.channel)
"
2019-02-07 07:24:53 +00:00
:class="[
2019-03-19 13:11:44 +00:00
'chan',
2019-02-07 07:24:53 +00:00
channel.type,
2019-07-17 09:33:59 +00:00
{active: activeChannel && channel === activeChannel.channel},
{'parted-channel': channel.type === 'channel' && channel.state === 0},
2019-02-07 07:24:53 +00:00
]"
:aria-label="getAriaLabel()"
:title="getAriaLabel()"
:data-id="channel.id"
:data-target="'#chan-' + channel.id"
2019-01-02 12:09:50 +00:00
:data-name="channel.name"
:aria-controls="'#chan-' + channel.id"
:aria-selected="activeChannel && channel === activeChannel.channel"
role="tab"
>
2019-07-17 09:33:59 +00:00
<slot :network="network" :channel="channel" :activeChannel="activeChannel" />
</div>
</template>
<script>
export default {
name: "ChannelWrapper",
props: {
network: Object,
channel: Object,
activeChannel: Object,
},
methods: {
getAriaLabel() {
const extra = [];
if (this.channel.unread > 0) {
extra.push(`${this.channel.unread} unread`);
}
if (this.channel.highlight > 0) {
extra.push(`${this.channel.highlight} mention`);
}
if (extra.length > 0) {
return `${this.channel.name} (${extra.join(", ")})`;
}
return this.channel.name;
},
},
};
</script>