| 
									
										
										
										
											2021-01-17 22:22:54 -09:00
										 |  |  | <template> | 
					
						
							| 
									
										
										
										
											2021-05-05 14:08:13 -08:00
										 |  |  |   <div> | 
					
						
							| 
									
										
										
										
											2021-08-01 19:24:47 -08:00
										 |  |  |     <v-chip v-for="(time, index) in allTimes" :key="index" label color="accent custom-transparent" class="ma-1"> | 
					
						
							| 
									
										
										
										
											2021-05-05 14:08:13 -08:00
										 |  |  |       <v-icon left> | 
					
						
							| 
									
										
										
										
											2021-06-16 18:55:32 -08:00
										 |  |  |         {{ $globals.icons.clockOutline }} | 
					
						
							| 
									
										
										
										
											2021-05-05 14:08:13 -08:00
										 |  |  |       </v-icon> | 
					
						
							|  |  |  |       {{ time.name }} | | 
					
						
							|  |  |  |       {{ time.value }} | 
					
						
							|  |  |  |     </v-chip> | 
					
						
							|  |  |  |   </div> | 
					
						
							| 
									
										
										
										
											2021-01-17 22:22:54 -09:00
										 |  |  | </template> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-09 07:15:23 +01:00
										 |  |  | <script lang="ts"> | 
					
						
							|  |  |  | import { computed, defineComponent, useContext } from "@nuxtjs/composition-api"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export default defineComponent({ | 
					
						
							| 
									
										
										
										
											2021-01-17 22:22:54 -09:00
										 |  |  |   props: { | 
					
						
							| 
									
										
										
										
											2021-08-02 22:15:11 -08:00
										 |  |  |     prepTime: { | 
					
						
							|  |  |  |       type: String, | 
					
						
							|  |  |  |       default: null, | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     totalTime: { | 
					
						
							|  |  |  |       type: String, | 
					
						
							|  |  |  |       default: null, | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     performTime: { | 
					
						
							|  |  |  |       type: String, | 
					
						
							|  |  |  |       default: null, | 
					
						
							|  |  |  |     }, | 
					
						
							| 
									
										
										
										
											2021-01-17 22:22:54 -09:00
										 |  |  |   }, | 
					
						
							| 
									
										
										
										
											2022-01-09 07:15:23 +01:00
										 |  |  |   setup(props) { | 
					
						
							|  |  |  |     const { i18n } = useContext(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function isEmpty(str: string | null) { | 
					
						
							| 
									
										
										
										
											2021-04-21 21:52:12 -08:00
										 |  |  |       return !str || str.length === 0; | 
					
						
							| 
									
										
										
										
											2022-01-09 07:15:23 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const showCards = computed(() => { | 
					
						
							|  |  |  |       return [props.prepTime, props.totalTime, props.performTime].some((x) => !isEmpty(x)); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const validateTotalTime = computed(() => { | 
					
						
							|  |  |  |       return !isEmpty(props.totalTime) ? { name: i18n.t("recipe.total-time"), value: props.totalTime } : null; | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const validatePrepTime = computed(() => { | 
					
						
							|  |  |  |       return !isEmpty(props.prepTime) ? { name: i18n.t("recipe.prep-time"), value: props.prepTime } : null; | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const validatePerformTime = computed(() => { | 
					
						
							|  |  |  |       return !isEmpty(props.performTime) ? { name: i18n.t("recipe.perform-time"), value: props.performTime } : null; | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const allTimes = computed(() => { | 
					
						
							|  |  |  |       return [validateTotalTime.value, validatePrepTime.value, validatePerformTime.value].filter((x) => x !== null); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return { | 
					
						
							|  |  |  |       showCards, | 
					
						
							|  |  |  |       allTimes, | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-01-17 22:22:54 -09:00
										 |  |  |   }, | 
					
						
							| 
									
										
										
										
											2022-01-09 07:15:23 +01:00
										 |  |  | }); | 
					
						
							| 
									
										
										
										
											2021-01-17 22:22:54 -09:00
										 |  |  | </script> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <style scoped> | 
					
						
							| 
									
										
										
										
											2021-04-21 21:52:12 -08:00
										 |  |  | .time-card-flex { | 
					
						
							|  |  |  |   width: fit-content; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2021-01-17 22:22:54 -09:00
										 |  |  | .custom-transparent { | 
					
						
							|  |  |  |   opacity: 0.7; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2021-05-01 20:46:02 -08:00
										 |  |  | </style> |