{"version":3,"file":"ScrollProgressBar.CFORxmo8.mjs","names":["useState","useRef","useCallback"],"sources":["https:/framerusercontent.com/modules/q9xozelpqxABDY9B1j82/alyz0OcKzSQLUZJEfz7o/ScrollProgressBar.js"],"sourcesContent":["// Scroll progress bar component with clickable sections\n// Creates a vertical progress indicator that tracks scroll position\n// Each dash is clickable and scrolls to corresponding section\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useState,useCallback,useRef,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * Scroll Progress Bar\n *\n * @framerIntrinsicWidth 40\n * @framerIntrinsicHeight 400\n *\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export default function ScrollProgressBar(props){const{fillMode=\"fill\",activeColor=\"#000000\",inactiveColor=\"#CCCCCC\",activeDashWidth=24,inactiveDashWidth=24,dashHeight=4,dashGap=12,dashRadius=2,scrollOffset=0,tooltipFont,sections=[]}=props;// Calculate section count from sections array\nconst sectionCount=sections.length>0?sections.length:5;const[activeSection,setActiveSection]=useState(0);const dashRefs=useRef([]);const tippyInstances=useRef([]);// Track visible sections using Intersection Observer\nconst updateProgress=useCallback(()=>{if(typeof window===\"undefined\")return;const sectionElements=[];sections.forEach(section=>{if(section.anchor){const element=document.querySelector(section.anchor);if(element){sectionElements.push(element);}}});if(sectionElements.length===0)return;// Find which section is most visible\nlet maxVisibleIndex=0;let maxVisibleRatio=0;sectionElements.forEach((element,index)=>{const rect=element.getBoundingClientRect();const viewportHeight=window.innerHeight;// Calculate how much of the section is visible\nconst visibleTop=Math.max(0,rect.top);const visibleBottom=Math.min(viewportHeight,rect.bottom);const visibleHeight=Math.max(0,visibleBottom-visibleTop);const visibleRatio=visibleHeight/viewportHeight;// Prioritize sections that are at the top of viewport\nconst topBonus=rect.top<=scrollOffset+20&&rect.top>=-(scrollOffset+20)?.5:0;const totalScore=visibleRatio+topBonus;if(totalScore>maxVisibleRatio){maxVisibleRatio=totalScore;maxVisibleIndex=index;}});startTransition(()=>{setActiveSection(maxVisibleIndex);});},[sections,scrollOffset]);useEffect(()=>{if(typeof window===\"undefined\")return;updateProgress();window.addEventListener(\"scroll\",updateProgress,{passive:true});return()=>{window.removeEventListener(\"scroll\",updateProgress);};},[updateProgress]);// Initialize Tippy.js tooltips\nuseEffect(()=>{if(typeof window===\"undefined\")return;// Dynamically load tippy.js\nconst loadTippy=async()=>{if(!window.tippy){// Load Tippy CSS\nconst link=document.createElement(\"link\");link.rel=\"stylesheet\";link.href=\"https://unpkg.com/tippy.js@6/dist/tippy.css\";document.head.appendChild(link);// Load Tippy JS\nconst script=document.createElement(\"script\");script.src=\"https://unpkg.com/@popperjs/core@2\";document.head.appendChild(script);await new Promise(resolve=>{script.onload=resolve;});const tippyScript=document.createElement(\"script\");tippyScript.src=\"https://unpkg.com/tippy.js@6\";document.head.appendChild(tippyScript);await new Promise(resolve=>{tippyScript.onload=resolve;});}// Initialize tooltips\ntippyInstances.current.forEach(instance=>instance?.destroy());tippyInstances.current=[];dashRefs.current.forEach((dash,index)=>{if(dash&&window.tippy){const tooltipText=sections[index]?.tooltip||`Section ${index+1}`;const instance=window.tippy(dash,{content:tooltipText,placement:\"right\",arrow:false,followCursor:true,theme:\"translucent\",onCreate(instance){// Add custom translucent styling\nconst box=instance.popper.querySelector(\".tippy-box\");if(box){box.style.backgroundColor=\"rgba(0, 0, 0, 0.75)\";box.style.backdropFilter=\"blur(8px)\";box.style.color=\"#ffffff\";if(tooltipFont){for(const[key,value]of Object.entries(tooltipFont)){if(value==null)continue;box.style[key]=typeof value===\"number\"?String(value):value;}}}}});tippyInstances.current.push(instance);}});};loadTippy();return()=>{tippyInstances.current.forEach(instance=>instance?.destroy());};},[sectionCount,sections,tooltipFont]);const handleDashClick=useCallback(index=>{if(typeof window===\"undefined\")return;const anchor=sections[index]?.anchor;if(anchor){const element=document.querySelector(anchor);if(element){const elementPosition=element.getBoundingClientRect().top+window.scrollY;const offsetPosition=elementPosition-scrollOffset;window.scrollTo({top:offsetPosition,behavior:\"smooth\"});// Update active section immediately for better UX\nstartTransition(()=>{setActiveSection(index);});return;}}},[sections,scrollOffset]);return /*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:\"100%\",display:\"flex\",flexDirection:\"column\",alignItems:\"center\",justifyContent:\"center\",gap:`${dashGap}px`,padding:\"16px 0\"},children:Array.from({length:sectionCount}).map((_,index)=>{const isActive=fillMode===\"single\"?index===activeSection:index<=activeSection;return /*#__PURE__*/_jsx(\"div\",{ref:el=>{dashRefs.current[index]=el;},onClick:()=>handleDashClick(index),onKeyDown:e=>{if(e.key===\"Enter\"||e.key===\" \"){handleDashClick(index);}},role:\"button\",tabIndex:0,\"aria-label\":`Scroll to section ${index+1}`,style:{padding:\"8px\",cursor:\"pointer\",flexShrink:0,display:\"flex\",alignItems:\"center\",justifyContent:\"center\"},onMouseEnter:e=>{const dash=e.currentTarget.querySelector(\"div\");if(dash)dash.style.transform=\"scaleX(1.2)\";},onMouseLeave:e=>{const dash=e.currentTarget.querySelector(\"div\");if(dash)dash.style.transform=\"scaleX(1)\";},children:/*#__PURE__*/_jsx(\"div\",{style:{width:`${isActive?activeDashWidth:inactiveDashWidth}px`,height:`${dashHeight}px`,backgroundColor:isActive?activeColor:inactiveColor,borderRadius:`${dashRadius}px`,transition:\"background-color 0.3s ease, transform 0.2s ease, width 0.3s ease\",pointerEvents:\"none\"}})},index);})});}addPropertyControls(ScrollProgressBar,{fillMode:{type:ControlType.Enum,title:\"Mode\",options:[\"single\",\"fill\"],optionTitles:[\"Single Active\",\"Progressive Fill\"],defaultValue:\"fill\",displaySegmentedControl:true},tooltipFont:{type:ControlType.Font,title:\"Tooltip Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"12px\",variant:\"Medium\",letterSpacing:\"-0.01em\",lineHeight:\"1.2em\"}},scrollOffset:{type:ControlType.Number,title:\"Scroll Offset\",defaultValue:0,min:-300,max:300,step:1,unit:\"px\"},sections:{type:ControlType.Array,title:\"Sections\",control:{type:ControlType.Object,controls:{tooltip:{type:ControlType.String,title:\"Tooltip\",defaultValue:\"Section\"},anchor:{type:ControlType.String,title:\"Anchor\",defaultValue:\"#section\",placeholder:\"#section-id\"}}},defaultValue:[{tooltip:\"Introduction\",anchor:\"#intro\"},{tooltip:\"Overview\",anchor:\"#overview\"},{tooltip:\"Features\",anchor:\"#features\"},{tooltip:\"Details\",anchor:\"#details\"},{tooltip:\"Conclusion\",anchor:\"#conclusion\"}]},activeColor:{type:ControlType.Color,title:\"Active Color\",defaultValue:\"#000000\"},inactiveColor:{type:ControlType.Color,title:\"Inactive Color\",defaultValue:\"#CCCCCC\"},activeDashWidth:{type:ControlType.Number,title:\"Active Width\",defaultValue:24,min:10,max:60,step:1,unit:\"px\"},inactiveDashWidth:{type:ControlType.Number,title:\"Inactive Width\",defaultValue:24,min:10,max:60,step:1,unit:\"px\"},dashHeight:{type:ControlType.Number,title:\"Dash Height\",defaultValue:4,min:2,max:10,step:1,unit:\"px\"},dashGap:{type:ControlType.Number,title:\"Gap\",defaultValue:12,min:4,max:30,step:1,unit:\"px\"},dashRadius:{type:ControlType.Number,title:\"Radius\",defaultValue:2,min:0,max:10,step:1,unit:\"px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ScrollProgressBar\",\"slots\":[],\"annotations\":{\"framerIntrinsicWidth\":\"40\",\"framerIntrinsicHeight\":\"400\",\"framerSupportedLayoutWidth\":\"any\",\"framerSupportedLayoutHeight\":\"any\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ScrollProgressBar.map"],"mappings":"oNAWG,SAAwB,EAAkB,EAAM,CAAC,GAAK,CAAC,WAAS,OAAO,cAAY,UAAU,gBAAc,UAAU,kBAAgB,GAAG,oBAAkB,GAAG,aAAW,EAAE,UAAQ,GAAG,aAAW,EAAE,eAAa,EAAE,cAAY,WAAS,CAAC,GAAG,EACv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