about summary refs log tree commit diff
path: root/components/Posts/PostList
diff options
context:
space:
mode:
authorPatryk Niedźwiedziński <pniedzwiedzinski19@gmail.com>2020-01-27 17:53:19 +0100
committerGitHub <noreply@github.com>2020-01-27 17:53:19 +0100
commit4f5d597cf08a609e64741b0fdaf16577284249ba (patch)
tree6fe224aac15e46ed4f527b12b86fdac7ab376b29 /components/Posts/PostList
parent6a87f4d381bb43bea3a2b64ea930d4f46783e22c (diff)
parent3c2ac6715dfffc2eda38e014ed0b4986ccc7f75a (diff)
downloadpuszcza-4f5d597cf08a609e64741b0fdaf16577284249ba.tar.gz
puszcza-4f5d597cf08a609e64741b0fdaf16577284249ba.zip
Merge pull request #25 from 19pdh/develop
Camp & images
Diffstat (limited to 'components/Posts/PostList')
-rw-r--r--components/Posts/PostList/PurePostList.stories.js14
-rw-r--r--components/Posts/PostList/PurePostList.vue18
-rw-r--r--components/Posts/PostList/index.js7
-rw-r--r--components/Posts/PostList/parentMixin.js4
4 files changed, 29 insertions, 14 deletions
diff --git a/components/Posts/PostList/PurePostList.stories.js b/components/Posts/PostList/PurePostList.stories.js
index e2c39de..a159982 100644
--- a/components/Posts/PostList/PurePostList.stories.js
+++ b/components/Posts/PostList/PurePostList.stories.js
@@ -4,27 +4,33 @@ import { postLink } from '../PostLink.stories'
 
 import PurePostList from './PurePostList'
 
-export const posts = Array(5).fill(postLink)
+const postLinkNoImage = { ...postLink }
+delete postLinkNoImage['image']
+
+export const posts = [
+  ...Array(3).fill(postLinkNoImage),
+  ...Array(5).fill(postLink),
+]
 
 storiesOf('Posts/PurePostList', module)
   .add('default', () => {
     return {
       components: { PurePostList },
       template: `<pure-post-list :posts="posts"/>`,
-      data: () => ({ posts })
+      data: () => ({ posts }),
     }
   })
   .add('loading', () => {
     return {
       components: { PurePostList },
       template: `<pure-post-list :posts="posts" loading/>`,
-      data: () => ({ posts: [] })
+      data: () => ({ posts: [] }),
     }
   })
   .add('no posts', () => {
     return {
       components: { PurePostList },
       template: `<pure-post-list :posts="posts"/>`,
-      data: () => ({ posts: [] })
+      data: () => ({ posts: [] }),
     }
   })
diff --git a/components/Posts/PostList/PurePostList.vue b/components/Posts/PostList/PurePostList.vue
index ace069f..210973e 100644
--- a/components/Posts/PostList/PurePostList.vue
+++ b/components/Posts/PostList/PurePostList.vue
@@ -1,6 +1,6 @@
 <template>
   <div class="post-list">
-    <div v-if="loading" class="post-list-container">
+    <div v-if="loading" class="post-list-container loading">
       <div class="loading-post" v-for="(_, index) in 4" :key="index"></div>
     </div>
     <div v-else-if="!posts" class="no-posts">Brak wpisów</div>
@@ -12,6 +12,7 @@
           :route="post.route"
           :title="post.title"
           :description="post.description"
+          :image="post.image"
         />
       </div>
     </transition>
@@ -27,14 +28,14 @@ export default {
   props: {
     posts: {
       type: Array,
-      required: true
+      required: true,
     },
     loading: {
       type: Boolean,
       required: false,
-      default: () => false
-    }
-  }
+      default: () => false,
+    },
+  },
 }
 </script>
 
@@ -52,6 +53,13 @@ export default {
   justify-content: center;
 }
 
+@media (max-width: 920px) {
+  .post-list-container.loading div:nth-child(1),
+  .post-list-container.loading div:nth-child(2) {
+    display: none;
+  }
+}
+
 @keyframes loading {
   0%,
   100% {
diff --git a/components/Posts/PostList/index.js b/components/Posts/PostList/index.js
index 11d44ff..7e0b1f4 100644
--- a/components/Posts/PostList/index.js
+++ b/components/Posts/PostList/index.js
@@ -12,11 +12,12 @@ export const getPosts = async () => {
   }
 }
 
-export const parsePosts = posts =>
-  posts.map(post => ({
+export const parsePosts = (posts) =>
+  posts.map((post) => ({
     title: post.content.meta.title,
+    image: post.content.meta.image,
     description: post.content.description,
-    route: post.route
+    route: post.route,
   }))
 
 export default PostList
diff --git a/components/Posts/PostList/parentMixin.js b/components/Posts/PostList/parentMixin.js
index e5b06ed..801d51c 100644
--- a/components/Posts/PostList/parentMixin.js
+++ b/components/Posts/PostList/parentMixin.js
@@ -3,7 +3,7 @@ import { getPosts } from './index'
 export default {
   async asyncData() {
     return {
-      posts: await getPosts()
+      posts: await getPosts(),
     }
-  }
+  },
 }