egirlskey/src/client/app/desktop/views/pages/user/user.header.vue

182 lines
4.1 KiB
Vue
Raw Normal View History

2018-02-14 15:32:13 +00:00
<template>
2018-03-29 05:48:47 +00:00
<div class="header" :data-is-dark-background="user.bannerUrl != null">
2018-04-19 09:54:34 +00:00
<div class="is-suspended" v-if="user.isSuspended"><p>%fa:exclamation-triangle% %i18n:@is-suspended%</p></div>
2018-04-17 13:25:51 +00: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-05-07 08:05:05 +00:00
<div class="banner-container" :style="style">
<div class="banner" ref="banner" :style="style" @click="onBannerClick"></div>
2018-04-18 10:47:56 +00:00
<div class="fade"></div>
2018-02-14 15:32:13 +00:00
<div class="title">
2018-04-09 09:52:29 +00:00
<p class="name">{{ user | userName }}</p>
2018-05-18 06:42:42 +00:00
<p class="username"><mk-acct :user="user"/></p>
2018-04-07 18:58:11 +00:00
<p class="location" v-if="user.host === null && user.profile.location">%fa:map-marker%{{ user.profile.location }}</p>
2018-02-14 15:32:13 +00:00
</div>
2018-06-20 10:55:34 +00:00
</div>
<mk-avatar class="avatar" :user="user" :disable-preview="true"/>
<div class="body">
<misskey-flavored-markdown v-if="user.description" :text="user.description" :i="$store.state.i"/>
2018-02-14 15:32:13 +00:00
</div>
</div>
</template>
<script lang="ts">
import Vue from 'vue';
export default Vue.extend({
props: ['user'],
2018-05-07 08:05:05 +00:00
computed: {
style(): any {
if (this.user.bannerUrl == null) return {};
return {
backgroundColor: this.user.bannerColor && this.user.bannerColor.length == 3 ? `rgb(${ this.user.bannerColor.join(',') })` : null,
2018-05-07 08:05:05 +00:00
backgroundImage: `url(${ this.user.bannerUrl })`
};
}
},
2018-02-14 15:32:13 +00:00
mounted() {
2018-04-15 09:38:40 +00:00
if (this.user.bannerUrl) {
window.addEventListener('load', this.onScroll);
2018-06-06 16:52:03 +00:00
window.addEventListener('scroll', this.onScroll, { passive: true });
2018-04-15 09:38:40 +00:00
window.addEventListener('resize', this.onScroll);
}
2018-02-14 15:32:13 +00:00
},
beforeDestroy() {
2018-04-15 09:38:40 +00:00
if (this.user.bannerUrl) {
window.removeEventListener('load', this.onScroll);
window.removeEventListener('scroll', this.onScroll);
window.removeEventListener('resize', this.onScroll);
}
2018-02-14 15:32:13 +00:00
},
methods: {
onScroll() {
const banner = this.$refs.banner as any;
const top = window.scrollY;
const z = 1.25; // 奥行き(小さいほど奥)
const pos = -(top / z);
banner.style.backgroundPosition = `center calc(50% - ${pos}px)`;
const blur = top / 32
if (blur <= 10) banner.style.filter = `blur(${blur}px)`;
},
onBannerClick() {
2018-05-27 04:49:09 +00:00
if (!this.$store.getters.isSignedIn || this.$store.state.i.id != this.user.id) return;
2018-02-14 15:32:13 +00:00
(this as any).apis.updateBanner().then(i => {
2018-03-29 05:48:47 +00:00
this.user.bannerUrl = i.bannerUrl;
2018-02-14 15:32:13 +00:00
});
}
}
});
</script>
<style lang="stylus" scoped>
2018-03-03 04:47:55 +00:00
@import '~const.styl'
2018-06-20 10:55:34 +00:00
root(isDark)
background isDark ? #282C37 : #fff
border 1px solid rgba(#000, 0.075)
border-radius 6px
2018-02-14 15:32:13 +00:00
overflow hidden
2018-04-19 09:54:34 +00:00
> .is-suspended
2018-04-15 09:38:40 +00:00
> .is-remote
2018-04-19 09:54:34 +00:00
&.is-suspended
color #570808
background #ffdbdb
&.is-remote
color #573c08
background #fff0db
2018-04-15 09:38:40 +00:00
> p
margin 0 auto
2018-04-19 17:09:53 +00:00
padding 14px 16px
max-width 1200px
font-size 14px
2018-04-15 09:38:40 +00:00
> a
font-weight bold
2018-02-14 15:32:13 +00:00
&[data-is-dark-background]
> .banner-container
> .banner
background-color #383838
2018-04-18 10:47:56 +00:00
> .fade
2018-04-28 23:51:17 +00:00
background linear-gradient(transparent, rgba(#000, 0.7))
2018-02-14 15:32:13 +00:00
> .title
color #fff
> .name
text-shadow 0 0 8px #000
> .banner-container
2018-06-20 10:55:34 +00:00
height 250px
2018-02-14 15:32:13 +00:00
overflow hidden
background-size cover
background-position center
> .banner
height 100%
2018-04-15 10:24:21 +00:00
background-color #bfccd0
2018-02-14 15:32:13 +00:00
background-size cover
background-position center
2018-04-18 10:47:56 +00:00
> .fade
position absolute
bottom 0
left 0
width 100%
height 78px
2018-02-14 15:32:13 +00:00
> .title
position absolute
2018-06-20 10:55:34 +00:00
bottom 0
2018-02-14 15:32:13 +00:00
left 0
width 100%
2018-06-20 10:55:34 +00:00
padding 0 0 8px 154px
2018-04-15 09:38:40 +00:00
color #5e6367
2018-02-14 15:32:13 +00:00
font-family '游ゴシック', 'YuGothic', 'ヒラギノ角ゴ ProN W3', 'Hiragino Kaku Gothic ProN', 'Meiryo', 'メイリオ', sans-serif
> .name
display block
margin 0
2018-06-20 10:55:34 +00:00
line-height 32px
2018-02-14 15:32:13 +00:00
font-weight bold
2018-06-20 10:55:34 +00:00
font-size 1.8em
2018-02-14 15:32:13 +00:00
> .username
> .location
display inline-block
margin 0 16px 0 0
line-height 20px
opacity 0.8
> i
margin-right 4px
2018-06-20 10:55:34 +00:00
> .avatar
display block
position absolute
top 170px
left 16px
z-index 2
width 120px
height 120px
box-shadow 1px 1px 3px rgba(#000, 0.2)
> .body
padding 16px 16px 16px 154px
color isDark ? #c5ced6 : #555
.header[data-darkmode]
root(true)
.header:not([data-darkmode])
root(false)
2018-02-14 15:32:13 +00:00
</style>