Sharkey/src/client/app/mobile/views/pages/user.vue

262 lines
5.4 KiB
Vue
Raw Normal View History

2018-02-15 11:33:34 +02:00
<template>
2018-02-22 10:32:58 +02:00
<mk-ui>
2018-04-09 12:52:29 +03:00
<span slot="header" v-if="!fetching">%fa:user% {{ user | userName }}</span>
2018-02-22 10:32:58 +02:00
<main v-if="!fetching">
2018-04-17 16:25:51 +03:00
<div class="is-remote" v-if="user.host != null"><p>%fa:exclamation-triangle% %i18n:@is-remote%<a :href="user.url || user.uri" target="_blank">%i18n:@view-remote%</a></p></div>
2018-02-15 11:33:34 +02:00
<header>
2018-03-29 08:48:47 +03:00
<div class="banner" :style="user.bannerUrl ? `background-image: url(${user.bannerUrl}?thumbnail&size=1024)` : ''"></div>
2018-02-15 11:33:34 +02:00
<div class="body">
<div class="top">
<a class="avatar">
2018-03-29 08:48:47 +03:00
<img :src="`${user.avatarUrl}?thumbnail&size=200`" alt="avatar"/>
2018-02-15 11:33:34 +02:00
</a>
2018-02-18 05:35:18 +02:00
<mk-follow-button v-if="os.isSignedIn && os.i.id != user.id" :user="user"/>
2018-02-15 11:33:34 +02:00
</div>
<div class="title">
2018-04-09 12:52:29 +03:00
<h1>{{ user | userName }}</h1>
<span class="username">@{{ user | acct }}</span>
2018-04-14 19:04:40 +03:00
<span class="followed" v-if="user.isFollowed">%i18n:@follows-you%</span>
2018-02-15 11:33:34 +02:00
</div>
<div class="description">{{ user.description }}</div>
<div class="info">
2018-04-07 21:58:11 +03:00
<p class="location" v-if="user.host === null && user.profile.location">
%fa:map-marker%{{ user.profile.location }}
2018-02-15 11:33:34 +02:00
</p>
2018-04-07 21:58:11 +03:00
<p class="birthday" v-if="user.host === null && user.profile.birthday">
%fa:birthday-cake%{{ user.profile.birthday.replace('-', '年').replace('-', '月') + '日' }} ({{ age }})
2018-02-15 11:33:34 +02:00
</p>
</div>
<div class="status">
2018-02-21 14:08:03 +02:00
<a>
2018-04-07 20:30:37 +03:00
<b>{{ user.notesCount | number }}</b>
2018-04-14 19:04:40 +03:00
<i>%i18n:@notes%</i>
2018-02-15 11:33:34 +02:00
</a>
2018-04-09 13:23:52 +03:00
<a :href="user | userPage('following')">
2018-03-29 08:48:47 +03:00
<b>{{ user.followingCount | number }}</b>
2018-04-14 19:04:40 +03:00
<i>%i18n:@following%</i>
2018-02-15 11:33:34 +02:00
</a>
2018-04-09 13:23:52 +03:00
<a :href="user | userPage('followers')">
2018-03-29 08:48:47 +03:00
<b>{{ user.followersCount | number }}</b>
2018-04-14 19:04:40 +03:00
<i>%i18n:@followers%</i>
2018-02-15 11:33:34 +02:00
</a>
</div>
</div>
</header>
<nav>
<div class="nav-container">
2018-04-16 09:13:31 +03:00
<a :data-is-active="page == 'home'" @click="page = 'home'">%i18n:@overview%</a>
<a :data-is-active="page == 'notes'" @click="page = 'notes'">%i18n:@timeline%</a>
<a :data-is-active="page == 'media'" @click="page = 'media'">%i18n:@media%</a>
</div>
</nav>
2018-02-15 11:33:34 +02:00
<div class="body">
2018-02-22 10:32:58 +02:00
<x-home v-if="page == 'home'" :user="user"/>
2018-04-16 09:13:31 +03:00
<mk-user-timeline v-if="page == 'notes'" :user="user" key="tl"/>
<mk-user-timeline v-if="page == 'media'" :user="user" :with-media="true" key="media"/>
2018-02-15 11:33:34 +02:00
</div>
2018-02-22 10:32:58 +02:00
</main>
2018-02-15 11:33:34 +02:00
</mk-ui>
</template>
<script lang="ts">
import Vue from 'vue';
2018-02-22 15:03:44 +02:00
import * as age from 's-age';
2018-04-08 13:27:53 +03:00
import parseAcct from '../../../../../acct/parse';
2018-02-16 06:11:54 +02:00
import Progress from '../../../common/scripts/loading';
2018-02-22 10:32:58 +02:00
import XHome from './user/home.vue';
2018-02-15 11:33:34 +02:00
export default Vue.extend({
2018-02-22 10:32:58 +02:00
components: {
XHome
},
2018-02-15 11:33:34 +02:00
data() {
return {
fetching: true,
2018-02-23 01:07:30 +02:00
user: null,
2018-04-09 12:52:29 +03:00
page: 'home'
2018-02-15 11:33:34 +02:00
};
},
computed: {
age(): number {
2018-04-07 21:58:11 +03:00
return age(this.user.profile.birthday);
2018-02-15 11:33:34 +02:00
}
},
2018-02-22 10:06:19 +02:00
watch: {
$route: 'fetch'
},
2018-02-22 14:23:10 +02:00
created() {
this.fetch();
},
2018-02-15 11:33:34 +02:00
mounted() {
2018-02-16 06:11:54 +02:00
document.documentElement.style.background = '#313a42';
2018-02-22 10:06:19 +02:00
},
methods: {
fetch() {
Progress.start();
2018-03-27 10:51:12 +03:00
(this as any).api('users/show', parseAcct(this.$route.params.user)).then(user => {
2018-02-22 10:06:19 +02:00
this.user = user;
this.fetching = false;
2018-02-16 06:11:54 +02:00
2018-02-22 10:06:19 +02:00
Progress.done();
2018-04-09 12:52:29 +03:00
document.title = Vue.filter('userName')(this.user) + ' | Misskey';
2018-02-22 10:06:19 +02:00
});
}
2018-02-15 11:33:34 +02:00
}
});
</script>
2018-02-22 10:32:58 +02:00
<style lang="stylus" scoped>
2018-03-03 06:47:55 +02:00
@import '~const.styl'
2018-02-22 10:32:58 +02:00
main
2018-04-15 12:38:40 +03:00
> .is-remote
padding 16px
color #573c08
background #fff0db
> p
margin 0 auto
max-width 1024px
> a
font-weight bold
2018-04-16 09:17:20 +03:00
@media (max-width 500px)
font-size 12px
2018-02-15 11:33:34 +02:00
> header
> .banner
padding-bottom 33.3%
background-color #1b1b1b
background-size cover
background-position center
> .body
padding 12px
margin 0 auto
max-width 600px
> .top
&:after
content ''
display block
clear both
> .avatar
display block
float left
width 25%
height 40px
> img
display block
position absolute
left -2px
bottom -2px
width 100%
2018-02-22 10:32:58 +02:00
border 3px solid #313a42
2018-02-15 11:33:34 +02:00
border-radius 6px
@media (min-width 500px)
left -4px
bottom -4px
border 4px solid #313a42
border-radius 12px
2018-02-16 20:01:00 +02:00
> .mk-follow-button
2018-02-15 11:33:34 +02:00
float right
height 40px
> .title
margin 8px 0
> h1
margin 0
line-height 22px
font-size 20px
color #fff
> .username
display inline-block
line-height 20px
font-size 16px
font-weight bold
color #657786
> .followed
margin-left 8px
padding 2px 4px
font-size 12px
color #657786
background #f8f8f8
border-radius 4px
> .description
margin 8px 0
color #fff
> .info
margin 8px 0
> p
display inline
margin 0 16px 0 0
color #a9b9c1
> i
margin-right 4px
> .status
> a
color #657786
&:not(:last-child)
margin-right 16px
> b
margin-right 4px
font-size 16px
color #fff
> i
font-size 14px
> nav
2018-04-09 20:04:30 +03:00
position -webkit-sticky
position sticky
top 48px
box-shadow 0 4px 4px rgba(0, 0, 0, 0.3)
background-color #313a42
z-index 1
2018-04-09 20:04:30 +03:00
> .nav-container
2018-02-15 11:33:34 +02:00
display flex
justify-content center
margin 0 auto
max-width 600px
> a
display block
flex 1 1
text-align center
line-height 52px
font-size 14px
text-decoration none
color #657786
border-bottom solid 2px transparent
&[data-is-active]
font-weight bold
color $theme-color
border-color $theme-color
> .body
padding 8px
@media (min-width 500px)
padding 16px
</style>