Procházet zdrojové kódy

:sparkles: using card component in list pages

tags/0.9.0
j před 4 roky
rodič
revize
0b23c8a389

+ 48
- 0
vue-theme/src/components/card.vue Zobrazit soubor

@@ -0,0 +1,48 @@
1
+<template lang="pug">
2
+.card(v-if="content")
3
+    router-link(:to="`/${type}`")
4
+        p.t-up {{type}}
5
+    .card--info(:class="{ 'wide': wide }")
6
+        router-link(:to="`/${type}/${content.slug}`")
7
+            featured-image(:post="content")
8
+        .f-col.w-max
9
+            router-link(:to="`/${type}/${content.slug}`")
10
+                h1.t-up.t-cntr {{ content.title }}
11
+            p {{ content.excerpt }}
12
+</template>
13
+
14
+<script>
15
+import featuredImage from '@/components/featured-image'
16
+export default {
17
+    components: { featuredImage },
18
+    props: ['type', 'content', 'wide']
19
+}
20
+</script>
21
+
22
+<style lang="postcss">
23
+@import '../sss/variables.sss'
24
+@import '../sss/theme.sss'
25
+.card
26
+    padding: $ms--3 $ms--1
27
+    overflow: hidden
28
+    text-overflow: clip
29
+    &--info
30
+        justify-content: center
31
+    img
32
+        width: 100%
33
+        height: auto
34
+    h1, h2, h3, p
35
+        padding: 0
36
+        margin: 0
37
+    h1
38
+        font-size: $ms-1
39
+
40
+@media (min-width: $medium)
41
+    .card
42
+        &--info 
43
+            justify-content: center
44
+            > a:first-of-type
45
+                width: 100%
46
+        .wide
47
+            display: flex    
48
+</style>

+ 5
- 2
vue-theme/src/components/featured-image.vue Zobrazit soubor

@@ -13,11 +13,11 @@ import { ytThumbnail } from '@/utils/helpers'
13 13
 
14 14
 export default {
15 15
     props: {
16
-        post: { required:true }
16
+        post: { required: true }
17 17
     },
18 18
     computed: {
19 19
         featured() {
20
-            return this.post.featuredImage ? this.post.featuredImage : null
20
+            return this.post.featured ? this.post.featured : null
21 21
         },
22 22
         hero() {
23 23
             return this.post.hero && JSON.parse(this.post.hero) ? JSON.parse(this.post.hero) : null
@@ -27,6 +27,9 @@ export default {
27 27
         getThumbnailFromYt(url) {
28 28
             return ytThumbnail(url, 'medium')
29 29
         }
30
+    },
31
+    created() {
32
+        console.log(this.post)
30 33
     }
31 34
 }
32 35
 </script>

+ 3
- 8
vue-theme/src/pages/list.vue Zobrazit soubor

@@ -15,13 +15,7 @@
15 15
 
16 16
         .posts(v-if="posts && loaded" :class="{ 'is-grid': grid }")
17 17
             section(v-for="post in posts" :key="post.slug").shadow.post
18
-                header
19
-                    router-link(:to="`/${type}/${post.slug}`")
20
-                        featured-image(:post="post")
21
-                        h2.t-up {{ post.title }}
22
-                article
23
-                    h4 {{ post.date }}
24
-                    p {{ post.excerpt }}
18
+                card(:content="post" :type="type")
25 19
 
26 20
         footer
27 21
             p {{ `${type} count: ${Object.values(posts).length}` }}
@@ -43,13 +37,14 @@
43 37
 
44 38
 <script>
45 39
 import featuredImage from '@/components/featured-image'
40
+import card from '@/components/card'
46 41
 import sidebar from '@/components/sidebars/sidebar'
47 42
 import { postTypeGetters, scrollTop } from './mixin-post-types'
48 43
 
49 44
 import { convertTitleCase, typeFromRoute, sortTypes } from '@/utils/helpers'
50 45
 
51 46
 export default {
52
-    components: { sidebar, featuredImage },
47
+    components: { sidebar, featuredImage, card },
53 48
     props: {
54 49
         sidebar: { type: Boolean },
55 50
         grid: { type: Boolean },

Načítá se…
Zrušit
Uložit