| 
									
										
										
										
											2021-05-22 21:04:19 -08:00
										 |  |  | <template> | 
					
						
							| 
									
										
										
										
											2021-05-24 10:12:46 -08:00
										 |  |  |   <v-img | 
					
						
							|  |  |  |     v-if="!fallBackImage" | 
					
						
							| 
									
										
										
										
											2021-08-01 19:24:47 -08:00
										 |  |  |     :height="height" | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |     cover | 
					
						
							| 
									
										
										
										
											2024-08-23 20:26:12 +02:00
										 |  |  |     min-height="125" | 
					
						
							|  |  |  |     max-height="fill-height" | 
					
						
							| 
									
										
										
										
											2022-02-13 12:23:42 -09:00
										 |  |  |     :src="getImage(recipeId)" | 
					
						
							| 
									
										
										
										
											2021-08-01 19:24:47 -08:00
										 |  |  |     @click="$emit('click')" | 
					
						
							| 
									
										
										
										
											2021-05-24 10:12:46 -08:00
										 |  |  |     @load="fallBackImage = false" | 
					
						
							|  |  |  |     @error="fallBackImage = true" | 
					
						
							|  |  |  |   > | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |     <slot /> | 
					
						
							| 
									
										
										
										
											2021-05-24 10:12:46 -08:00
										 |  |  |   </v-img> | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |   <div | 
					
						
							|  |  |  |     v-else | 
					
						
							|  |  |  |     class="icon-slot" | 
					
						
							|  |  |  |     @click="$emit('click')" | 
					
						
							|  |  |  |   > | 
					
						
							|  |  |  |     <v-icon | 
					
						
							|  |  |  |       color="primary" | 
					
						
							|  |  |  |       class="icon-position" | 
					
						
							|  |  |  |       :size="iconSize" | 
					
						
							|  |  |  |     > | 
					
						
							| 
									
										
										
										
											2021-05-24 10:12:46 -08:00
										 |  |  |       {{ $globals.icons.primary }} | 
					
						
							|  |  |  |     </v-icon> | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |     <slot /> | 
					
						
							| 
									
										
										
										
											2021-05-22 21:04:19 -08:00
										 |  |  |   </div> | 
					
						
							|  |  |  | </template> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-09 07:15:23 +01:00
										 |  |  | <script lang="ts"> | 
					
						
							| 
									
										
										
										
											2021-11-06 11:28:47 -08:00
										 |  |  | import { useStaticRoutes, useUserApi } from "~/composables/api"; | 
					
						
							| 
									
										
										
										
											2022-01-09 07:15:23 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  | export default defineNuxtComponent({ | 
					
						
							| 
									
										
										
										
											2021-05-22 21:04:19 -08:00
										 |  |  |   props: { | 
					
						
							|  |  |  |     tiny: { | 
					
						
							|  |  |  |       type: Boolean, | 
					
						
							|  |  |  |       default: null, | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     small: { | 
					
						
							|  |  |  |       type: Boolean, | 
					
						
							|  |  |  |       default: null, | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     large: { | 
					
						
							|  |  |  |       type: Boolean, | 
					
						
							|  |  |  |       default: null, | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     iconSize: { | 
					
						
							| 
									
										
										
										
											2021-08-01 19:24:47 -08:00
										 |  |  |       type: [Number, String], | 
					
						
							| 
									
										
										
										
											2021-05-22 21:04:19 -08:00
										 |  |  |       default: 100, | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     slug: { | 
					
						
							| 
									
										
										
										
											2021-08-01 19:24:47 -08:00
										 |  |  |       type: String, | 
					
						
							| 
									
										
										
										
											2021-05-22 21:04:19 -08:00
										 |  |  |       default: null, | 
					
						
							|  |  |  |     }, | 
					
						
							| 
									
										
										
										
											2022-02-13 12:23:42 -09:00
										 |  |  |     recipeId: { | 
					
						
							|  |  |  |       type: String, | 
					
						
							|  |  |  |       required: true, | 
					
						
							|  |  |  |     }, | 
					
						
							| 
									
										
										
										
											2021-05-23 15:05:39 -08:00
										 |  |  |     imageVersion: { | 
					
						
							| 
									
										
										
										
											2021-08-01 19:24:47 -08:00
										 |  |  |       type: String, | 
					
						
							| 
									
										
										
										
											2021-05-23 15:05:39 -08:00
										 |  |  |       default: null, | 
					
						
							|  |  |  |     }, | 
					
						
							| 
									
										
										
										
											2021-05-22 21:04:19 -08:00
										 |  |  |     height: { | 
					
						
							| 
									
										
										
										
											2024-08-23 20:26:12 +02:00
										 |  |  |       type: [Number, String], | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |       default: "100%", | 
					
						
							| 
									
										
										
										
											2021-05-22 21:04:19 -08:00
										 |  |  |     }, | 
					
						
							|  |  |  |   }, | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |   emits: ["click"], | 
					
						
							| 
									
										
										
										
											2022-01-09 07:15:23 +01:00
										 |  |  |   setup(props) { | 
					
						
							| 
									
										
										
										
											2021-11-06 11:28:47 -08:00
										 |  |  |     const api = useUserApi(); | 
					
						
							| 
									
										
										
										
											2021-08-01 19:24:47 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-09 16:19:23 -08:00
										 |  |  |     const { recipeImage, recipeSmallImage, recipeTinyImage } = useStaticRoutes(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-09 07:15:23 +01:00
										 |  |  |     const fallBackImage = ref(false); | 
					
						
							|  |  |  |     const imageSize = computed(() => { | 
					
						
							|  |  |  |       if (props.tiny) return "tiny"; | 
					
						
							|  |  |  |       if (props.small) return "small"; | 
					
						
							|  |  |  |       if (props.large) return "large"; | 
					
						
							| 
									
										
										
										
											2021-05-22 21:04:19 -08:00
										 |  |  |       return "large"; | 
					
						
							| 
									
										
										
										
											2022-01-09 07:15:23 +01:00
										 |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-13 12:23:42 -09:00
										 |  |  |     watch( | 
					
						
							|  |  |  |       () => props.recipeId, | 
					
						
							|  |  |  |       () => { | 
					
						
							|  |  |  |         fallBackImage.value = false; | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |       }, | 
					
						
							| 
									
										
										
										
											2022-02-13 12:23:42 -09:00
										 |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function getImage(recipeId: string) { | 
					
						
							| 
									
										
										
										
											2022-01-09 07:15:23 +01:00
										 |  |  |       switch (imageSize.value) { | 
					
						
							| 
									
										
										
										
											2021-05-22 21:04:19 -08:00
										 |  |  |         case "tiny": | 
					
						
							| 
									
										
										
										
											2022-02-13 12:23:42 -09:00
										 |  |  |           return recipeTinyImage(recipeId, props.imageVersion); | 
					
						
							| 
									
										
										
										
											2021-05-22 21:04:19 -08:00
										 |  |  |         case "small": | 
					
						
							| 
									
										
										
										
											2022-02-13 12:23:42 -09:00
										 |  |  |           return recipeSmallImage(recipeId, props.imageVersion); | 
					
						
							| 
									
										
										
										
											2021-05-22 21:04:19 -08:00
										 |  |  |         case "large": | 
					
						
							| 
									
										
										
										
											2022-02-13 12:23:42 -09:00
										 |  |  |           return recipeImage(recipeId, props.imageVersion); | 
					
						
							| 
									
										
										
										
											2021-05-22 21:04:19 -08:00
										 |  |  |       } | 
					
						
							| 
									
										
										
										
											2022-01-09 07:15:23 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return { | 
					
						
							|  |  |  |       api, | 
					
						
							|  |  |  |       fallBackImage, | 
					
						
							|  |  |  |       imageSize, | 
					
						
							|  |  |  |       getImage, | 
					
						
							|  |  |  |     }; | 
					
						
							| 
									
										
										
										
											2021-05-22 21:04:19 -08:00
										 |  |  |   }, | 
					
						
							| 
									
										
										
										
											2022-01-09 07:15:23 +01:00
										 |  |  | }); | 
					
						
							| 
									
										
										
										
											2021-05-22 21:04:19 -08:00
										 |  |  | </script> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <style scoped> | 
					
						
							|  |  |  | .icon-slot { | 
					
						
							|  |  |  |   position: relative; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | .icon-slot > div { | 
					
						
							| 
									
										
										
										
											2021-07-09 14:33:23 -08:00
										 |  |  |   top: 0; | 
					
						
							| 
									
										
										
										
											2021-05-22 21:04:19 -08:00
										 |  |  |   position: absolute; | 
					
						
							|  |  |  |   z-index: 1; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | .icon-position { | 
					
						
							|  |  |  |   opacity: 0.8; | 
					
						
							|  |  |  |   display: flex !important; | 
					
						
							|  |  |  |   position: relative; | 
					
						
							|  |  |  |   margin-left: auto !important; | 
					
						
							|  |  |  |   margin-right: auto !important; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-01-09 07:15:23 +01:00
										 |  |  | </style> |