storj/web/satellite/src/components/header/AccountButton.vue

126 lines
3.3 KiB
Vue
Raw Normal View History

2019-01-24 20:15:10 +00:00
// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
<template>
<div class="account-button-container" id="accountDropdownButton">
<div class="account-button-toggle-container" @click="toggleSelection">
<div class="account-button-toggle-container__avatar" :class="{ 'expanded-background': isDropdownShown }">
<h1 class="account-button-toggle-container__avatar__letter" :class="{ 'expanded-font-color': isDropdownShown }">
{{ avatarLetter }}
</h1>
2018-11-16 14:28:02 +00:00
</div>
<div class="account-button-toggle-container__expander-area">
<ExpandIcon
v-if="!isDropdownShown"
alt="Arrow down (expand)"
/>
<HideIcon
v-if="isDropdownShown"
alt="Arrow up (hide)"
/>
</div>
</div>
<AccountDropdown v-if="isDropdownShown"/>
2018-11-16 14:28:02 +00:00
</div>
</template>
<script lang="ts">
2019-09-09 11:33:39 +01:00
import { Component, Vue } from 'vue-property-decorator';
import ExpandIcon from '@/../static/images/common/BlackArrowExpand.svg';
2019-09-09 11:33:39 +01:00
import { APP_STATE_ACTIONS } from '@/utils/constants/actionNames';
import HideIcon from '../../../static/images/common/ArrowHide.svg';
2019-09-09 11:33:39 +01:00
import AccountDropdown from './AccountDropdown.vue';
2019-09-09 11:33:39 +01:00
@Component({
components: {
AccountDropdown,
ExpandIcon,
HideIcon,
},
2019-09-09 11:33:39 +01:00
})
export default class AccountButton extends Vue {
/**
* Toggles account dropdown.
*/
2019-09-09 11:33:39 +01:00
public toggleSelection(): void {
this.$store.dispatch(APP_STATE_ACTIONS.TOGGLE_ACCOUNT);
}
/**
* Returns first letter of user`s name.
*/
2019-09-09 11:33:39 +01:00
public get avatarLetter(): string {
return this.$store.getters.userName.slice(0, 1).toUpperCase();
}
/**
* Indicates if account dropdown should render.
*/
2019-09-09 11:33:39 +01:00
public get isDropdownShown(): boolean {
return this.$store.state.appStateModule.appState.isAccountDropdownShown;
}
2019-09-09 11:33:39 +01:00
}
</script>
<style scoped lang="scss">
.account-button-toggle-container {
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-start;
width: max-content;
height: 50px;
&__avatar {
width: 40px;
height: 40px;
border-radius: 6px;
display: flex;
align-items: center;
justify-content: center;
background: #e8eaf2;
&__letter {
font-family: 'font_medium', sans-serif;
font-size: 16px;
line-height: 23px;
color: #354049;
}
}
&__expander-area {
2019-10-17 13:25:18 +01:00
margin-left: 9px;
display: flex;
align-items: center;
justify-content: center;
}
}
.account-button-container {
position: relative;
background-color: #fff;
cursor: pointer;
}
.expanded-background {
background-color: #2582ff;
}
.expanded-font-color {
color: #fff;
}
@media screen and (max-width: 1280px) {
.account-button-toggle-container {
2019-07-10 10:55:40 +01:00
&__expander-area {
display: none;
}
}
}
</style>