/
user.vue
168 lines (166 loc) · 3.8 KB
/
user.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<template>
<div v-if="$auth.loggedIn" v-click-outside="close" class="user">
<a class="user__button" href="#" @click.prevent="showSelector">
{{ firstChar(user.username) }}
</a>
<div v-if="visibleSelector && user" class="user__content">
<p class="user__name">{{ user.username }}</p>
<p class="user__mail">{{ user.email }}</p>
<a
class="user__link"
href="https://docs.rubrix.ml/en/stable/"
target="_blank"
>
<svgicon name="docs"></svgicon> View docs
</a>
<a class="user__link" href="#" @click.prevent="logout">
<svgicon name="logout"></svgicon> Log out
</a>
<span class="copyright">© 2022 Rubrix ({{ rubrixVersion }})</span>
</div>
</div>
</template>
<script>
import { mapActions } from "vuex";
import "assets/icons/docs";
import "assets/icons/logout";
export default {
data: () => {
return {
visibleSelector: false,
rubrixVersion: undefined,
};
},
computed: {
user() {
return this.$auth.user;
},
},
async fetch() {
this.rubrixVersion = await this.getRubrixVersion();
},
methods: {
...mapActions({
getRubrixVersion: "entities/rubrix-info/getRubrixVersion",
}),
firstChar(name) {
return name.slice(0, 2);
},
showSelector() {
this.visibleSelector = !this.visibleSelector;
},
close() {
this.visibleSelector = false;
},
async logout() {
await this.$auth.logout();
await this.$auth.strategy.token.reset();
},
},
};
</script>
<style scope lang="scss">
$buttonSize: 34px;
%circle {
height: $buttonSize;
width: $buttonSize;
line-height: $buttonSize;
display: block;
text-align: center;
text-transform: uppercase;
border-radius: 50%;
text-decoration: none;
font-weight: 700;
@include font-size(16px);
}
.user {
position: relative;
z-index: 3;
&__button {
@extend %circle;
background: $lighter-color;
transform: scale3d(1, 1, 1) translateZ(0);
transition: all 0.2s ease-in-out;
color: $primary-color;
will-change: auto;
&:hover {
transform: scale3d(1.05, 1.05, 1.05) translateZ(0);
transition: all 0.2s ease-in-out;
}
}
&__content {
position: absolute;
top: 3.8em;
right: -1em;
padding-top: 1.5em;
background: $lighter-color;
border-radius: $border-radius;
@include font-size(12px);
font-weight: 600;
color: palette(grey, medium);
padding: 1.2em 1.2em 0.8em 1.2em;
box-shadow: $shadow;
min-width: 200px;
a {
text-decoration: none;
}
}
&__name {
color: palette(grey, dark);
@include font-size(16px);
margin: 0 1.5em 0.3em 1.5em;
font-weight: 600;
}
&__mail {
margin: 0 1.5em 2em 1.5em;
}
&__link {
display: flex;
align-items: center;
outline: none !important;
padding: 0.7em;
margin: 0 -0.5em 0 -0.5em;
transition: background-color 0.3s ease-in-out;
border-radius: $border-radius;
&:hover {
background: #f5f5f5;
transition: background-color 0.3s ease-in-out;
}
&__circle {
@extend %circle;
margin-right: 0.7em;
background: palette(grey, dark);
color: $lighter-color;
&.active {
background: $primary-color;
}
}
&__name {
color: palette(grey, dark);
margin-top: 0;
margin-bottom: 0;
line-height: 1.4em;
span {
display: block;
margin-top: 0;
margin-bottom: 0;
color: palette(grey, medium);
}
}
}
}
.copyright {
display: block;
@include font-size(11px);
text-transform: uppercase;
font-weight: 400;
color: palette(grey, dark);
line-height: 1em;
margin-top: 1.5em;
padding: 1em;
background: #fcfcfc;
text-align: right;
border-bottom-right-radius: 5px;
border-bottom-left-radius: 5px;
}
</style>