{"version":3,"file":"ReadingProgress.CUwlaXT0.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/s4I2dYy37i3obnDu5FXr/6XrQ5TjsbwJWnqpZSc8o/ReadingProgress.js"],"sourcesContent":["// Progress bar that sticks to the bottom of the viewport and updates as you scroll\n// Supports CMS connection for blog title field\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useState,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * Sticky Reading Progress Bar\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight fixed\n */export default function ReadingProgress(props){const{title,backgroundColor,barColor,textColor,font,style={},padding,radius,shadow,sectionSelector}=props;const[progress,setProgress]=useState(0);const[sectionInView,setSectionInView]=useState(false);const[fadeIn,setFadeIn]=useState(false);useEffect(()=>{function updateProgress(){if(typeof window===\"undefined\"||typeof document===\"undefined\")return;let section=null;if(sectionSelector){section=document.querySelector(sectionSelector);}let scrollTop,docHeight;let inView=false;if(section){const rect=section.getBoundingClientRect();const sectionTop=rect.top+window.scrollY;const sectionHeight=section.offsetHeight;const sectionBottom=sectionTop+sectionHeight;const winHeight=window.innerHeight;const scrollY=window.scrollY;// Check if section is in viewport\ninView=rect.bottom>0&&rect.top<winHeight;if(!inView){startTransition(()=>setProgress(0));startTransition(()=>setSectionInView(false));startTransition(()=>setFadeIn(false));return;}startTransition(()=>setSectionInView(true));// Fade in when section comes into view\nif(!fadeIn){startTransition(()=>setFadeIn(true));}if(scrollY<sectionTop){startTransition(()=>setProgress(0));return;}if(scrollY+winHeight>sectionBottom){startTransition(()=>setProgress(100));return;}scrollTop=scrollY-sectionTop;docHeight=sectionHeight-winHeight;}else{scrollTop=window.scrollY||document.documentElement.scrollTop;docHeight=document.documentElement.scrollHeight-window.innerHeight;inView=true;startTransition(()=>setSectionInView(true));// Fade in immediately if no section selector\nif(!fadeIn){startTransition(()=>setFadeIn(true));}}const percent=docHeight>0?Math.round(scrollTop/docHeight*100):0;startTransition(()=>setProgress(percent));}if(typeof window!==\"undefined\"){window.addEventListener(\"scroll\",updateProgress,{passive:true});updateProgress();return()=>window.removeEventListener(\"scroll\",updateProgress);}},[sectionSelector]);// Sticky to bottom\nconst stickyStyle={position:style?.position||\"relative\",left:undefined,right:undefined,bottom:undefined,zIndex:1,pointerEvents:\"auto\",width:style?.width||\"100%\",height:style?.height,...style};return /*#__PURE__*/_jsxs(\"div\",{style:{...stickyStyle,borderRadius:props.radius,background:backgroundColor,boxShadow:props.shadow?\"0 2px 8px rgba(0,0,0,0.10)\":\"none\",display:\"flex\",alignItems:\"center\",padding:props.padding,gap:16,overflow:\"hidden\",minHeight:56,minWidth:0,opacity:fadeIn?1:0,transition:\"opacity 0.5s ease-in-out\"},\"aria-label\":\"Reading progress bar\",role:\"progressbar\",\"aria-valuenow\":progress,\"aria-valuemin\":0,\"aria-valuemax\":100,children:[/*#__PURE__*/_jsxs(\"button\",{\"aria-label\":\"Scroll to top\",tabIndex:progress>10?0:-1,onClick:()=>{if(progress>10&&typeof window!==\"undefined\"){window.scrollTo({top:0,behavior:\"smooth\"});}},style:{width:40,height:40,borderRadius:\"50%\",background:\"rgba(0,0,0,0.10)\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",position:\"relative\",border:\"none\",cursor:progress>10?\"pointer\":\"default\",outline:\"none\",transition:\"background 0.2s, box-shadow 0.2s\",boxShadow:progress>10?\"0 2px 8px rgba(0,0,0,0.10)\":\"none\",padding:0,opacity:sectionInView?1:.5},disabled:progress<=10||!sectionInView,children:[/*#__PURE__*/_jsx(\"svg\",{width:40,height:40,style:{position:\"absolute\",top:0,left:0},children:/*#__PURE__*/_jsx(\"circle\",{cx:20,cy:20,r:16,stroke:barColor,strokeWidth:3,fill:\"none\",strokeDasharray:2*Math.PI*16,strokeDashoffset:2*Math.PI*16*(1-progress/100),style:{transition:\"stroke-dashoffset 0.3s\"}})}),/*#__PURE__*/_jsx(\"svg\",{width:22,height:22,viewBox:\"0 0 256 256\",fill:\"none\",xmlns:\"http://www.w3.org/2000/svg\",style:{opacity:progress>10&&sectionInView?1:0,transition:\"opacity 0.4s\",zIndex:2,pointerEvents:\"none\"},\"aria-hidden\":\"true\",children:/*#__PURE__*/_jsx(\"path\",{d:\"M128 208V48M128 48l-80 80M128 48l80 80\",stroke:barColor,strokeWidth:16,strokeLinecap:\"round\",strokeLinejoin:\"round\"})})]}),/*#__PURE__*/_jsxs(\"div\",{style:{flex:1,minWidth:0},children:[/*#__PURE__*/_jsx(\"div\",{style:{color:textColor,fontWeight:600,fontSize:font.fontSize,lineHeight:font.lineHeight,letterSpacing:font.letterSpacing,fontStyle:font.fontStyle,textAlign:\"left\",whiteSpace:\"normal\",overflowWrap:\"break-word\",wordBreak:\"break-word\",minWidth:0,...font},children:title}),/*#__PURE__*/_jsxs(\"div\",{style:{color:textColor,opacity:.7,fontSize:14,fontWeight:400,marginTop:2},children:[progress,\"%\"]})]})]});}addPropertyControls(ReadingProgress,{title:{type:ControlType.String,title:\"Title\",defaultValue:\"Starting and Growing a Career in Web Design\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#232323\"},barColor:{type:ControlType.Color,title:\"Bar Color\",defaultValue:\"#FFFFFF\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#FFFFFF\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:16,variant:\"Semibold\",letterSpacing:\"-0.01em\",lineHeight:\"1.2em\"}},padding:{type:ControlType.Padding,title:\"Padding\",defaultValue:\"0 24px\"},radius:{type:ControlType.BorderRadius,title:\"Radius\",defaultValue:\"20px\"},shadow:{type:ControlType.Boolean,title:\"Shadow\",defaultValue:true,enabledTitle:\"Show\",disabledTitle:\"Hide\"},sectionSelector:{type:ControlType.String,title:\"Section Selector\",defaultValue:\"\",placeholder:\"e.g. #main-content or .blog-article\",description:\"CSS selector for the section to track (optional)\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ReadingProgress\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"fixed\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ReadingProgress.map"],"mappings":"8MAOG,SAAwB,EAAgB,EAAM,CAAC,GAAK,CAAC,QAAM,kBAAgB,WAAS,YAAU,OAAK,QAAM,CAAC,EAAE,UAAQ,SAAO,SAAO,mBAAiB,EAAW,CAAC,EAAS,GAAaA,EAAS,CAAC,EAAO,CAAC,EAAc,GAAkBA,EAAS,EAAK,EAAO,CAAC,EAAO,GAAWA,EAAS,EAAK,EAIhG,OAJkG,MAAc,CAAC,SAAS,GAAgB,CAAC,GAAU,IAAS,QAAa,OAAO,SAAW,IAAY,OAAO,IAAI,EAAQ,KAAQ,IAAiB,EAAQ,SAAS,cAAc,CAAe,GAAG,IAAI,EAAU,EAAc,EAAO,GAAM,GAAG,EAAQ,CAAC,IAAM,EAAK,EAAQ,sBAAsB,EAAQ,EAAW,EAAK,IAAI,EAAO,QAAc,EAAc,EAAQ,aAAmB,EAAc,EAAW,EAAoB,EAAU,EAAO,YAAkB,EAAQ,EAAO,QACptB,GAAzC,EAAO,EAAK,OAAO,GAAG,EAAK,IAAI,EAAa,CAAC,EAAO,CAAC,MAAoB,EAAY,CAAC,CAAC,EAAE,MAAoB,EAAiB,EAAK,CAAC,EAAE,MAAoB,EAAU,EAAK,CAAC,EAAE,MAAO,CACjI,GADkI,MAAoB,EAAiB,EAAI,CAAC,EAC1N,GAAQ,MAAoB,EAAU,EAAI,CAAC,EAAM,EAAQ,EAAW,CAAC,MAAoB,EAAY,CAAC,CAAC,EAAE,MAAO,CAAC,GAAG,EAAQ,EAAU,EAAc,CAAC,MAAoB,EAAY,GAAG,CAAC,EAAE,MAAO,CAAC,EAAU,EAAQ,EAAW,EAAU,EAAc,CAA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