{"version":3,"file":"ProgressiveHighlightText.Cv52pvEK.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/AC2u3mpvR01w7mL17dVQ/Fg0PrujT4dw870mef77A/ProgressiveHighlightText.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useRef}from\"react\";import{addPropertyControls,ControlType}from\"framer\";import{motion,useScroll,useTransform}from\"framer-motion\";const defaultProps={text:\"We help ambitious founders turn their vision into a coherent product — from strategy through design and development, delivered in weeks not months.\",font:{fontSize:56,lineHeight:\"1.15\"},activeColor:\"rgb(20, 20, 20)\",inactiveColor:\"rgb(200, 200, 195)\",revealAnchor:.55,revealSpread:.15};/**\n * ProgressiveHighlightText\n *\n * Renders a block of text where each word fades from an \"inactive\" muted\n * color to an \"active\" dark color as the user scrolls past it. The reveal\n * is driven by the text block's position in the viewport, not by where\n * the user is on the page overall.\n *\n * Each word is split into its own span and animated independently with\n * Framer Motion's useScroll hook bound to the container element.\n *\n * revealAnchor controls where on the screen (0=top, 1=bottom) a word\n * needs to reach before it's fully active. 0.55 means slightly above\n * the vertical middle, which feels natural for reading.\n *\n * revealSpread controls how gradual the transition is. Smaller values\n * make each word \"snap\" between states more sharply; larger values\n * give a softer, more drawn-out fade.\n */export default function ProgressiveHighlightText(props){const{text,font,activeColor,inactiveColor,revealAnchor,revealSpread,style}=props;const containerRef=useRef(null);// Track the container's progress as it passes through the viewport.\n// offset [\"start end\", \"end start\"] means: progress is 0 when the top\n// of the container reaches the bottom of the viewport, and 1 when the\n// bottom of the container reaches the top.\nconst{scrollYProgress}=useScroll({target:containerRef,offset:[\"start end\",\"end start\"]});// Split text into words while preserving whitespace structure.\n// We split on spaces but keep the words separate so we can wrap each\n// in a span with its own animated color.\nconst words=text.split(/(\\s+)/).filter(w=>w.length>0);const actualWords=words.filter(w=>!/^\\s+$/.test(w));const totalWords=actualWords.length;let wordIndex=-1;return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{...font,color:inactiveColor,width:\"100%\",...style},children:words.map((segment,i)=>{if(/^\\s+$/.test(segment)){// Whitespace — render as-is, no animation\nreturn /*#__PURE__*/_jsx(\"span\",{children:segment},i);}wordIndex++;return /*#__PURE__*/_jsx(Word,{word:segment,index:wordIndex,total:totalWords,scrollProgress:scrollYProgress,activeColor:activeColor,inactiveColor:inactiveColor,revealAnchor:revealAnchor,revealSpread:revealSpread},i);})});}ProgressiveHighlightText.defaultProps=defaultProps;function Word({word,index,total,scrollProgress,activeColor,inactiveColor,revealAnchor,revealSpread}){// Each word has its own \"activation point\" along the scroll progress.\n// Word 0 activates earliest, last word activates latest.\n// The activation window goes from (revealAnchor - revealSpread) to\n// (revealAnchor + revealSpread) of scroll progress.\n//\n// We map: word i activates when scroll progress reaches\n// (revealAnchor - revealSpread) + (i / total) * (2 * revealSpread)\n//\n// Actually the cleaner way: spread the word activation evenly across\n// the entire 0–1 scroll range, centered on revealAnchor.\nconst activationStart=revealAnchor-revealSpread/2;const activationEnd=revealAnchor+revealSpread/2;const wordProgress=index/Math.max(1,total-1);// Each word activates at: activationStart + wordProgress * (activationEnd - activationStart)\n// But we want each word to fade in over a small window of its own\nconst wordActivationPoint=activationStart+wordProgress*(activationEnd-activationStart);const fadeWindow=(activationEnd-activationStart)/Math.max(1,total)*2;const color=useTransform(scrollProgress,[wordActivationPoint-fadeWindow/2,wordActivationPoint+fadeWindow/2],[inactiveColor,activeColor]);return /*#__PURE__*/_jsx(motion.span,{style:{color},children:word});}addPropertyControls(ProgressiveHighlightText,{text:{type:ControlType.String,title:\"Text\",displayTextArea:true,defaultValue:\"We help ambitious founders turn their vision into a coherent product — from strategy through design and development, delivered in weeks not months.\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:56,lineHeight:\"1.15\"}},activeColor:{type:ControlType.Color,title:\"Active color\",defaultValue:\"rgb(20, 20, 20)\"},inactiveColor:{type:ControlType.Color,title:\"Inactive color\",defaultValue:\"rgb(200, 200, 195)\"},revealAnchor:{type:ControlType.Number,title:\"Reveal anchor\",description:\"Where on screen the highlight peaks. 0 = top, 0.5 = middle, 1 = bottom.\",min:0,max:1,step:.05,defaultValue:.55},revealSpread:{type:ControlType.Number,title:\"Reveal spread\",description:\"How spread out the reveal is along scroll progress. Smaller = tighter and snappier; larger = slower and softer.\",min:.05,max:.6,step:.05,defaultValue:.15}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ProgressiveHighlightText\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ProgressiveHighlightText.map"],"mappings":"yOAkBG,SAAwB,EAAyB,EAAM,CAAC,GAAK,CAAC,OAAK,OAAK,cAAY,gBAAc,eAAa,eAAa,SAAO,EAAY,EAAaA,EAAO,KAAK,CAItK,CAAC,mBAAiB,EAAU,CAAC,OAAO,EAAa,OAAO,CAAC,YAAY,YAAY,CAAC,CAAC,CAGlF,EAAM,EAAK,MAAM,QAAQ,CAAC,OAAO,GAAG,EAAE,OAAO,EAAE,CAA2D,EAAxC,EAAM,OAAO,GAAG,CAAC,QAAQ,KAAK,EAAE,CAAC,CAA8B,OAAW,EAAU,GAAG,OAAoB,EAAK,MAAM,CAAC,IAAI,EAAa,MAAM,CAAC,GAAG,EAAK,MAAM,EAAc,MAAM,OAAO,GAAG,EAAM,CAAC,SAAS,EAAM,KAAK,EAAQ,IAAQ,QAAQ,KAAK,EAAQ,CAC/S,EAAK,OAAO,CAAC,SAAS,EAAQ,CAAC,EAAE,EAAE,IAAgC,EAAK,EAAK,CAAC,KAAK,EAAQ,MAAM,EAAU,MAAM,EAAW,eAAe,EAA4B,cAA0B,gBAA2B,eAA0B,eAAa,CAAC,EAAE,EAAG,CAAC,CAAC,CAAqD,SAAS,EAAK,CAAC,OAAK,QAAM,QAAM,iBAAe,cAAY,gBAAc,eAAa,gBAAc,CAUxb,IAAM,EAAgB,E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