Adjusted the number of elements displayed for differing screen widths through css. Now uses the new movie popover vue prototype variables instead of an attached eventhub

This commit is contained in:
2019-06-03 23:08:58 +02:00
parent aada5fc2c5
commit fcc56bf103

View File

@@ -1,6 +1,7 @@
<template> <template>
<li class="movies-item"> <li class="movies-item" :class="{'shortList': shortList}">
<a class="movies-item__link" :class="{'no-image': noImage}" href="#" @click.prevent="openMoviePopup(movie.id, movie.type, true)"> <a class="movies-item__link" :class="{'no-image': noImage}" @click.prevent="openMoviePopup(movie.id, movie.type)">
<figure class="movies-item__poster"> <figure class="movies-item__poster">
<img v-if="!noImage" class="movies-item__img" src="~assets/placeholder.png" v-img="poster()" alt=""> <img v-if="!noImage" class="movies-item__img" src="~assets/placeholder.png" v-img="poster()" alt="">
<img v-if="noImage" class="movies-item__img is-loaded" src="~assets/no-image.png" alt=""> <img v-if="noImage" class="movies-item__img is-loaded" src="~assets/no-image.png" alt="">
@@ -17,7 +18,7 @@
import img from '../directives/v-image.js' import img from '../directives/v-image.js'
export default { export default {
props: ['movie'], props: ['movie', 'shortList'],
directives: { directives: {
img: img img: img
}, },
@@ -28,15 +29,14 @@ export default {
}, },
methods: { methods: {
poster() { poster() {
if(this.movie.poster_path){ if(this.movie.poster){
return 'https://image.tmdb.org/t/p/w300' + this.movie.poster_path; return 'https://image.tmdb.org/t/p/w500' + this.movie.poster;
} else { } else {
this.noImage = true; this.noImage = true;
} }
}, },
openMoviePopup(id, type, event){ openMoviePopup(id, type){
console.log('open:', id, type, event) this.$popup.open(id, type)
eventHub.$emit('openMoviePopup', id, type, event);
} }
} }
} }
@@ -45,7 +45,50 @@ export default {
<style lang="scss"> <style lang="scss">
@import "./src/scss/variables"; @import "./src/scss/variables";
@import "./src/scss/media-queries"; @import "./src/scss/media-queries";
.movies-item{ .movies-item {
padding: 10px;
width: 50%;
@include tablet-min{
padding: 15px;
}
@include tablet-landscape-min{
padding: 20px;
width: 25%;
}
@include desktop-min{
padding: 30px;
width: 20%;
}
@include desktop-lg-min{
padding: 20px;
width: 16.5%;
}
&.shortList {
display: none;
&:nth-child(-n+6) { // show first 6
display: block;
}
@include tablet-landscape-min{
&:nth-child(-n+8) { // show first 8
display: block;
}
}
@include desktop-min{
&:nth-child(-n+10) { // show first 10
display: block;
}
}
@include desktop-lg-min{
display: block; // show all
}
}
&__link{ &__link{
text-decoration: none; text-decoration: none;
color: rgba($c-dark, 0.5); color: rgba($c-dark, 0.5);
@@ -55,7 +98,7 @@ export default {
padding-top: 15px; padding-top: 15px;
} }
&__poster{ &__poster{
transition: transform 0.5s ease, box-shadow 0.5s ease; transition: transform 0.5s ease, box-shadow 0.3s ease;
transform: translateZ(0); transform: translateZ(0);
background: $c-white; background: $c-white;
} }