| 
									
										
										
										
											2022-10-21 20:01:08 -08:00
										 |  |  | <template> | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |   <div | 
					
						
							|  |  |  |     ref="el" | 
					
						
							|  |  |  |     :class="isOverDropZone ? 'over' : ''" | 
					
						
							|  |  |  |   > | 
					
						
							|  |  |  |     <div | 
					
						
							|  |  |  |       v-if="isOverDropZone" | 
					
						
							|  |  |  |       class="overlay" | 
					
						
							|  |  |  |     /> | 
					
						
							|  |  |  |     <div | 
					
						
							|  |  |  |       v-if="isOverDropZone" | 
					
						
							|  |  |  |       class="absolute text-container" | 
					
						
							|  |  |  |     > | 
					
						
							|  |  |  |       <p class="text-center drop-text"> | 
					
						
							|  |  |  |         {{ $t("recipe.drop-image") }} | 
					
						
							|  |  |  |       </p> | 
					
						
							| 
									
										
										
										
											2022-10-21 20:01:08 -08:00
										 |  |  |     </div> | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |     <slot /> | 
					
						
							| 
									
										
										
										
											2022-10-21 20:01:08 -08:00
										 |  |  |   </div> | 
					
						
							|  |  |  | </template> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <script lang="ts"> | 
					
						
							|  |  |  | import { useDropZone } from "@vueuse/core"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  | export default defineNuxtComponent({ | 
					
						
							|  |  |  |   emits: ["drop"], | 
					
						
							| 
									
										
										
										
											2022-10-21 20:01:08 -08:00
										 |  |  |   setup(_, context) { | 
					
						
							|  |  |  |     const el = ref<HTMLDivElement>(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |     function onDrop(files: File[] | null) { | 
					
						
							|  |  |  |       if (files) { | 
					
						
							|  |  |  |         context.emit("drop", files); | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2022-10-21 20:01:08 -08:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |     const { isOverDropZone } = useDropZone(el, files => onDrop(files)); | 
					
						
							| 
									
										
										
										
											2022-10-21 20:01:08 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     return { el, isOverDropZone }; | 
					
						
							|  |  |  |   }, | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | </script> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <style lang="css"> | 
					
						
							|  |  |  | .over { | 
					
						
							|  |  |  |   background-color: #f0f0f0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | .overlay { | 
					
						
							|  |  |  |   position: absolute; | 
					
						
							|  |  |  |   filter: blur(2px); | 
					
						
							|  |  |  |   top: 0; | 
					
						
							|  |  |  |   left: 0; | 
					
						
							|  |  |  |   right: 0; | 
					
						
							|  |  |  |   bottom: 0; | 
					
						
							|  |  |  |   background-color: rgba(0, 0, 0, 0.309); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | .text-container { | 
					
						
							|  |  |  |   z-index: 10; | 
					
						
							|  |  |  |   position: absolute; | 
					
						
							|  |  |  |   top: 0; | 
					
						
							|  |  |  |   left: 0; | 
					
						
							|  |  |  |   right: 0; | 
					
						
							|  |  |  |   bottom: 0; | 
					
						
							|  |  |  |   display: flex; | 
					
						
							|  |  |  |   justify-content: center; | 
					
						
							|  |  |  |   align-items: center; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | .drop-text { | 
					
						
							|  |  |  |   color: white; | 
					
						
							|  |  |  |   font-size: 1.5rem; | 
					
						
							|  |  |  |   font-weight: bold; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | </style> |