neko/client/src/app.vue

240 lines
5.6 KiB
Vue
Raw Normal View History

2020-01-23 06:16:40 +13:00
<template>
2023-03-25 03:24:20 +13:00
<div id="neko" :class="[!videoOnly && side ? 'expanded' : '']">
2020-01-29 14:27:35 +13:00
<template v-if="!$client.supported">
<neko-unsupported />
</template>
<template v-else>
<main class="neko-main">
2023-03-25 03:24:20 +13:00
<div v-if="!videoOnly" class="header-container">
2020-01-29 14:27:35 +13:00
<neko-header />
</div>
<div class="video-container">
2023-03-26 09:53:17 +13:00
<neko-video
ref="video"
:hideControls="hideControls"
:extraControls="isEmbedMode"
@control-attempt="controlAttempt"
/>
2020-01-29 14:27:35 +13:00
</div>
2023-03-25 03:24:20 +13:00
<div v-if="!videoOnly" class="room-container">
2020-01-29 14:27:35 +13:00
<neko-members />
<div class="room-menu">
<div class="settings">
<neko-menu />
</div>
<div class="controls">
2021-04-05 02:57:23 +12:00
<neko-controls :shakeKbd="shakeKbd" />
2020-01-29 14:27:35 +13:00
</div>
<div class="emotes">
<neko-emotes />
</div>
2020-01-23 06:16:40 +13:00
</div>
</div>
2020-01-29 14:27:35 +13:00
</main>
2023-03-25 03:24:20 +13:00
<neko-side v-if="!videoOnly && side" />
2020-01-29 14:27:35 +13:00
<neko-connect v-if="!connected" />
<neko-about v-if="about" />
2021-04-04 08:25:11 +12:00
<notifications
2023-03-25 03:24:20 +13:00
v-if="!videoOnly"
2021-04-04 08:25:11 +12:00
group="neko"
position="top left"
style="top: 50px; pointer-events: none"
:ignoreDuplicates="true"
/>
2020-01-29 14:27:35 +13:00
</template>
2020-01-23 06:16:40 +13:00
</div>
</template>
<style lang="scss">
#neko {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
2020-01-31 12:57:00 +13:00
max-width: 100vw;
max-height: 100vh;
2020-01-23 06:16:40 +13:00
flex-direction: row;
display: flex;
.neko-main {
2020-01-31 12:57:00 +13:00
min-width: 360px;
2020-01-23 06:16:40 +13:00
max-width: 100%;
flex-grow: 1;
flex-direction: column;
display: flex;
overflow: auto;
.header-container {
background: $background-tertiary;
height: $menu-height;
flex-shrink: 0;
display: flex;
}
.video-container {
background: rgba($color: #000, $alpha: 0.4);
max-width: 100%;
flex-grow: 1;
display: flex;
}
.room-container {
background: $background-tertiary;
height: $controls-height;
max-width: 100%;
flex-shrink: 0;
flex-direction: column;
display: flex;
.room-menu {
max-width: 100%;
flex: 1;
display: flex;
.settings {
margin-left: 10px;
flex: 1;
justify-content: flex-start;
align-items: center;
display: flex;
}
.controls {
flex: 1;
justify-content: center;
align-items: center;
display: flex;
}
2020-01-24 04:23:26 +13:00
.emotes {
2020-01-23 06:16:40 +13:00
margin-right: 10px;
flex: 1;
justify-content: flex-end;
align-items: center;
display: flex;
}
}
}
}
}
2020-01-31 12:57:00 +13:00
@media only screen and (max-width: 600px) {
2021-02-14 01:01:51 +13:00
#neko.expanded {
.neko-main {
transform: translateX(calc(-100% + 65px));
video {
display: none;
2020-01-31 12:57:00 +13:00
}
}
2021-02-14 01:01:51 +13:00
.neko-menu {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 65px;
width: calc(100% - 65px);
}
2020-01-31 12:57:00 +13:00
}
}
@media only screen and (max-width: 768px) {
2021-02-14 01:01:51 +13:00
#neko .neko-main .room-container {
display: none;
2020-01-31 12:57:00 +13:00
}
}
2020-01-23 06:16:40 +13:00
</style>
<script lang="ts">
2021-04-04 08:25:11 +12:00
import { Vue, Component, Ref, Watch } from 'vue-property-decorator'
2020-01-23 06:16:40 +13:00
import Connect from '~/components/connect.vue'
import Video from '~/components/video.vue'
import Menu from '~/components/menu.vue'
import Side from '~/components/side.vue'
import Controls from '~/components/controls.vue'
import Members from '~/components/members.vue'
2020-01-24 04:23:26 +13:00
import Emotes from '~/components/emotes.vue'
2020-01-23 06:16:40 +13:00
import About from '~/components/about.vue'
2020-01-24 04:23:26 +13:00
import Header from '~/components/header.vue'
2020-01-29 14:27:35 +13:00
import Unsupported from '~/components/unsupported.vue'
2020-01-23 06:16:40 +13:00
@Component({
name: 'neko',
components: {
'neko-connect': Connect,
'neko-video': Video,
'neko-menu': Menu,
'neko-side': Side,
'neko-controls': Controls,
'neko-members': Members,
2020-01-24 04:23:26 +13:00
'neko-emotes': Emotes,
2020-01-23 06:16:40 +13:00
'neko-about': About,
2020-01-24 04:23:26 +13:00
'neko-header': Header,
2020-01-29 14:27:35 +13:00
'neko-unsupported': Unsupported,
2020-01-23 06:16:40 +13:00
},
})
export default class extends Vue {
@Ref('video') video!: Video
2021-04-05 02:57:23 +12:00
shakeKbd = false
2023-03-27 23:53:39 +13:00
get volume() {
const numberParam = parseFloat(new URL(location.href).searchParams.get('volume') || '1.0')
return Math.max(0.0, Math.min(!isNaN(numberParam) ? numberParam * 100 : 100, 100))
}
2023-03-25 03:24:20 +13:00
get isCastMode() {
2021-04-04 08:25:11 +12:00
return !!new URL(location.href).searchParams.get('cast')
}
2023-03-25 03:24:20 +13:00
get isEmbedMode() {
return !!new URL(location.href).searchParams.get('embed')
}
get hideControls() {
return this.isCastMode
}
get videoOnly() {
return this.isCastMode || this.isEmbedMode
}
2023-03-27 23:53:39 +13:00
@Watch('volume', { immediate: true })
onVolume(volume: number) {
if (new URL(location.href).searchParams.has('volume')) {
this.$accessor.video.setVolume(volume)
}
2023-03-27 23:53:39 +13:00
}
2021-04-04 08:25:11 +12:00
@Watch('hideControls', { immediate: true })
2022-01-18 08:02:01 +13:00
onHideControls(enabled: boolean) {
if (enabled) {
this.$accessor.video.setMuted(false)
this.$accessor.settings.setSound(false)
}
2021-04-04 08:25:11 +12:00
}
2021-04-05 02:57:23 +12:00
controlAttempt() {
if (this.shakeKbd || this.$accessor.remote.hosted) return
2021-04-05 02:57:23 +12:00
this.shakeKbd = true
2021-07-17 21:30:46 +12:00
window.setTimeout(() => (this.shakeKbd = false), 5000)
2021-04-05 02:57:23 +12:00
}
2020-01-23 06:16:40 +13:00
get about() {
return this.$accessor.client.about
}
get side() {
return this.$accessor.client.side
}
get connected() {
return this.$accessor.connected
}
}
</script>