{"version":3,"file":"Progress_Circle.DaPRBONW.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/NBw2Opt2PwEZFoBy43fr/ySl37wdTTeDPpiF0M1CY/Progress_Circle.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useRef,useState}from\"react\";import{motion,useAnimation}from\"framer-motion\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n *\n * @framerDisableUnlink\n *\n * @framerName Guilherme Neder\n *\n */export default function ProgressCircle({size=200,borderWidth=8,emptyColor=\"#CFCFCF\",fillColor=\"#0033FF\",percentage=90,duration=2,replayOnView=true,showText=true,textSizePercentage=20,showPercentageSymbol=true,selectedFont={fontFamily:\"Inter\",fontWeight:500,systemFont:true}}){const controls=useAnimation();const ref=useRef(null);const[isInView,setIsInView]=useState(false);const[currentPercentage,setCurrentPercentage]=useState(0);const[hasAnimated,setHasAnimated]=useState(false);const radius=size/2-borderWidth/2;const circumference=2*Math.PI*radius;const fontSize=size*textSizePercentage/100;useEffect(()=>{const observer=new IntersectionObserver(([entry])=>{setIsInView(entry.isIntersecting);},{threshold:.1});if(ref.current){observer.observe(ref.current);}return()=>{if(ref.current){observer.unobserve(ref.current);}};},[]);// Reset hasAnimated when percentage changes\nuseEffect(()=>{setHasAnimated(false);},[percentage]);useEffect(()=>{const animateProgress=async()=>{await controls.start({strokeDashoffset:circumference-percentage/100*circumference,transition:{duration:duration,ease:\"easeInOut\"}});setHasAnimated(true);};if(isInView){// Only animate if replayOnView is true OR if it hasn't animated before\nif(replayOnView||!hasAnimated){setCurrentPercentage(0);controls.set({strokeDashoffset:circumference});animateProgress();}}else if(replayOnView){// Only reset if replayOnView is true\ncontrols.stop();setCurrentPercentage(0);controls.set({strokeDashoffset:circumference});}},[isInView,percentage,circumference,duration,controls,replayOnView,hasAnimated]);return /*#__PURE__*/_jsx(\"div\",{ref:ref,style:{width:size,height:size},children:/*#__PURE__*/_jsxs(\"svg\",{width:size,height:size,children:[/*#__PURE__*/_jsx(\"circle\",{cx:size/2,cy:size/2,r:radius,fill:\"none\",stroke:emptyColor,strokeWidth:borderWidth}),/*#__PURE__*/_jsx(motion.circle,{cx:size/2,cy:size/2,r:radius,fill:\"none\",stroke:fillColor,strokeWidth:borderWidth,strokeDasharray:circumference,strokeLinecap:\"round\",transform:`rotate(-90 ${size/2} ${size/2})`,initial:{strokeDashoffset:circumference},animate:controls,onUpdate:latest=>{const progress=(circumference-latest.strokeDashoffset)/circumference;setCurrentPercentage(Math.round(progress*100));}}),showText&&/*#__PURE__*/_jsx(\"text\",{x:\"50%\",y:\"50%\",textAnchor:\"middle\",dy:\".3em\",style:{fontFamily:selectedFont.fontFamily,fontWeight:selectedFont.fontWeight,fontSize:`${fontSize}px`,fill:fillColor},children:`${currentPercentage}${showPercentageSymbol?\"%\":\"\"}`})]})});}addPropertyControls(ProgressCircle,{size:{type:ControlType.Number,title:\"Size\",defaultValue:200,min:50,max:500,step:10},borderWidth:{type:ControlType.Number,title:\"Border Width\",defaultValue:8,min:1,max:50,step:1},emptyColor:{type:ControlType.Color,title:\"Empty Color\",defaultValue:\"#CFCFCF\"},fillColor:{type:ControlType.Color,title:\"Fill Color\",defaultValue:\"#0033FF\"},percentage:{type:ControlType.Number,title:\"Number\",defaultValue:90,min:0,max:100,step:1},duration:{type:ControlType.Number,title:\"Animation Duration\",defaultValue:2,min:.1,max:10,step:.1},replayOnView:{type:ControlType.Boolean,title:\"Replay on View\",defaultValue:true},showText:{type:ControlType.Boolean,title:\"Show Text\",defaultValue:true},textSizePercentage:{type:ControlType.Number,title:\"Text Size (%)\",defaultValue:20,min:5,max:50,step:1},showPercentageSymbol:{type:ControlType.Boolean,title:\"Show % Symbol\",defaultValue:true},selectedFont:{type:ControlType.Font,title:\"Font\",description:\"Made by [Guilherme N.](https://framernapratica.com.br)\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ProgressCircle\",\"slots\":[],\"annotations\":{\"framerDisableUnlink\":\"*\",\"framerSupportedLayoutWidth\":\"auto\",\"framerContractVersion\":\"1\",\"framerName\":\"Guilherme Neder\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Progress_Circle.map"],"mappings":"uPAQG,SAAwB,EAAe,CAAC,OAAK,IAAI,cAAY,EAAE,aAAW,UAAU,YAAU,UAAU,aAAW,GAAG,WAAS,EAAE,eAAa,GAAK,WAAS,GAAK,qBAAmB,GAAG,uBAAqB,GAAK,eAAa,CAAC,WAAW,QAAQ,WAAW,IAAI,WAAW,EAAI,GAAG,CAAC,IAAM,EAAS,EAAa,EAAQ,EAAIA,EAAO,IAAI,EAAO,CAAC,EAAS,GAAaC,EAAS,EAAK,EAAO,CAAC,EAAkB,GAAsBA,EAAS,CAAC,EAAO,CAAC,EAAY,GAAgBA,EAAS,EAAK,EAAQ,EAAO,EAAK,EAAE,EAAY,EAAQ,EAAc,EAAE,KAAK,GAAG,EAAa,EAAS,EAAK,EAAmB,IAGxa,OAH4a,MAAc,CAAC,IAAM,EAAS,IAAI,sBAAsB,CAAC,KAAS,CAAC,EAAY,EAAM,cAAc,CAAE,EAAE,CAAC,UAAU,EAAE,CAAC,EAAiD,OAA5C,EAAI,SAAS,EAAS,QAAQ,EAAI,OAAO,MAAa,CAAI,EAAI,SAAS,EAAS,UAAU,EAAI,OAAO,CAAG,CAAE,EAAE,CAAC,CAAC,EAC9zB,MAAc,CAAC,EAAe,EAAK,CAAE,EAAE,CAAC,CAAU,CAAC,EAAE,MAAc,CAA+L,GAC/P,GAAc,CAAC,KAAa,EAAqB,CAAC,EAAE,EAAS,IAAI,CAAC,iBAAiB,CAAa,CAAC,GAAE,SADH,CAAC,MAAM,EAAS,MAAM,CAAC,iBAAiB,EAAc,EAAW,IAAI,EAAc,WAAW,CAAU,WAAS,KAAK,WAAW,CAAC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