2018-02-12 13:10:16 +01:00
|
|
|
<template>
|
2018-09-18 19:51:06 +02:00
|
|
|
<div class="account" v-hotkey.global="keymap">
|
2018-02-12 13:10:16 +01:00
|
|
|
<button class="header" :data-active="isOpen" @click="toggle">
|
2018-11-05 17:40:11 +01:00
|
|
|
<span class="username">{{ $store.state.i.username }}<template v-if="!isOpen"><fa icon="angle-down"/></template><template v-if="isOpen"><fa icon="angle-up"/></template></span>
|
2018-05-27 06:49:09 +02:00
|
|
|
<mk-avatar class="avatar" :user="$store.state.i"/>
|
2018-02-12 13:10:16 +01:00
|
|
|
</button>
|
2018-02-22 19:33:12 +01:00
|
|
|
<transition name="zoom-in-top">
|
|
|
|
<div class="menu" v-if="isOpen">
|
|
|
|
<ul>
|
|
|
|
<li>
|
2018-11-05 17:40:11 +01:00
|
|
|
<router-link :to="`/@${ $store.state.i.username }`">
|
2019-04-29 02:11:57 +02:00
|
|
|
<i><fa icon="user" fixed-width/></i>
|
2018-11-08 19:44:35 +01:00
|
|
|
<span>{{ $t('profile') }}</span>
|
2018-11-05 17:40:11 +01:00
|
|
|
<i><fa icon="angle-right"/></i>
|
|
|
|
</router-link>
|
2018-02-22 19:33:12 +01:00
|
|
|
</li>
|
|
|
|
<li @click="drive">
|
2018-11-05 17:40:11 +01:00
|
|
|
<p>
|
2019-04-29 02:11:57 +02:00
|
|
|
<i><fa icon="cloud" fixed-width/></i>
|
2018-11-08 19:44:35 +01:00
|
|
|
<span>{{ $t('@.drive') }}</span>
|
2018-11-05 17:40:11 +01:00
|
|
|
<i><fa icon="angle-right"/></i>
|
|
|
|
</p>
|
2018-02-22 19:33:12 +01:00
|
|
|
</li>
|
2018-04-20 05:38:31 +02:00
|
|
|
<li>
|
2018-11-05 17:40:11 +01:00
|
|
|
<router-link to="/i/favorites">
|
2019-04-29 02:11:57 +02:00
|
|
|
<i><fa icon="star" fixed-width/></i>
|
2019-03-01 02:42:28 +01:00
|
|
|
<span>{{ $t('@.favorites') }}</span>
|
2018-11-05 17:40:11 +01:00
|
|
|
<i><fa icon="angle-right"/></i>
|
|
|
|
</router-link>
|
2018-04-20 05:38:31 +02:00
|
|
|
</li>
|
2019-05-18 13:36:33 +02:00
|
|
|
<li>
|
|
|
|
<router-link to="/i/lists">
|
2019-04-29 02:11:57 +02:00
|
|
|
<i><fa icon="list" fixed-width/></i>
|
2018-11-08 19:44:35 +01:00
|
|
|
<span>{{ $t('lists') }}</span>
|
2018-11-05 17:40:11 +01:00
|
|
|
<i><fa icon="angle-right"/></i>
|
2019-05-18 13:36:33 +02:00
|
|
|
</router-link>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<router-link to="/i/groups">
|
|
|
|
<i><fa :icon="faUsers" fixed-width/></i>
|
|
|
|
<span>{{ $t('groups') }}</span>
|
|
|
|
<i><fa icon="angle-right"/></i>
|
|
|
|
</router-link>
|
2018-04-24 14:24:06 +02:00
|
|
|
</li>
|
2019-04-29 04:03:05 +02:00
|
|
|
<li>
|
2019-04-29 02:11:57 +02:00
|
|
|
<router-link to="/i/pages">
|
|
|
|
<i><fa :icon="faStickyNote" fixed-width/></i>
|
|
|
|
<span>{{ $t('@.pages') }}</span>
|
|
|
|
<i><fa icon="angle-right"/></i>
|
|
|
|
</router-link>
|
|
|
|
</li>
|
2019-05-18 13:36:33 +02:00
|
|
|
<li v-if="($store.state.i.isLocked || $store.state.i.carefulBot)">
|
|
|
|
<router-link to="/i/follow-requests">
|
2019-04-29 02:11:57 +02:00
|
|
|
<i><fa :icon="['far', 'envelope']" fixed-width/></i>
|
2018-11-08 19:44:35 +01:00
|
|
|
<span>{{ $t('follow-requests') }}<i v-if="$store.state.i.pendingReceivedFollowRequestsCount">{{ $store.state.i.pendingReceivedFollowRequestsCount }}</i></span>
|
2018-11-05 17:40:11 +01:00
|
|
|
<i><fa icon="angle-right"/></i>
|
2019-05-18 13:36:33 +02:00
|
|
|
</router-link>
|
2018-06-02 06:34:53 +02:00
|
|
|
</li>
|
2018-02-22 19:33:12 +01:00
|
|
|
</ul>
|
|
|
|
<ul>
|
2018-12-27 12:45:23 +01:00
|
|
|
<li>
|
|
|
|
<router-link to="/i/settings">
|
2019-04-29 02:11:57 +02:00
|
|
|
<i><fa icon="cog" fixed-width/></i>
|
2019-03-01 02:42:28 +01:00
|
|
|
<span>{{ $t('@.settings') }}</span>
|
2018-11-05 17:40:11 +01:00
|
|
|
<i><fa icon="angle-right"/></i>
|
2018-12-27 12:45:23 +01:00
|
|
|
</router-link>
|
2018-02-22 19:33:12 +01:00
|
|
|
</li>
|
2018-11-14 20:15:42 +01:00
|
|
|
<li v-if="$store.state.i.isAdmin || $store.state.i.isModerator">
|
2018-11-05 17:40:11 +01:00
|
|
|
<a href="/admin">
|
2019-04-29 02:11:57 +02:00
|
|
|
<i><fa icon="terminal" fixed-width/></i>
|
2018-11-08 19:44:35 +01:00
|
|
|
<span>{{ $t('admin') }}</span>
|
2018-11-05 17:40:11 +01:00
|
|
|
<i><fa icon="angle-right"/></i>
|
|
|
|
</a>
|
2018-04-20 00:45:37 +02:00
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<ul>
|
2019-02-15 22:50:58 +01:00
|
|
|
<li @click="toggleDeckMode">
|
|
|
|
<p>
|
2019-02-23 19:34:09 +01:00
|
|
|
<template v-if="$store.state.device.inDeckMode"><span>{{ $t('@.home') }}</span><i><fa :icon="faHome"/></i></template>
|
|
|
|
<template v-else><span>{{ $t('@.deck') }}</span><i><fa :icon="faColumns"/></i></template>
|
2019-02-15 22:50:58 +01:00
|
|
|
</p>
|
|
|
|
</li>
|
2018-04-20 00:45:37 +02:00
|
|
|
<li @click="dark">
|
2018-11-05 17:40:11 +01:00
|
|
|
<p>
|
2019-02-24 05:29:08 +01:00
|
|
|
<span>{{ $store.state.device.darkmode ? $t('@.turn-off-darkmode') : $t('@.turn-on-darkmode') }}</span>
|
|
|
|
<template><i><fa :icon="$store.state.device.darkmode ? faSun : faMoon"/></i></template>
|
2018-11-05 17:40:11 +01:00
|
|
|
</p>
|
2018-02-22 19:33:12 +01:00
|
|
|
</li>
|
|
|
|
</ul>
|
2018-08-22 19:47:12 +02:00
|
|
|
<ul>
|
|
|
|
<li @click="signout">
|
2018-11-05 17:40:11 +01:00
|
|
|
<p class="signout">
|
2019-04-29 02:11:57 +02:00
|
|
|
<i><fa icon="power-off" fixed-width/></i>
|
2019-02-26 06:13:02 +01:00
|
|
|
<span>{{ $t('@.signout') }}</span>
|
2018-11-05 17:40:11 +01:00
|
|
|
</p>
|
2018-08-22 19:47:12 +02:00
|
|
|
</li>
|
|
|
|
</ul>
|
2018-02-22 19:33:12 +01:00
|
|
|
</div>
|
|
|
|
</transition>
|
2018-02-12 13:10:16 +01:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
2018-11-08 19:44:35 +01:00
|
|
|
import i18n from '../../../i18n';
|
2019-04-18 14:33:24 +02:00
|
|
|
// import MkSettingsWindow from './settings-window.vue';
|
2018-02-18 15:51:41 +01:00
|
|
|
import MkDriveWindow from './drive-window.vue';
|
2018-02-12 13:10:16 +01:00
|
|
|
import contains from '../../../common/scripts/contains';
|
2019-05-18 13:36:33 +02:00
|
|
|
import { faHome, faColumns, faUsers } from '@fortawesome/free-solid-svg-icons';
|
2019-04-29 02:11:57 +02:00
|
|
|
import { faMoon, faSun, faStickyNote } from '@fortawesome/free-regular-svg-icons';
|
2018-02-12 13:10:16 +01:00
|
|
|
|
|
|
|
export default Vue.extend({
|
2018-11-08 19:44:35 +01:00
|
|
|
i18n: i18n('desktop/views/components/ui.header.account.vue'),
|
2018-02-12 13:10:16 +01:00
|
|
|
data() {
|
|
|
|
return {
|
2019-02-15 22:50:58 +01:00
|
|
|
isOpen: false,
|
2019-05-18 13:36:33 +02:00
|
|
|
faHome, faColumns, faMoon, faSun, faStickyNote, faUsers
|
2018-02-12 13:10:16 +01:00
|
|
|
};
|
|
|
|
},
|
2018-09-18 19:51:06 +02:00
|
|
|
computed: {
|
|
|
|
keymap(): any {
|
|
|
|
return {
|
|
|
|
'a|m': this.toggle
|
|
|
|
};
|
|
|
|
}
|
|
|
|
},
|
2018-02-12 13:10:16 +01:00
|
|
|
beforeDestroy() {
|
|
|
|
this.close();
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
toggle() {
|
|
|
|
this.isOpen ? this.close() : this.open();
|
|
|
|
},
|
|
|
|
open() {
|
|
|
|
this.isOpen = true;
|
2018-12-11 12:36:55 +01:00
|
|
|
for (const el of Array.from(document.querySelectorAll('body *'))) {
|
2018-02-12 13:10:16 +01:00
|
|
|
el.addEventListener('mousedown', this.onMousedown);
|
2018-12-11 12:36:55 +01:00
|
|
|
}
|
2018-02-12 13:10:16 +01:00
|
|
|
},
|
|
|
|
close() {
|
|
|
|
this.isOpen = false;
|
2018-12-11 12:36:55 +01:00
|
|
|
for (const el of Array.from(document.querySelectorAll('body *'))) {
|
2018-02-12 13:10:16 +01:00
|
|
|
el.removeEventListener('mousedown', this.onMousedown);
|
2018-12-11 12:36:55 +01:00
|
|
|
}
|
2018-02-12 13:10:16 +01:00
|
|
|
},
|
|
|
|
onMousedown(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
if (!contains(this.$el, e.target) && this.$el != e.target) this.close();
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
drive() {
|
|
|
|
this.close();
|
2018-11-09 00:13:34 +01:00
|
|
|
this.$root.new(MkDriveWindow);
|
2018-02-12 13:10:16 +01:00
|
|
|
},
|
2018-02-26 11:23:53 +01:00
|
|
|
signout() {
|
2018-11-09 10:25:21 +01:00
|
|
|
this.$root.signout();
|
2018-04-20 00:45:37 +02:00
|
|
|
},
|
|
|
|
dark() {
|
2018-05-23 22:28:46 +02:00
|
|
|
this.$store.commit('device/set', {
|
|
|
|
key: 'darkmode',
|
|
|
|
value: !this.$store.state.device.darkmode
|
|
|
|
});
|
2019-02-15 22:50:58 +01:00
|
|
|
},
|
|
|
|
toggleDeckMode() {
|
2019-02-17 13:28:20 +01:00
|
|
|
this.$store.commit('device/set', { key: 'deckMode', value: !this.$store.state.device.inDeckMode });
|
2019-02-17 15:40:00 +01:00
|
|
|
location.replace('/');
|
2019-02-15 22:50:58 +01:00
|
|
|
},
|
2018-02-12 13:10:16 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="stylus" scoped>
|
2018-09-27 15:55:17 +02:00
|
|
|
.account
|
2018-02-12 13:10:16 +01:00
|
|
|
> .header
|
|
|
|
display block
|
|
|
|
margin 0
|
|
|
|
padding 0
|
2018-09-27 08:19:11 +02:00
|
|
|
color var(--desktopHeaderFg)
|
2018-02-12 13:10:16 +01:00
|
|
|
border none
|
|
|
|
background transparent
|
|
|
|
cursor pointer
|
|
|
|
|
|
|
|
*
|
|
|
|
pointer-events none
|
|
|
|
|
|
|
|
&:hover
|
|
|
|
&[data-active='true']
|
2018-09-27 08:19:11 +02:00
|
|
|
color var(--desktopHeaderHoverFg)
|
2018-02-12 13:10:16 +01:00
|
|
|
|
|
|
|
> .avatar
|
|
|
|
filter saturate(150%)
|
|
|
|
|
|
|
|
> .username
|
|
|
|
display block
|
|
|
|
float left
|
|
|
|
margin 0 12px 0 16px
|
|
|
|
max-width 16em
|
|
|
|
line-height 48px
|
|
|
|
font-weight bold
|
|
|
|
font-family Meiryo, sans-serif
|
|
|
|
text-decoration none
|
|
|
|
|
2018-10-15 10:43:25 +02:00
|
|
|
@media (max-width 1100px)
|
|
|
|
display none
|
|
|
|
|
2018-11-05 17:40:11 +01:00
|
|
|
[data-icon]
|
2018-02-12 13:10:16 +01:00
|
|
|
margin-left 8px
|
|
|
|
|
|
|
|
> .avatar
|
|
|
|
display block
|
|
|
|
float left
|
|
|
|
min-width 32px
|
|
|
|
max-width 32px
|
|
|
|
min-height 32px
|
|
|
|
max-height 32px
|
|
|
|
margin 8px 8px 8px 0
|
|
|
|
border-radius 4px
|
|
|
|
transition filter 100ms ease
|
|
|
|
|
2018-10-15 10:43:25 +02:00
|
|
|
@media (max-width 1100px)
|
|
|
|
margin-left 8px
|
|
|
|
|
2018-02-12 13:10:16 +01:00
|
|
|
> .menu
|
2018-09-26 13:28:13 +02:00
|
|
|
$bgcolor = var(--face)
|
2018-02-12 13:10:16 +01:00
|
|
|
display block
|
|
|
|
position absolute
|
|
|
|
top 56px
|
|
|
|
right -2px
|
|
|
|
width 230px
|
|
|
|
font-size 0.8em
|
2018-04-20 00:45:37 +02:00
|
|
|
background $bgcolor
|
2018-02-12 13:10:16 +01:00
|
|
|
border-radius 4px
|
2018-12-30 06:00:57 +01:00
|
|
|
box-shadow 0 var(--lineWidth) 4px rgba(#000, 0.25)
|
2018-02-12 13:10:16 +01:00
|
|
|
|
|
|
|
&:before
|
|
|
|
content ""
|
|
|
|
pointer-events none
|
|
|
|
display block
|
|
|
|
position absolute
|
|
|
|
top -28px
|
|
|
|
right 12px
|
|
|
|
border-top solid 14px transparent
|
|
|
|
border-right solid 14px transparent
|
2018-04-29 01:51:17 +02:00
|
|
|
border-bottom solid 14px rgba(#000, 0.1)
|
2018-02-12 13:10:16 +01:00
|
|
|
border-left solid 14px transparent
|
|
|
|
|
|
|
|
&:after
|
|
|
|
content ""
|
|
|
|
pointer-events none
|
|
|
|
display block
|
|
|
|
position absolute
|
|
|
|
top -27px
|
|
|
|
right 12px
|
|
|
|
border-top solid 14px transparent
|
|
|
|
border-right solid 14px transparent
|
2018-04-20 00:45:37 +02:00
|
|
|
border-bottom solid 14px $bgcolor
|
2018-02-12 13:10:16 +01:00
|
|
|
border-left solid 14px transparent
|
|
|
|
|
|
|
|
ul
|
|
|
|
display block
|
|
|
|
margin 10px 0
|
|
|
|
padding 0
|
|
|
|
list-style none
|
|
|
|
|
|
|
|
& + ul
|
|
|
|
padding-top 10px
|
2018-12-30 06:00:57 +01:00
|
|
|
border-top solid var(--lineWidth) var(--faceDivider)
|
2018-02-12 13:10:16 +01:00
|
|
|
|
|
|
|
> li
|
|
|
|
display block
|
|
|
|
margin 0
|
|
|
|
padding 0
|
|
|
|
|
|
|
|
> a
|
|
|
|
> p
|
|
|
|
display block
|
|
|
|
z-index 1
|
|
|
|
padding 0 28px
|
|
|
|
margin 0
|
|
|
|
line-height 40px
|
2018-09-27 15:55:17 +02:00
|
|
|
color var(--text)
|
2018-02-12 13:10:16 +01:00
|
|
|
cursor pointer
|
|
|
|
|
|
|
|
*
|
|
|
|
pointer-events none
|
|
|
|
|
2018-04-20 00:45:37 +02:00
|
|
|
> span:first-child
|
2018-04-20 05:38:31 +02:00
|
|
|
padding-left 22px
|
2018-04-20 00:45:37 +02:00
|
|
|
|
2018-06-02 06:34:53 +02:00
|
|
|
> span:nth-child(2)
|
|
|
|
> i
|
|
|
|
margin-left 4px
|
|
|
|
padding 2px 8px
|
|
|
|
font-size 90%
|
2018-06-02 08:51:43 +02:00
|
|
|
font-style normal
|
2018-09-26 13:19:35 +02:00
|
|
|
background var(--primary)
|
|
|
|
color var(--primaryForeground)
|
2018-06-02 06:34:53 +02:00
|
|
|
border-radius 8px
|
|
|
|
|
2018-11-05 17:40:11 +01:00
|
|
|
> i:first-child
|
2018-02-12 13:10:16 +01:00
|
|
|
margin-right 6px
|
2018-04-20 00:45:37 +02:00
|
|
|
width 16px
|
2018-02-12 13:10:16 +01:00
|
|
|
|
2018-11-05 17:40:11 +01:00
|
|
|
> i:last-child
|
2018-02-12 13:10:16 +01:00
|
|
|
display block
|
|
|
|
position absolute
|
|
|
|
top 0
|
|
|
|
right 8px
|
|
|
|
z-index 1
|
|
|
|
padding 0 20px
|
|
|
|
font-size 1.2em
|
|
|
|
line-height 40px
|
|
|
|
|
|
|
|
&:hover, &:active
|
|
|
|
text-decoration none
|
2018-09-26 13:19:35 +02:00
|
|
|
background var(--primary)
|
|
|
|
color var(--primaryForeground)
|
2018-02-12 13:10:16 +01:00
|
|
|
|
2018-02-22 19:33:12 +01:00
|
|
|
&:active
|
2018-09-26 13:19:35 +02:00
|
|
|
background var(--primaryDarken10)
|
2018-02-22 19:33:12 +01:00
|
|
|
|
2018-04-20 05:38:31 +02:00
|
|
|
&.signout
|
|
|
|
$color = #e64137
|
|
|
|
|
|
|
|
&:hover, &:active
|
|
|
|
background $color
|
|
|
|
color #fff
|
|
|
|
|
|
|
|
&:active
|
|
|
|
background darken($color, 10%)
|
|
|
|
|
2018-02-22 19:33:12 +01:00
|
|
|
.zoom-in-top-enter-active,
|
|
|
|
.zoom-in-top-leave-active {
|
|
|
|
transform-origin: center -16px;
|
|
|
|
}
|
|
|
|
|
2018-02-12 13:10:16 +01:00
|
|
|
</style>
|