puzzle/src/frontend/components/ConnectionOverlay.vue
2021-05-17 00:27:47 +02:00

37 lines
955 B
Vue
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div class="overlay connection-lost" v-if="show">
<div class="overlay-content" v-if="lostConnection">
<div> LOST CONNECTION </div>
<span class="btn" @click="$emit('reconnect')">Reconnect</span>
</div>
<div class="overlay-content" v-if="connecting">
<div>Connecting...</div>
</div>
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
import Communication from './../Communication'
export default defineComponent({
name: 'connection-overlay',
emits: {
reconnect: null,
},
props: {
connectionState: Number,
},
computed: {
lostConnection (): boolean {
return this.connectionState === Communication.CONN_STATE_DISCONNECTED
},
connecting (): boolean {
return this.connectionState === Communication.CONN_STATE_CONNECTING
},
show (): boolean {
return !!(this.lostConnection || this.connecting)
},
}
})
</script>