about summary refs log tree commit diff
path: root/components/Posts/PostList/PurePostList.vue
blob: 210973ecb06343ba63f5aac3d6ffe45acdd55990 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<template>
  <div class="post-list">
    <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>
    <transition name="fade-in">
      <div v-if="posts && !loading" class="post-list-container">
        <post-link
          v-for="(post, index) in posts"
          :key="index"
          :route="post.route"
          :title="post.title"
          :description="post.description"
          :image="post.image"
        />
      </div>
    </transition>
  </div>
</template>

<script>
import PostLink from '../PostLink'

export default {
  name: 'PurePostList',
  components: { PostLink },
  props: {
    posts: {
      type: Array,
      required: true,
    },
    loading: {
      type: Boolean,
      required: false,
      default: () => false,
    },
  },
}
</script>

<style scoped>
.post-list {
  width: 100%;
  max-width: 900px;
  justify-content: center;
  margin: 0 auto;
}

.post-list-container {
  display: flex;
  flex-wrap: wrap;
  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% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.loading-post {
  background: #efefef;
  animation: loading 1.5s ease-in-out infinite;
  margin: 20px;
  flex-basis: 410px;
  width: 410px;
  height: 250px;
  text-align: left;
}

.no-posts {
  text-align: center;
}

@keyframes fade-in {
  0% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

.fade-in-enter-active {
  animation: fade-in 0.3s reverse;
}
</style>