{"version":3,"file":"ImageGradientUploader.CseAAeju.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/6RmUSzCzYu7p2OSDX1YV/f5nyXeHfVQe9ScOkAldi/ImageGradientUploader.js"],"sourcesContent":["// Image upload component with top and bottom gradient controls\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useState,useRef,startTransition}from\"react\";import{addPropertyControls,ControlType,Color}from\"framer\";/**\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n */export default function ImageGradientUploader(props){const{uploadedImage=\"https://framerusercontent.com/images/GfGkADagM4KEibNcIiRUWlfrR0.jpg\",topGradientColor,bottomGradientColor,topGradientOpacity,bottomGradientOpacity,topGradientHeight,bottomGradientHeight,borderRadius}=props;const[dragActive,setDragActive]=useState(false);const[currentImage,setCurrentImage]=useState(uploadedImage);const fileInputRef=useRef(null);const handleDrag=e=>{e.preventDefault();e.stopPropagation();if(e.type===\"dragenter\"||e.type===\"dragover\"){startTransition(()=>setDragActive(true));}else if(e.type===\"dragleave\"){startTransition(()=>setDragActive(false));}};const handleDrop=e=>{e.preventDefault();e.stopPropagation();startTransition(()=>setDragActive(false));if(e.dataTransfer.files&&e.dataTransfer.files[0]){handleFile(e.dataTransfer.files[0]);}};const handleChange=e=>{e.preventDefault();if(e.target.files&&e.target.files[0]){handleFile(e.target.files[0]);}};const handleFile=file=>{if(file.type.startsWith(\"image/\")){const reader=new FileReader;reader.onload=e=>{if(e.target?.result){startTransition(()=>setCurrentImage(e.target.result));}};reader.readAsDataURL(file);}};// Convert hex color to rgba with opacity\nconst hexToRgba=(hex,opacity)=>{const color=Color(hex);const rgb=Color.toRgb(color);return`rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${opacity})`;};const topGradientStyle=`linear-gradient(to bottom, ${hexToRgba(topGradientColor,topGradientOpacity)} 0%, transparent ${topGradientHeight}%)`;const bottomGradientStyle=`linear-gradient(to top, ${hexToRgba(bottomGradientColor,bottomGradientOpacity)} 0%, transparent ${bottomGradientHeight}%)`;return /*#__PURE__*/_jsxs(\"div\",{style:{position:\"relative\",width:\"100%\",height:\"100%\",borderRadius:borderRadius,overflow:\"hidden\",border:dragActive?\"2px dashed #0099FF\":\"2px dashed transparent\",transition:\"border-color 0.2s ease\"},onDragEnter:handleDrag,onDragLeave:handleDrag,onDragOver:handleDrag,onDrop:handleDrop,children:[/*#__PURE__*/_jsx(\"input\",{ref:fileInputRef,type:\"file\",accept:\"image/*\",onChange:handleChange,style:{display:\"none\"}}),/*#__PURE__*/_jsx(\"img\",{src:currentImage,alt:\"Uploaded image\",style:{width:\"100%\",height:\"100%\",objectFit:\"cover\",display:\"block\"}}),/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",top:0,left:0,right:0,bottom:0,background:`${topGradientStyle}, ${bottomGradientStyle}`,pointerEvents:\"none\"}}),dragActive&&/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",top:0,left:0,right:0,bottom:0,backgroundColor:\"rgba(0, 153, 255, 0.1)\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",color:\"#0099FF\",fontSize:\"16px\",fontWeight:\"600\",pointerEvents:\"none\"},children:\"Rilascia l'immagine qui\"})]});}addPropertyControls(ImageGradientUploader,{uploadedImage:{type:ControlType.File,allowedFileTypes:[\"jpg\",\"jpeg\",\"png\",\"gif\",\"webp\",\"svg\"],title:\"Upload Image\"},topGradientColor:{type:ControlType.Color,title:\"Top Gradient Color\",defaultValue:\"#000000\"},topGradientOpacity:{type:ControlType.Number,title:\"Top Opacity\",defaultValue:.5,min:0,max:1,step:.1},topGradientHeight:{type:ControlType.Number,title:\"Top Height\",defaultValue:30,min:0,max:100,step:5,unit:\"%\"},bottomGradientColor:{type:ControlType.Color,title:\"Bottom Gradient Color\",defaultValue:\"#000000\"},bottomGradientOpacity:{type:ControlType.Number,title:\"Bottom Opacity\",defaultValue:.5,min:0,max:1,step:.1},bottomGradientHeight:{type:ControlType.Number,title:\"Bottom Height\",defaultValue:30,min:0,max:100,step:5,unit:\"%\"},borderRadius:{type:ControlType.Number,title:\"Border Radius\",defaultValue:8,min:0,max:50,step:1,unit:\"px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ImageGradientUploader\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"fixed\",\"framerSupportedLayoutWidth\":\"fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ImageGradientUploader.map"],"mappings":"sMAIG,SAAwB,EAAsB,EAAM,CAAC,GAAK,CAAC,gBAAc,sEAAsE,mBAAiB,sBAAoB,qBAAmB,wBAAsB,oBAAkB,uBAAqB,gBAAc,EAAW,CAAC,EAAW,GAAeA,EAAS,EAAK,EAAO,CAAC,EAAa,GAAiBA,EAAS,CAAa,EAAQ,EAAaC,EAAO,IAAI,EAAQ,EAAW,GAAG,CAAC,EAAE,eAAe,EAAE,EAAE,gBAAgB,EAAK,EAAE,OAAO,aAAa,EAAE,OAAO,WAAY,MAAoB,EAAc,EAAI,CAAC,EAAW,EAAE,OAAO,aAAa,MAAoB,EAAc,EAAK,CAAC,CAAG,EAAQ,EAAW,GAAG,CAAC,EAAE,eAAe,EAAE,EAAE,gBAAgB,EAAE,MAAoB,EAAc,EAAK,CAAC,EAAK,EAAE,aAAa,OAAO,EAAE,aAAa,MAAM,IAAI,EAAW,EAAE,aAAa,MAAM,EAAE,CAAG,EAAQ,EAAa,GAAG,CAAC,EAAE,eAAe,EAAK,EAAE,OAAO,OAAO,EAAE,OAAO,MAAM,IAAI,EAAW,EAAE,OAAO,MAAM,EAAE,CAAG,EAAQ,EAAW,GAAM,CAAC,GAAG,EAAK,KAAK,WAAW,QAAQ,EAAE,CAAC,IAAM,EAAO,IAAI,WAAW,EAAO,OAAO,GAAG,CAAI,EAAE,QAAQ,QAAQ,MAAoB,EAAgB,EAAE,OAAO,MAAM,CAAC,CAA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