2018-02-16 01:51:02 -06:00
|
|
|
<template>
|
|
|
|
<div class="mk-user-preview">
|
|
|
|
<template v-if="u != null">
|
2018-07-24 09:43:14 -05:00
|
|
|
<div class="banner" :style="u.bannerUrl ? `background-image: url(${u.bannerUrl})` : ''"></div>
|
2018-04-29 03:17:15 -05:00
|
|
|
<mk-avatar class="avatar" :user="u" :disable-preview="true"/>
|
2018-02-16 01:51:02 -06:00
|
|
|
<div class="title">
|
2018-04-19 17:55:46 -05:00
|
|
|
<router-link class="name" :to="u | userPage">{{ u | userName }}</router-link>
|
2018-05-18 01:42:42 -05:00
|
|
|
<p class="username"><mk-acct :user="u"/></p>
|
2018-02-16 01:51:02 -06:00
|
|
|
</div>
|
|
|
|
<div class="description">{{ u.description }}</div>
|
|
|
|
<div class="status">
|
|
|
|
<div>
|
2018-11-08 12:44:35 -06:00
|
|
|
<p>{{ $t('notes') }}</p><span>{{ u.notesCount }}</span>
|
2018-02-16 01:51:02 -06:00
|
|
|
</div>
|
|
|
|
<div>
|
2018-11-08 12:44:35 -06:00
|
|
|
<p>{{ $t('following') }}</p><span>{{ u.followingCount }}</span>
|
2018-02-16 01:51:02 -06:00
|
|
|
</div>
|
|
|
|
<div>
|
2018-11-08 12:44:35 -06:00
|
|
|
<p>{{ $t('followers') }}</p><span>{{ u.followersCount }}</span>
|
2018-02-16 01:51:02 -06:00
|
|
|
</div>
|
|
|
|
</div>
|
2018-11-13 01:19:46 -06:00
|
|
|
<mk-follow-button class="follow-button" v-if="$store.getters.isSignedIn && u.id != $store.state.i.id" :user="u" mini/>
|
2018-02-16 01:51:02 -06:00
|
|
|
</template>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
2018-11-08 12:44:35 -06:00
|
|
|
import i18n from '../../../i18n';
|
2018-02-16 01:51:02 -06:00
|
|
|
import * as anime from 'animejs';
|
2018-07-07 05:19:00 -05:00
|
|
|
import parseAcct from '../../../../../misc/acct/parse';
|
2018-02-16 01:51:02 -06:00
|
|
|
|
|
|
|
export default Vue.extend({
|
2018-11-08 12:44:35 -06:00
|
|
|
i18n: i18n('desktop/views/components/user-preview.vue'),
|
2018-02-16 01:51:02 -06:00
|
|
|
props: {
|
|
|
|
user: {
|
|
|
|
type: [Object, String],
|
|
|
|
required: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2018-04-09 05:18:15 -05:00
|
|
|
u: null
|
2018-02-16 01:51:02 -06:00
|
|
|
};
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
if (typeof this.user == 'object') {
|
|
|
|
this.u = this.user;
|
2018-02-16 11:24:10 -06:00
|
|
|
this.$nextTick(() => {
|
|
|
|
this.open();
|
|
|
|
});
|
2018-02-16 01:51:02 -06:00
|
|
|
} else {
|
2018-08-25 08:42:26 -05:00
|
|
|
const query = this.user.startsWith('@') ?
|
2018-04-08 05:30:19 -05:00
|
|
|
parseAcct(this.user.substr(1)) :
|
|
|
|
{ userId: this.user };
|
2018-03-27 02:51:12 -05:00
|
|
|
|
2018-11-08 17:13:34 -06:00
|
|
|
this.$root.api('users/show', query).then(user => {
|
2018-02-16 01:51:02 -06:00
|
|
|
this.u = user;
|
|
|
|
this.open();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
open() {
|
|
|
|
anime({
|
|
|
|
targets: this.$el,
|
|
|
|
opacity: 1,
|
|
|
|
'margin-top': 0,
|
|
|
|
duration: 200,
|
|
|
|
easing: 'easeOutQuad'
|
|
|
|
});
|
|
|
|
},
|
|
|
|
close() {
|
|
|
|
anime({
|
|
|
|
targets: this.$el,
|
|
|
|
opacity: 0,
|
|
|
|
'margin-top': '-8px',
|
|
|
|
duration: 200,
|
|
|
|
easing: 'easeOutQuad',
|
2018-09-15 07:53:04 -05:00
|
|
|
complete: () => this.destroyDom()
|
2018-02-16 01:51:02 -06:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="stylus" scoped>
|
2018-09-28 01:34:34 -05:00
|
|
|
.mk-user-preview
|
2018-02-16 01:51:02 -06:00
|
|
|
position absolute
|
|
|
|
z-index 2048
|
|
|
|
margin-top -8px
|
|
|
|
width 250px
|
2018-09-26 06:28:13 -05:00
|
|
|
background var(--face)
|
2018-02-16 01:51:02 -06:00
|
|
|
background-clip content-box
|
2018-04-28 18:51:17 -05:00
|
|
|
border solid 1px rgba(#000, 0.1)
|
2018-02-16 01:51:02 -06:00
|
|
|
border-radius 4px
|
|
|
|
overflow hidden
|
|
|
|
opacity 0
|
|
|
|
|
|
|
|
> .banner
|
|
|
|
height 84px
|
2018-09-28 01:34:34 -05:00
|
|
|
background-color rgba(0, 0, 0, 0.1)
|
2018-02-16 01:51:02 -06:00
|
|
|
background-size cover
|
|
|
|
background-position center
|
|
|
|
|
|
|
|
> .avatar
|
|
|
|
display block
|
|
|
|
position absolute
|
|
|
|
top 62px
|
|
|
|
left 13px
|
2018-02-22 10:11:09 -06:00
|
|
|
z-index 2
|
2018-04-29 03:17:15 -05:00
|
|
|
width 58px
|
|
|
|
height 58px
|
2018-09-26 06:28:13 -05:00
|
|
|
border solid 3px var(--face)
|
2018-04-29 03:17:15 -05:00
|
|
|
border-radius 8px
|
2018-02-16 01:51:02 -06:00
|
|
|
|
|
|
|
> .title
|
|
|
|
display block
|
|
|
|
padding 8px 0 8px 82px
|
|
|
|
|
|
|
|
> .name
|
2018-02-22 10:11:09 -06:00
|
|
|
display inline-block
|
2018-02-16 01:51:02 -06:00
|
|
|
margin 0
|
|
|
|
font-weight bold
|
|
|
|
line-height 16px
|
2018-09-28 01:34:34 -05:00
|
|
|
color var(--text)
|
2018-02-16 01:51:02 -06:00
|
|
|
|
|
|
|
> .username
|
|
|
|
display block
|
|
|
|
margin 0
|
|
|
|
line-height 16px
|
|
|
|
font-size 0.8em
|
2018-09-28 01:34:34 -05:00
|
|
|
color var(--text)
|
|
|
|
opacity 0.7
|
2018-02-16 01:51:02 -06:00
|
|
|
|
|
|
|
> .description
|
|
|
|
padding 0 16px
|
|
|
|
font-size 0.7em
|
2018-09-28 01:34:34 -05:00
|
|
|
color var(--text)
|
2018-02-16 01:51:02 -06:00
|
|
|
|
|
|
|
> .status
|
|
|
|
padding 8px 16px
|
|
|
|
|
|
|
|
> div
|
|
|
|
display inline-block
|
|
|
|
width 33%
|
|
|
|
|
|
|
|
> p
|
|
|
|
margin 0
|
|
|
|
font-size 0.7em
|
2018-09-28 01:34:34 -05:00
|
|
|
color var(--text)
|
2018-02-16 01:51:02 -06:00
|
|
|
|
2018-08-15 10:49:40 -05:00
|
|
|
> span
|
2018-02-16 01:51:02 -06:00
|
|
|
font-size 1em
|
2018-09-26 06:19:35 -05:00
|
|
|
color var(--primary)
|
2018-02-16 01:51:02 -06:00
|
|
|
|
2018-11-13 01:19:46 -06:00
|
|
|
> .follow-button
|
2018-02-16 01:51:02 -06:00
|
|
|
position absolute
|
|
|
|
top 92px
|
|
|
|
right 8px
|
|
|
|
|
|
|
|
</style>
|