2018-02-11 16:06:22 -08:00
|
|
|
<template>
|
2018-03-26 00:56:46 -07:00
|
|
|
<div class="mk-media-list">
|
|
|
|
<mk-media-image v-for="media in mediaList" ref="media" :image="media" :key="media.id"/>
|
2018-02-11 16:06:22 -08:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
|
|
|
|
|
|
|
export default Vue.extend({
|
2018-03-26 00:56:46 -07:00
|
|
|
props: ['mediaList'],
|
2018-02-11 16:06:22 -08:00
|
|
|
mounted() {
|
2018-03-26 00:56:46 -07:00
|
|
|
const tags = this.$refs.media as Vue[];
|
2018-02-11 16:06:22 -08:00
|
|
|
|
2018-03-26 00:56:46 -07:00
|
|
|
if (this.mediaList.length == 1) {
|
2018-02-12 16:27:57 -08:00
|
|
|
(this.$el.style as any).gridTemplateRows = '1fr';
|
2018-02-11 16:06:22 -08:00
|
|
|
|
2018-02-12 16:27:57 -08:00
|
|
|
(tags[0].$el.style as any).gridColumn = '1 / 2';
|
|
|
|
(tags[0].$el.style as any).gridRow = '1 / 2';
|
2018-03-26 00:56:46 -07:00
|
|
|
} else if (this.mediaList.length == 2) {
|
2018-02-12 16:27:57 -08:00
|
|
|
(this.$el.style as any).gridTemplateColumns = '1fr 1fr';
|
|
|
|
(this.$el.style as any).gridTemplateRows = '1fr';
|
2018-02-11 16:06:22 -08:00
|
|
|
|
2018-02-12 16:27:57 -08:00
|
|
|
(tags[0].$el.style as any).gridColumn = '1 / 2';
|
|
|
|
(tags[0].$el.style as any).gridRow = '1 / 2';
|
|
|
|
(tags[1].$el.style as any).gridColumn = '2 / 3';
|
|
|
|
(tags[1].$el.style as any).gridRow = '1 / 2';
|
2018-03-26 00:56:46 -07:00
|
|
|
} else if (this.mediaList.length == 3) {
|
2018-02-12 16:27:57 -08:00
|
|
|
(this.$el.style as any).gridTemplateColumns = '1fr 0.5fr';
|
|
|
|
(this.$el.style as any).gridTemplateRows = '1fr 1fr';
|
|
|
|
|
|
|
|
(tags[0].$el.style as any).gridColumn = '1 / 2';
|
|
|
|
(tags[0].$el.style as any).gridRow = '1 / 3';
|
|
|
|
(tags[1].$el.style as any).gridColumn = '2 / 3';
|
|
|
|
(tags[1].$el.style as any).gridRow = '1 / 2';
|
|
|
|
(tags[2].$el.style as any).gridColumn = '2 / 3';
|
|
|
|
(tags[2].$el.style as any).gridRow = '2 / 3';
|
2018-03-26 00:56:46 -07:00
|
|
|
} else if (this.mediaList.length == 4) {
|
2018-02-12 16:27:57 -08:00
|
|
|
(this.$el.style as any).gridTemplateColumns = '1fr 1fr';
|
|
|
|
(this.$el.style as any).gridTemplateRows = '1fr 1fr';
|
|
|
|
|
|
|
|
(tags[0].$el.style as any).gridColumn = '1 / 2';
|
|
|
|
(tags[0].$el.style as any).gridRow = '1 / 2';
|
|
|
|
(tags[1].$el.style as any).gridColumn = '2 / 3';
|
|
|
|
(tags[1].$el.style as any).gridRow = '1 / 2';
|
|
|
|
(tags[2].$el.style as any).gridColumn = '1 / 2';
|
|
|
|
(tags[2].$el.style as any).gridRow = '2 / 3';
|
|
|
|
(tags[3].$el.style as any).gridColumn = '2 / 3';
|
|
|
|
(tags[3].$el.style as any).gridRow = '2 / 3';
|
2018-02-11 16:06:22 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
2018-02-14 22:14:28 -08:00
|
|
|
|
|
|
|
<style lang="stylus" scoped>
|
2018-03-26 00:56:46 -07:00
|
|
|
.mk-media-list
|
2018-02-14 22:14:28 -08:00
|
|
|
display grid
|
|
|
|
grid-gap 4px
|
|
|
|
height 256px
|
|
|
|
|
|
|
|
@media (max-width 500px)
|
|
|
|
height 192px
|
|
|
|
</style>
|