{"version":3,"file":"Text_Opacity_Letters.ZK_5ocnu.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/IpG84MPXcNrhqgn7RK5q/0x2krDyoSz2an91wjE7y/Text_Opacity_Letters.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{motion,useScroll,useTransform}from\"framer-motion\";import{useRef,useEffect}from\"react\";const EachCharacter=({char,start,end,progress,duration,easing,index,transitionStartIndex,fadedColor,activeColor})=>{const colorProgress=useTransform(progress,[start,end],[fadedColor,activeColor]);const initialColor=index<transitionStartIndex?activeColor:fadedColor;return /*#__PURE__*/_jsx(motion.span,{style:{color:index<transitionStartIndex?initialColor:colorProgress},transition:{duration:duration,ease:easing},children:char});};const EachWord=({word,progress,starting,ending,duration,easing,transitionStartIndex,currentCharacterIndex,fadedColor,activeColor})=>{const characters=word.split(\"\");const wordLength=word.length;const amount=ending-starting;const step=amount/wordLength;return /*#__PURE__*/_jsxs(motion.span,{children:[characters.map((char,idx)=>{const charStart=starting+step*idx;const charEnd=starting+step*(idx+1);return /*#__PURE__*/_jsx(EachCharacter,{char:char,start:charStart,end:charEnd,progress:progress,duration:duration,easing:easing,index:currentCharacterIndex+idx,transitionStartIndex:transitionStartIndex,fadedColor:fadedColor,activeColor:activeColor},idx);}),\"\\xa0\"]});};export default function Text_Color_Letters(props){const{text,duration,easing,fontSize,lineHeight,letterSpacing,paragraphAlign,paragraphSpacing,transitionStartIndex,fontFamily,fontWeight,fadedColor,activeColor,showHeading,headingText,headingFontFamily,headingFontSize,headingFontWeight,headingLineHeight,headingLetterSpacing,headingColor,headingSpacing,scrollStart,scrollEnd}=props;// Safe fallbacks for existing instances where new props are undefined\nconst safeHeadingFontFamily=headingFontFamily||\"Urbanist\";const safeFontFamily=fontFamily||\"Urbanist\";const safeScrollStart=scrollStart??.6;const safeScrollEnd=scrollEnd??.2;const ref=useRef(null);// scrollStart uses \"start\" anchor (top edge of element)\n// scrollEnd uses \"end\" anchor (bottom edge of element) — this makes the\n// animation span the full height of the element through the viewport\n// for a much slower, scroll-driven reveal.\nconst{scrollYProgress}=useScroll({target:ref,offset:[`start ${safeScrollStart}`,`end ${safeScrollEnd}`]});useEffect(()=>{const style=document.createElement(\"style\");const bodyImport=`@import url('https://fonts.googleapis.com/css2?family=${safeFontFamily.replace(/ /g,\"+\")}:wght@400;500;700&display=swap');`;const headingImport=showHeading?`@import url('https://fonts.googleapis.com/css2?family=${safeHeadingFontFamily.replace(/ /g,\"+\")}:wght@400;500;600;700;800;900&display=swap');`:\"\";style.appendChild(document.createTextNode(`${bodyImport}\n${headingImport}`));document.head.appendChild(style);return()=>{document.head.removeChild(style);};},[safeFontFamily,safeHeadingFontFamily,showHeading]);// Build the unified word sequence: heading first, then body\nconst headingWords=showHeading&&headingText?headingText.split(/\\s+/).filter(Boolean):[];const paragraphs=text.split(/\\n/);const bodyWords=text.split(/\\s+/).filter(Boolean);const totalWords=headingWords.length+bodyWords.length;// Shared counters across heading + body so the animation flows continuously\nlet currentCharacterIndex=0;let wordIndexOffset=0;// Render heading (consumes the first slice of the animation timeline)\nlet renderedHeading=null;if(showHeading&&headingText){renderedHeading=/*#__PURE__*/_jsx(\"h2\",{style:{display:\"flex\",flexWrap:\"wrap\",justifyContent:paragraphAlign,fontFamily:`${safeHeadingFontFamily}, sans-serif`,fontSize:`${headingFontSize??56}px`,fontWeight:headingFontWeight??\"700\",lineHeight:`${headingLineHeight??64}px`,letterSpacing:`${headingLetterSpacing??-2}px`,textAlign:paragraphAlign===\"flex-start\"?\"left\":paragraphAlign===\"flex-end\"?\"right\":\"center\",margin:0,marginBottom:`${headingSpacing??32}px`},children:headingWords.map((word,idx)=>{const globalWordIndex=wordIndexOffset+idx;const starting=globalWordIndex/totalWords;const ending=(globalWordIndex+1)/totalWords;const startIdx=currentCharacterIndex;currentCharacterIndex+=word.length+1;return /*#__PURE__*/_jsx(EachWord,{word:word,progress:scrollYProgress,starting:starting,ending:ending,duration:duration,easing:easing,transitionStartIndex:transitionStartIndex,currentCharacterIndex:startIdx,fadedColor:fadedColor,activeColor:headingColor??\"#FFFFFF\"},`h-${idx}`);})});wordIndexOffset+=headingWords.length;}return /*#__PURE__*/_jsxs(\"div\",{ref:ref,style:{fontFamily:`${safeFontFamily}, sans-serif`,fontSize:`${fontSize}px`,fontWeight:fontWeight,color:fadedColor,lineHeight:`${lineHeight}px`,letterSpacing:`${letterSpacing}px`,textAlign:paragraphAlign===\"flex-start\"?\"left\":paragraphAlign===\"flex-end\"?\"right\":\"center\",margin:0},children:[renderedHeading,paragraphs.map((paragraph,pIdx)=>{const words=paragraph.split(\" \").filter(Boolean);const rendered=/*#__PURE__*/_jsx(\"p\",{style:{display:\"flex\",flexWrap:\"wrap\",justifyContent:paragraphAlign,margin:0,marginBottom:pIdx<paragraphs.length-1?`${paragraphSpacing}px`:0},children:words.map((word,idx)=>{const globalWordIndex=wordIndexOffset+idx;const starting=globalWordIndex/totalWords;const ending=(globalWordIndex+1)/totalWords;const startIdx=currentCharacterIndex;currentCharacterIndex+=word.length+1;return /*#__PURE__*/_jsx(EachWord,{word:word,progress:scrollYProgress,starting:starting,ending:ending,duration:duration,easing:easing,transitionStartIndex:transitionStartIndex,currentCharacterIndex:startIdx,fadedColor:fadedColor,activeColor:activeColor},idx);})},pIdx);wordIndexOffset+=words.length;return rendered;})]});}addPropertyControls(Text_Color_Letters,{showHeading:{title:\"Show Heading\",type:ControlType.Boolean,defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},headingText:{title:\"Heading Text\",type:ControlType.String,defaultValue:\"The Problem Nobody Was Talking About\",displayTextArea:true,hidden:props=>!props.showHeading},headingFontFamily:{title:\"Heading Font\",type:ControlType.String,defaultValue:\"Urbanist\",hidden:props=>!props.showHeading},headingFontSize:{title:\"Heading Size\",type:ControlType.Number,defaultValue:56,min:10,max:200,hidden:props=>!props.showHeading},headingFontWeight:{title:\"Heading Weight\",type:ControlType.Enum,options:[\"400\",\"500\",\"600\",\"700\",\"800\",\"900\"],optionTitles:[\"Regular\",\"Medium\",\"Semibold\",\"Bold\",\"Extrabold\",\"Black\"],defaultValue:\"700\",hidden:props=>!props.showHeading},headingLineHeight:{title:\"Heading Line Height\",type:ControlType.Number,defaultValue:64,min:10,max:300,hidden:props=>!props.showHeading},headingLetterSpacing:{title:\"Heading Letter Spacing\",type:ControlType.Number,defaultValue:-2,min:-10,max:10,step:.1,hidden:props=>!props.showHeading},headingColor:{title:\"Heading Color\",type:ControlType.Color,defaultValue:\"#FFFFFF\",hidden:props=>!props.showHeading},headingSpacing:{title:\"Heading Spacing\",type:ControlType.Number,defaultValue:32,min:0,max:200,step:1,hidden:props=>!props.showHeading},text:{title:\"Text\",type:ControlType.String,defaultValue:\"Hello Text\",displayTextArea:true},fadedColor:{title:\"Faded Color\",type:ControlType.Color,defaultValue:\"#666666\"},activeColor:{title:\"Active Color\",type:ControlType.Color,defaultValue:\"#FFFFFF\"},fontFamily:{title:\"Font Family\",type:ControlType.String,defaultValue:\"Urbanist\"},fontSize:{title:\"Font Size\",type:ControlType.Number,defaultValue:48,min:10,max:100},fontWeight:{title:\"Font Weight\",type:ControlType.Enum,options:[\"400\",\"500\",\"700\"],optionTitles:[\"Regular\",\"Medium\",\"Bold\"],defaultValue:\"400\"},lineHeight:{title:\"Line Height\",type:ControlType.Number,defaultValue:60,min:10,max:200},paragraphSpacing:{title:\"Paragraph Spacing\",type:ControlType.Number,defaultValue:24,min:0,max:200,step:1},letterSpacing:{title:\"Letter Spacing\",type:ControlType.Number,defaultValue:-3,min:-10,max:10},paragraphAlign:{title:\"Paragraph Align\",type:ControlType.Enum,options:[\"flex-start\",\"center\",\"flex-end\"],optionTitles:[\"Left\",\"Center\",\"Right\"],defaultValue:\"center\"},duration:{title:\"Duration\",type:ControlType.Number,defaultValue:.3,min:.1,max:3,step:.1},easing:{title:\"Easing\",type:ControlType.Enum,options:[\"easeInOut\",\"easeIn\",\"easeOut\",\"linear\"],optionTitles:[\"Ease In Out\",\"Ease In\",\"Ease Out\",\"Linear\"],defaultValue:\"easeInOut\"},transitionStartIndex:{title:\"Transition Start Index\",type:ControlType.Number,defaultValue:0,min:0,max:1e3},scrollStart:{title:\"Scroll Start\",type:ControlType.Number,defaultValue:.6,min:0,max:1,step:.05},scrollEnd:{title:\"Scroll End\",type:ControlType.Number,defaultValue:.2,min:0,max:1,step:.05}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Text_Color_Letters\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Text_Opacity_Letters.map"],"mappings":"kPAAsxC,SAAwB,EAAmB,EAAM,CAAC,GAAK,CAAC,OAAK,WAAS,SAAO,WAAS,aAAW,gBAAc,iBAAe,mBAAiB,uBAAqB,aAAW,aAAW,aAAW,cAAY,cAAY,cAAY,oBAAkB,kBAAgB,oBAAkB,oBAAkB,uBAAqB,eAAa,iBAAe,cAAY,aAAW,EACvoD,EAAsB,GAAmB,WAAiB,EAAe,GAAY,WAAiB,EAAgB,GAAa,GAAS,EAAc,GAAW,GAAS,EAAIA,EAAO,KAAK,CAI/L,CAAC,mBAAiB,EAAU,CAAC,OAAO,EAAI,OAAO,CAAC,SAAS,IAAkB,OAAO,IAAgB,CAAC,CAAC,CAAC,MAAc,CAAC,IAAM,EAAM,SAAS,cAAc,QAAQ,CAAO,EAAW,yDAAyD,EAAe,QAAQ,KAAK,IAAI,CAAC,mCAAyC,EAAc,EAAY,yDAAyD,EAAsB,QAAQ,KAAK,IAAI,CAAC,+CAA+C,GAC9a,OADib,EAAM,YAAY,SAAS,eAAe,GAAG,EAAW;EAC5hB,IAAgB,CAAC,CAAC,SAAS,KAAK,YAAY,EAAM,KAAW,CAAC,SAAS,KAAK,YAAY,EAAM,GAAK,CAAC,EAAe,EAAsB,EAAY,CAAC,CACxJ,IAAM,EAAa,GAAa,EAA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