knowyt/client/src/components/TopBar.vue
2022-08-06 14:50:20 +02:00

89 lines
2.0 KiB
Vue

<template>
<div v-if="user.name" class="topbar__container">
<div class="topbar__username">
{{ user.name }}
</div>
<div class="topbar__separator" />
<div class="topbar__actionbar">
<div v-if="user.isAdmin" class="topbar__actionbar__admin">
Admin
</div>
<div v-if="user.isGamemaster" class="topbar__actionbar__gamemaster">
Collect Quotes | Start | Continue | Idle | Finish
</div>
<div v-else class="topbar__actionbar__player">
{{ game.name }}
</div>
</div>
<div class="topbar__separator" />
<div class="topbar__logout-button-container">
<Button class="topbar__logout-button" :border="false" @click="actionLogout">Logout</Button>
</div>
</div>
</template>
<script setup lang="ts">
import { useRouter } from '#app'
import useAuth from '@/composables/useAuth';
import { useUserinfoStore } from "@/stores/UserinfoStore"
import { useGameinfoStore } from "@/stores/GameinfoStore"
const user = useUserinfoStore()
const game = useGameinfoStore()
const actionLogout = async () => {
await useAuth().logout()
useRouter().push('/')
}
</script>
<style lang="scss">
@import '~/assets/css/components';
.topbar {
&__container {
display: flex;
width: 100%;
height: 64px;
align-items: center;
background-color: $topbar-background-color;
font-size: 16px;
font-family: $font-primary;
font-weight: bold;
}
&__username,
&__logout-button-container {
width: 128px;
padding: 0 16px;
text-align: center;
color: $text-primary-color;
}
&__actionbar {
flex-grow: 1;
&__player {
font-size: 24px;
text-align: center;
}
}
&__separator {
width: 1px;
height: calc(64px - 2 * 16px);
margin: 16px 0;
background-color: $topbar-separator-color;
}
&__logout-button {
color: $text-primary-color;
font-size: 16px;
font-family: $font-primary;
&:hover {
color: $text-primary-hover-color;
}
}
}
</style>