Ver código fonte

:bug: lots of hero fixes and fail-overs

tags/0.9.0
j 4 anos atrás
pai
commit
05d22fdd48

+ 21
- 3
vue-theme/src/components/hero.vue Ver arquivo

9
         ).embedded
9
         ).embedded
10
         .blank.f-col(v-else)
10
         .blank.f-col(v-else)
11
             h3(v-if="heroText") {{ heroText }}
11
             h3(v-if="heroText") {{ heroText }}
12
+            img(:src="getThumbnailFromYt(showHero)" alt="hero alt image")
12
             button(v-if="showPlaybutton" @click="isPlaying = true") play
13
             button(v-if="showPlaybutton" @click="isPlaying = true") play
14
+    .hero--image(v-else-if="heroType === 'image'")
15
+        .hero--image--overlay.f-col
16
+            div(v-html="heroText")
17
+        img(:src="showHero" alt="hero alt image")
13
     .hero--image(v-else)
18
     .hero--image(v-else)
14
-        img(:src="showHero" alt="hero image")
19
+        .hero--image--overlay.f-col
20
+            div(v-html="heroText")
21
+
15
 </template>
22
 </template>
16
 
23
 
17
 <script>
24
 <script>
25
+import { ytThumbnail } from '@/utils/helpers'
18
 import { mapState } from 'vuex'
26
 import { mapState } from 'vuex'
19
 
27
 
20
 export default {
28
 export default {
39
     methods: {
47
     methods: {
40
         onResize() {
48
         onResize() {
41
             this.heroHeight = this.$el.offsetWidth / 1.8
49
             this.heroHeight = this.$el.offsetWidth / 1.8
50
+        },
51
+        getThumbnailFromYt(url) {
52
+            return ytThumbnail(url, 'max')
42
         }
53
         }
43
     },
54
     },
44
     mounted() {
55
     mounted() {
45
         this.heroHeight = this.$el.offsetWidth / 1.8
56
         this.heroHeight = this.$el.offsetWidth / 1.8
46
-        this.$nextTick(() => { window.addEventListener('resize', this.onResize) })
57
+        this.$nextTick(() => { 
58
+            window.addEventListener('resize', this.onResize) })
47
     },
59
     },
48
     watch: {
60
     watch: {
49
         $route() {
61
         $route() {
70
     min-height: 35%
82
     min-height: 35%
71
     width: 100%
83
     width: 100%
72
     &--image
84
     &--image
85
+        width: 100%
73
         > img
86
         > img
74
-            max-width: 100%
87
+            width: 100%
88
+        &--overlay
89
+            color: #ffffff
90
+            position: absolute
91
+            top: 30%
92
+            width: 100%
75
     .embedded
93
     .embedded
76
         height: 100%
94
         height: 100%
77
         width: 100%
95
         width: 100%

+ 5
- 2
vue-theme/src/pages/list.vue Ver arquivo

77
              * so if a sortBy is specified we return it sorted or
77
              * so if a sortBy is specified we return it sorted or
78
              * we fail over to sorted by date
78
              * we fail over to sorted by date
79
              */
79
              */
80
-            console.log(this.sortBy)
81
             return this.sortBy ? this[`all${type}`] : sortedByRecent
80
             return this.sortBy ? this[`all${type}`] : sortedByRecent
82
         },
81
         },
83
     },
82
     },
104
             }
103
             }
105
             const page = this.allPages[type]
104
             const page = this.allPages[type]
106
             if(!page) return
105
             if(!page) return
106
+            
107
             let json = { url: page.featured, heroType: 'image' }
107
             let json = { url: page.featured, heroType: 'image' }
108
             if(page.hero && JSON.parse(page.hero) && JSON.parse(page.hero).url) {
108
             if(page.hero && JSON.parse(page.hero) && JSON.parse(page.hero).url) {
109
                 json = JSON.parse(page.hero)
109
                 json = JSON.parse(page.hero)
110
                 json.heroType = 'video'
110
                 json.heroType = 'video'
111
             }
111
             }
112
+            if(page && page.content) {
113
+                json.text = this.allPages[type].content
114
+            }
112
             this.$store.commit('SET_HERO', json)
115
             this.$store.commit('SET_HERO', json)
113
         },
116
         },
114
     },
117
     },
126
         console.log(`${type} already loaded?:`, this[`all${type}Loaded`])
129
         console.log(`${type} already loaded?:`, this[`all${type}Loaded`])
127
         
130
         
128
         this.checkAndSetHero(this.type)
131
         this.checkAndSetHero(this.type)
129
-        console.log(this.$store)
132
+        
130
         if(!this[`all${type}Loaded`]) this.getPosts()
133
         if(!this[`all${type}Loaded`]) this.getPosts()
131
     }
134
     }
132
 }
135
 }

+ 4
- 0
vue-theme/src/pages/single.vue Ver arquivo

145
                 json = JSON.parse(post.hero)
145
                 json = JSON.parse(post.hero)
146
                 json.heroType = 'video'
146
                 json.heroType = 'video'
147
             }
147
             }
148
+            // No featured or youTube
149
+            if(!json.url) {
150
+                json.heroType = null
151
+            }
148
             this.$store.commit('SET_HERO', json)
152
             this.$store.commit('SET_HERO', json)
149
         },
153
         },
150
         
154
         

+ 10
- 5
vue-theme/src/store/index.js Ver arquivo

35
         if (!hero) return
35
         if (!hero) return
36
 
36
 
37
         if (hero.url) {
37
         if (hero.url) {
38
-            state.hero.text = state.hero.url = hero.url
39
-            state.hero.type = hero.type
38
+            state.hero.text = hero.text
39
+            state.hero.url = hero.url
40
+            state.hero.type = hero.heroType
40
 
41
 
41
-            state.hero.playbutton = hero.type === 'video' ? true : false
42
+            state.hero.playbutton = hero.heroType === 'video' ? true : false
42
         } else {
43
         } else {
43
-            state.hero.text = hero
44
+            console.warn('No hero to set')
45
+            state.hero.url = hero.url
46
+            state.hero.type = hero.heroType
47
+            state.hero.text = ''
48
+            state.hero.playbutton = false
44
         }
49
         }
45
     },
50
     },
46
     CLEAR_HERO(state) {
51
     CLEAR_HERO(state) {
47
         state.hero = {
52
         state.hero = {
48
             url: null,
53
             url: null,
49
             type: null,
54
             type: null,
50
-            text: 'sample hero text',
55
+            text: '',
51
             playbutton: false,
56
             playbutton: false,
52
         }
57
         }
53
     },
58
     },

Carregando…
Cancelar
Salvar