koel/resources/assets/js/components/user/UserBadge.vue

79 lines
1.5 KiB
Vue
Raw Normal View History

2022-04-15 14:24:30 +00:00
<template>
<span class="profile" id="userBadge">
2022-04-23 21:48:19 +00:00
<a class="view-profile" data-testid="view-profile-link" href="/#!/profile" title="View/edit user profile">
<img :alt="`Avatar of ${user.name}`" :src="user.avatar" class="avatar"/>
2022-04-15 17:00:08 +00:00
<span class="name">{{ user.name }}</span>
2022-04-15 14:24:30 +00:00
</a>
<a
2022-04-23 21:48:19 +00:00
title="Log out"
2022-04-15 14:24:30 +00:00
class="logout control"
data-testid="btn-logout"
href
role="button"
2022-04-23 21:48:19 +00:00
@click.prevent="logout"
2022-04-15 14:24:30 +00:00
>
<i class="fa fa-sign-out"></i>
</a>
</span>
</template>
2022-04-15 17:00:08 +00:00
<script lang="ts" setup>
import { toRef } from 'vue'
2022-04-15 14:24:30 +00:00
import { userStore } from '@/stores'
import { eventBus } from '@/utils'
2022-04-15 17:00:08 +00:00
const user = toRef(userStore.state, 'current')
2022-04-15 14:24:30 +00:00
2022-04-15 17:00:08 +00:00
const logout = () => eventBus.emit('LOG_OUT')
2022-04-15 14:24:30 +00:00
</script>
<style lang="scss">
#userBadge {
@include vertical-center();
justify-content: flex-end;
flex: 0 0 var(--extra-panel-width);
text-align: right;
height: 100%;
position: relative;
.avatar {
width: 24px;
height: 24px;
border-radius: 50%;
margin-right: .5rem;
}
.view-profile {
height: 100%;
@include vertical-center();
}
.logout {
height: 100%;
padding: 0 1.25rem;
@include vertical-center();
}
2022-04-15 17:00:08 +00:00
@media only screen and (max-width: 667px) {
2022-04-15 14:24:30 +00:00
flex: 0 0 96px;
margin-right: 0;
padding-right: 0;
align-content: stretch;
.name {
display: none;
}
.view-profile, .logout {
flex: 0 0 40px;
font-size: 1.4rem;
margin-right: 0;
@include vertical-center();
}
}
}
</style>