Преглед изворни кода

:recycle: moved card to separate component

tags/0.9.0
j пре 4 година
родитељ
комит
822e7d2274
1 измењених фајлова са 25 додато и 84 уклоњено
  1. 25
    84
      vue-theme/src/pages/index.vue

+ 25
- 84
vue-theme/src/pages/index.vue Прегледај датотеку

@@ -6,64 +6,34 @@
6 6
             ul.flipped(:class="[`sticky-${Object.keys(allSticky).length}`]")
7 7
                 //- if sticky
8 8
                 li.shadow(v-for="sticky in allSticky")
9
-                    .card(v-if="sticky")
10
-                        router-link(:to="`/${sticky.type}`")
11
-                            p.t-up {{sticky.type}}
12
-                        .card--info
13
-                            router-link(:to="`/${sticky.type}/${sticky.slug}`")
14
-                                img.index(src="https://i1.wp.com/www.craftinamerica.org/wp-content/uploads/2020/09/20200210_133120-e1599254267307.jpg")
15
-                            .f-col.w-max
16
-                                router-link(:to="`/${sticky.type}/${sticky.slug}`")
17
-                                    h1.t-up.t-cntr {{ sticky.title }}
18
-                                p episode excerpt, Lorem ipsum dolor sit amet, consectetu
9
+                    card(:content="sticky" :type="`${sticky.type}s`")
19 10
 
20 11
         section
21 12
             ul
22 13
                 li.shadow(v-for="type in ['episodes', 'exhibitions', 'events', 'artists', 'posts']")
23
-                    .card(v-if="firstPostOfType(type)")
24
-                        router-link(:to="`/${type}`")
25
-                            p.t-up {{type}}
26
-                        router-link(:to="`/${type}/${firstPostOfType(type).slug}`")
27
-                            img.index(src="https://i1.wp.com/www.craftinamerica.org/wp-content/uploads/2020/09/20200210_133120-e1599254267307.jpg")
28
-                            h1.t-up.t-cntr {{ firstPostOfType(type).title }}
29
-                        p episode excerpt, Lorem ipsum dolor sit amet, consectetu
14
+                    card(:content="firstPostOfType(type)" :type="type")
30 15
 
31 16
         section.max
32 17
             ul.w-max
33 18
                 li.shadow(v-for="post in [randomPostOfType('artists')]")
34
-                    .card(v-if="post")
35
-                        router-link(:to="`/${'artists'}/${post.slug}`")
36
-                            p.t-up {{'artists'}}
37
-                        .card--info.f-row
38
-                            router-link(:to="`/artists/${post.slug}`")
39
-                                img.index(src="https://i1.wp.com/www.craftinamerica.org/wp-content/uploads/2020/09/20200210_133120-e1599254267307.jpg")
40
-                            .f-col.w-max
41
-                                router-link(:to="`/artists/${post.slug}`")
42
-                                    h1.t-up.t-cntr {{ post.title }}
43
-                                p episode excerpt, Lorem ipsum dolor sit amet, consectetu
19
+                    card(v-if="post" :content="post" :type="`${post.type}s`" :wide="true")
44 20
 
45 21
         section
46 22
             ul.flipped
47 23
                 li.shadow(v-for="type in ['episodes', 'exhibitions', 'events', 'artists', 'artists']")
48 24
                     .random--wrapper(v-for="post in [randomPostOfType(type)]")
49
-                        .card(v-if="post")
50
-                            router-link(:to="`/${type}`")
51
-                                p.t-up {{type}}
52
-                            router-link(:to="`/${type}/${post.slug}`")
53
-                                img.index(src="https://i1.wp.com/www.craftinamerica.org/wp-content/uploads/2020/09/20200210_133120-e1599254267307.jpg")
54
-                                h1.t-up.t-cntr {{ post.title }}
55
-                            p episode excerpt, Lorem ipsum dolor sit amet, consectetu
56
-                                
57
-
25
+                        card(:content="post" :type="type")
58 26
 </template>
59 27
 
60 28
 <script>
61 29
 import { postTypeGetters, scrollTop } from './mixin-post-types'
30
+import card from '@/components/card.vue'
62 31
 
63 32
 import { convertTitleCase, postTypes } from '@/utils/helpers'
64 33
 
65 34
 export default {
66 35
     mixins: [postTypeGetters, scrollTop],
36
+    components: { card },
67 37
     created() {
68 38
         // console.log(wp)
69 39
         postTypes.forEach(type => {
@@ -102,46 +72,29 @@ export default {
102 72
 <style lang="postcss">
103 73
 @import '../sss/variables.sss'
104 74
 @import '../sss/theme.sss'
105
-.page--index
106
-    > article
107
-        display: flex
108
-        justify-content: space-around
109
-        flex-direction: column
110
-        align-items: stretch
111
-        section
112
-            ul
113
-                list-style: none
114
-                .card
115
-                    padding: $ms--3 $ms--1
116
-                    overflow: hidden
117
-                    text-overflow: clip
118
-                    &--info
119
-                        justify-content: center
120
-                    img
121
-                        width: 100%
122
-                        height: auto
123
-                    h1, h2, h3, p
124
-                        padding: 0
125
-                        margin: 0
126
-                    h1
127
-                        font-size: $ms-1
128
-            &.max 
129
-                margin: 0
130
-                > ul
131
-                    grid-template-columns: 
132
-                        auto
133
-                    grid-template-rows: 
134
-                        auto
135
-                    > li > .card > img
136
-                        width: 100%
75
+.page--index > article
76
+    display: flex
77
+    justify-content: space-around
78
+    flex-direction: column
79
+    align-items: stretch
80
+    section
81
+        ul
82
+            list-style: none
83
+            li
84
+                margin: 0 0 $ms-0 0
85
+        &.max 
86
+            margin: 0
87
+            > ul
88
+                grid-template-columns: 
89
+                    auto
90
+                grid-template-rows: 
91
+                    auto
137 92
 @media (min-width: $medium)
138 93
     .page--index > article > section
139 94
         &.stickies
140 95
             margin: 0 0 2% 0
141 96
         &.max 
142 97
             margin: 3.5% 0 3% 0
143
-            > li .card--info > a:first-of-type
144
-                width: 100%
145 98
         ul
146 99
             display: grid
147 100
             grid-template-columns: 
@@ -150,6 +103,7 @@ export default {
150 103
                 48% 48%
151 104
             gap: 4% 1%
152 105
             li
106
+                margin: 0
153 107
                 min-height: 10em
154 108
                 background-color: purple
155 109
                 &:nth-of-type(1)
@@ -166,20 +120,7 @@ export default {
166 120
                     grid-row-start: 2
167 121
                 &:nth-of-type(5)
168 122
                     grid-column-start: 3
169
-                .card
170
-                    padding: $ms--3 $ms--1
171
-                    overflow: hidden
172
-                    text-overflow: clip
173
-                    &--info
174
-                        justify-content: center
175
-                    img
176
-                        width: 100%
177
-                        height: auto
178
-                    h1, h2, h3, p
179
-                        padding: 0
180
-                        margin: 0
181
-                    h1
182
-                        font-size: $ms-1
123
+
183 124
         &.stickies
184 125
             ul
185 126
                 &.flipped

Loading…
Откажи
Сачувај