Merge pull request #2611 from tamaina/improve-media

メディアリストにバナータイプのメディアビューを追加
This commit is contained in:
syuilo 2018-09-16 04:28:07 +09:00 committed by GitHub
commit 49a2b5efe8
6 changed files with 166 additions and 56 deletions

View file

@ -278,6 +278,10 @@ common/views/components/connect-failed.troubleshooter.vue:
flush: "キャッシュの削除"
set-version: "バージョン指定"
common/views/components/media-banner.vue:
sensitive: "閲覧注意"
click-to-show: "クリックして表示"
common/views/components/cw-button.vue:
hide: "隠す"
show: "もっと見る"

View file

@ -0,0 +1,89 @@
<template>
<div class="mk-media-banner">
<div class="sensitive" v-if="media.isSensitive && hide" @click="hide = false">
<span class="icon">%fa:exclamation-triangle%</span>
<b>%i18n:@sensitive%</b>
<span>%i18n:@click-to-show%</span>
</div>
<div class="audio" v-else-if="media.type.startsWith('audio')">
<audio class="audio"
:src="media.url"
:title="media.name"
controls
ref="audio"
preload="metadata" />
</div>
<a class="download" v-else
:href="media.url"
:title="media.name"
:download="media.name"
>
<span class="icon">%fa:download%</span>
<b>{{ media.name }}</b>
</a>
</div>
</template>
<script lang="ts">
import Vue from 'vue';
export default Vue.extend({
props: {
media: {
type: Object,
required: true
},
hide: {
type: Boolean,
default: true
}
}
})
</script>
<style lang="stylus" scoped>
root(isDark)
width 100%
border-radius 4px
margin-top 4px
overflow hidden
> .download,
> .sensitive
display flex
align-items center
font-size 12px
padding 8px 12px
white-space nowrap
> *
display block
> b
overflow hidden
text-overflow ellipsis
> *:not(:last-child)
margin-right .2em
> .icon
font-size 1.6em
> .download
background isDark ? #21242d : #f7f7f7
> .sensitive
background #111
color #fff
> .audio
.audio
display block
width 100%
.mk-media-banner[data-darkmode]
root(true)
.mk-media-banner:not([data-darkmode])
root(false)
</style>

View file

@ -1,18 +1,27 @@
<template>
<div class="mk-media-list">
<div :data-count="mediaList.length" ref="grid">
<template v-for="media in mediaList">
<mk-media-video :video="media" :key="media.id" v-if="media.type.startsWith('video')" :inline-playable="mediaList.length === 1"/>
<mk-media-image :image="media" :key="media.id" v-else :raw="raw"/>
<template v-for="media in mediaList.filter(media => !previewable(media))">
<x-banner :media="media" :key="media.id"/>
</template>
<div v-if="mediaList.filter(media => previewable(media)).length > 0" class="gird-container">
<div :data-count="mediaList.filter(media => previewable(media)).length" ref="grid">
<template v-for="media in mediaList">
<mk-media-video :video="media" :key="media.id" v-if="media.type.startsWith('video')"/>
<mk-media-image :image="media" :key="media.id" v-else-if="media.type.startsWith('image')" :raw="raw"/>
</template>
</div>
</div>
</div>
</template>
<script lang="ts">
import Vue from 'vue';
import XBanner from './media-banner.vue';
export default Vue.extend({
components: {
XBanner
},
props: {
mediaList: {
required: true
@ -22,15 +31,25 @@ export default Vue.extend({
}
},
mounted() {
// for Safari bug
//#region for Safari bug
if (this.$refs.grid) {
this.$refs.grid.style.height = this.$refs.grid.clientHeight ? `${this.$refs.grid.clientHeight}px` : '128px';
}
//#endregion
},
methods: {
previewable(file) {
return file.type.startsWith('video') || file.type.startsWith('image');
}
}
});
</script>
<style lang="stylus" scoped>
.mk-media-list
> .gird-container
width 100%
margin-top 4px
&:before
content ''

View file

@ -89,7 +89,7 @@ export default Vue.extend({
text-align center
font-size 12px
> b
> *
display block
</style>

View file

@ -79,7 +79,6 @@ export default Vue.extend({
justify-content center
align-items center
font-size 3.5em
cursor zoom-in
overflow hidden
background-position center
@ -101,5 +100,4 @@ export default Vue.extend({
> b
display block
</style>

View file

@ -65,7 +65,7 @@ export default Vue.extend({
text-align center
font-size 12px
> b
> *
display block
</style>