knowyt/client/src/components/TopBar.vue

74 lines
1.5 KiB
Vue
Raw Normal View History

<template>
<div v-if="userInfo" class="topbar__container">
<div class="topbar__username">
{{ userInfo.name }}
</div>
<div class="topbar__separator" />
<div class="topbar__actionbar">
{{ userInfo.role }}
</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"
const { userInfo } = useUserinfoStore()
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;
}
&__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>