| 
									
										
										
										
											2021-05-22 21:04:19 -08:00
										 |  |  | <template> | 
					
						
							| 
									
										
										
										
											2021-05-24 10:12:46 -08:00
										 |  |  |   <v-img | 
					
						
							|  |  |  |     @click="$emit('click')" | 
					
						
							|  |  |  |     :height="height" | 
					
						
							|  |  |  |     v-if="!fallBackImage" | 
					
						
							|  |  |  |     :src="getImage(slug)" | 
					
						
							|  |  |  |     @load="fallBackImage = false" | 
					
						
							|  |  |  |     @error="fallBackImage = true" | 
					
						
							|  |  |  |   > | 
					
						
							|  |  |  |     <slot> </slot> | 
					
						
							|  |  |  |   </v-img> | 
					
						
							|  |  |  |   <div class="icon-slot" v-else @click="$emit('click')"> | 
					
						
							|  |  |  |     <v-icon color="primary" class="icon-position" :size="iconSize"> | 
					
						
							|  |  |  |       {{ $globals.icons.primary }} | 
					
						
							|  |  |  |     </v-icon> | 
					
						
							| 
									
										
										
										
											2021-06-14 19:37:38 -08:00
										 |  |  |     <slot> </slot> | 
					
						
							| 
									
										
										
										
											2021-05-22 21:04:19 -08:00
										 |  |  |   </div> | 
					
						
							|  |  |  | </template> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <script> | 
					
						
							|  |  |  | import { api } from "@/api"; | 
					
						
							|  |  |  | export default { | 
					
						
							|  |  |  |   props: { | 
					
						
							|  |  |  |     tiny: { | 
					
						
							|  |  |  |       type: Boolean, | 
					
						
							|  |  |  |       default: null, | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     small: { | 
					
						
							|  |  |  |       type: Boolean, | 
					
						
							|  |  |  |       default: null, | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     large: { | 
					
						
							|  |  |  |       type: Boolean, | 
					
						
							|  |  |  |       default: null, | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     iconSize: { | 
					
						
							|  |  |  |       default: 100, | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     slug: { | 
					
						
							|  |  |  |       default: null, | 
					
						
							|  |  |  |     }, | 
					
						
							| 
									
										
										
										
											2021-05-23 15:05:39 -08:00
										 |  |  |     imageVersion: { | 
					
						
							|  |  |  |       default: null, | 
					
						
							|  |  |  |     }, | 
					
						
							| 
									
										
										
										
											2021-05-22 21:04:19 -08:00
										 |  |  |     height: { | 
					
						
							|  |  |  |       default: 200, | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |   }, | 
					
						
							|  |  |  |   computed: { | 
					
						
							|  |  |  |     imageSize() { | 
					
						
							|  |  |  |       if (this.tiny) return "tiny"; | 
					
						
							|  |  |  |       if (this.small) return "small"; | 
					
						
							|  |  |  |       if (this.large) return "large"; | 
					
						
							|  |  |  |       return "large"; | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |   }, | 
					
						
							|  |  |  |   watch: { | 
					
						
							|  |  |  |     slug() { | 
					
						
							|  |  |  |       this.fallBackImage = false; | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |   }, | 
					
						
							|  |  |  |   data() { | 
					
						
							|  |  |  |     return { | 
					
						
							|  |  |  |       fallBackImage: false, | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |   }, | 
					
						
							|  |  |  |   methods: { | 
					
						
							| 
									
										
										
										
											2021-05-23 15:05:39 -08:00
										 |  |  |     getImage(slug) { | 
					
						
							| 
									
										
										
										
											2021-05-22 21:04:19 -08:00
										 |  |  |       switch (this.imageSize) { | 
					
						
							|  |  |  |         case "tiny": | 
					
						
							| 
									
										
										
										
											2021-05-23 15:05:39 -08:00
										 |  |  |           return api.recipes.recipeTinyImage(slug, this.imageVersion); | 
					
						
							| 
									
										
										
										
											2021-05-22 21:04:19 -08:00
										 |  |  |         case "small": | 
					
						
							| 
									
										
										
										
											2021-05-23 15:05:39 -08:00
										 |  |  |           return api.recipes.recipeSmallImage(slug, this.imageVersion); | 
					
						
							| 
									
										
										
										
											2021-05-22 21:04:19 -08:00
										 |  |  |         case "large": | 
					
						
							| 
									
										
										
										
											2021-05-23 15:05:39 -08:00
										 |  |  |           return api.recipes.recipeImage(slug, this.imageVersion); | 
					
						
							| 
									
										
										
										
											2021-05-22 21:04:19 -08:00
										 |  |  |       } | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |   }, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | </script> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <style scoped> | 
					
						
							|  |  |  | .icon-slot { | 
					
						
							|  |  |  |   position: relative; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | .icon-slot > div { | 
					
						
							|  |  |  |   position: absolute; | 
					
						
							|  |  |  |   z-index: 1; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | .icon-position { | 
					
						
							|  |  |  |   opacity: 0.8; | 
					
						
							|  |  |  |   display: flex !important; | 
					
						
							|  |  |  |   position: relative; | 
					
						
							|  |  |  |   margin-left: auto !important; | 
					
						
							|  |  |  |   margin-right: auto !important; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | </style> |