Sharkey/src/client/app/desktop/views/components/user-preview.vue

168 lines
3 KiB
Vue
Raw Normal View History

2018-02-16 09:51:02 +02:00
<template>
<div class="mk-user-preview">
<template v-if="u != null">
2018-03-29 08:48:47 +03:00
<div class="banner" :style="u.bannerUrl ? `background-image: url(${u.bannerUrl}?thumbnail&size=512)` : ''"></div>
2018-04-29 11:17:15 +03:00
<mk-avatar class="avatar" :user="u" :disable-preview="true"/>
2018-02-16 09:51:02 +02:00
<div class="title">
2018-04-20 01:55:46 +03:00
<router-link class="name" :to="u | userPage">{{ u | userName }}</router-link>
2018-04-09 12:52:29 +03:00
<p class="username">@{{ u | acct }}</p>
2018-02-16 09:51:02 +02:00
</div>
<div class="description">{{ u.description }}</div>
<div class="status">
<div>
2018-04-07 20:30:37 +03:00
<p>投稿</p><a>{{ u.notesCount }}</a>
2018-02-16 09:51:02 +02:00
</div>
<div>
2018-03-29 08:48:47 +03:00
<p>フォロー</p><a>{{ u.followingCount }}</a>
2018-02-16 09:51:02 +02:00
</div>
<div>
2018-03-29 08:48:47 +03:00
<p>フォロワー</p><a>{{ u.followersCount }}</a>
2018-02-16 09:51:02 +02:00
</div>
</div>
2018-02-18 05:35:18 +02:00
<mk-follow-button v-if="os.isSignedIn && user.id != os.i.id" :user="u"/>
2018-02-16 09:51:02 +02:00
</template>
</div>
</template>
<script lang="ts">
import Vue from 'vue';
import * as anime from 'animejs';
2018-04-02 07:44:32 +03:00
import parseAcct from '../../../../../acct/parse';
2018-02-16 09:51:02 +02:00
export default Vue.extend({
props: {
user: {
type: [Object, String],
required: true
}
},
data() {
return {
2018-04-09 13:18:15 +03:00
u: null
2018-02-16 09:51:02 +02:00
};
},
mounted() {
if (typeof this.user == 'object') {
this.u = this.user;
2018-02-16 19:24:10 +02:00
this.$nextTick(() => {
this.open();
});
2018-02-16 09:51:02 +02:00
} else {
2018-03-27 10:51:12 +03:00
const query = this.user[0] == '@' ?
2018-04-08 13:30:19 +03:00
parseAcct(this.user.substr(1)) :
{ userId: this.user };
2018-03-27 10:51:12 +03:00
(this as any).api('users/show', query).then(user => {
2018-02-16 09:51:02 +02: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',
complete: () => this.$destroy()
});
}
}
});
</script>
<style lang="stylus" scoped>
2018-03-03 06:47:55 +02:00
@import '~const.styl'
2018-04-20 01:55:46 +03:00
root(isDark)
2018-02-16 09:51:02 +02:00
position absolute
z-index 2048
margin-top -8px
width 250px
2018-04-20 01:55:46 +03:00
background isDark ? #282c37 : #fff
2018-02-16 09:51:02 +02:00
background-clip content-box
2018-04-29 02:51:17 +03:00
border solid 1px rgba(#000, 0.1)
2018-02-16 09:51:02 +02:00
border-radius 4px
overflow hidden
opacity 0
> .banner
height 84px
2018-04-20 01:55:46 +03:00
background-color isDark ? #1c1e26 : #f5f5f5
2018-02-16 09:51:02 +02:00
background-size cover
background-position center
> .avatar
display block
position absolute
top 62px
left 13px
2018-02-22 18:11:09 +02:00
z-index 2
2018-04-29 11:17:15 +03:00
width 58px
height 58px
border solid 3px isDark ? #282c37 : #fff
border-radius 8px
2018-02-16 09:51:02 +02:00
> .title
display block
padding 8px 0 8px 82px
> .name
2018-02-22 18:11:09 +02:00
display inline-block
2018-02-16 09:51:02 +02:00
margin 0
font-weight bold
line-height 16px
2018-04-20 01:55:46 +03:00
color isDark ? #fff : #656565
2018-02-16 09:51:02 +02:00
> .username
display block
margin 0
line-height 16px
font-size 0.8em
2018-04-20 01:55:46 +03:00
color isDark ? #606984 : #999
2018-02-16 09:51:02 +02:00
> .description
padding 0 16px
font-size 0.7em
2018-04-20 07:38:28 +03:00
color isDark ? #9ea4ad : #555
2018-02-16 09:51:02 +02:00
> .status
padding 8px 16px
> div
display inline-block
width 33%
> p
margin 0
font-size 0.7em
color #aaa
> a
font-size 1em
color $theme-color
> .mk-follow-button
position absolute
top 92px
right 8px
2018-04-20 01:55:46 +03:00
.mk-user-preview[data-darkmode]
root(true)
.mk-user-preview:not([data-darkmode])
root(false)
2018-02-16 09:51:02 +02:00
</style>