{"version":3,"file":"CustomText.BqBcj4ZM.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/QMgZKc8Wo8elB2R0pH75/IT5tc2jjJt7onsW1i3gr/CustomText.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,baseColor,activeColor})=>{const colorProgress=useTransform(progress,[start,end],[baseColor,activeColor]);const initialColor=index<transitionStartIndex?activeColor:baseColor;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,baseColor,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,baseColor:baseColor,activeColor:activeColor},idx);}),\"\\xa0\"]});};export default function Text_Color_Letters(props){const{text,duration,easing,fontSize,fontWeight,lineHeight,letterSpacing,paragraphAlign,transitionStartIndex,fontFamily,baseColor,activeColor,scrollStart,scrollEnd}=props;const words=text.split(\" \");const totalWords=words.length;const ref=useRef(null);const{scrollYProgress}=useScroll({target:ref,offset:[`start ${scrollStart}%`,`end ${scrollEnd}%`]});useEffect(()=>{const style=document.createElement(\"style\");// Clash Grotesk isn't on Google Fonts, so it loads from Fontshare.\n// Every other option keeps loading from Google Fonts as before.\nif(fontFamily.toLowerCase().includes(\"clash grotesk\")){style.appendChild(document.createTextNode(`\n                @import url('https://api.fontshare.com/v2/css?f[]=clash-grotesk@1,2,3,4,5,6,7&display=swap');\n            `));}else{style.appendChild(document.createTextNode(`\n                @import url('https://fonts.googleapis.com/css2?family=${fontFamily.replace(/ /g,\"+\")}:wght@${fontWeight}&display=swap');\n            `));}document.head.appendChild(style);return()=>{document.head.removeChild(style);};},[fontFamily,fontWeight]);let currentCharacterIndex=0;return /*#__PURE__*/_jsx(\"p\",{ref:ref,style:{fontFamily:`${fontFamily}, Suse`,fontWeight:fontWeight,fontSize:`${fontSize}px`,display:\"flex\",flexWrap:\"wrap\",lineHeight:`${lineHeight}%`,letterSpacing:`${letterSpacing/100*fontSize}px`,justifyContent:paragraphAlign,margin:0},children:words.map((word,idx)=>{const starting=idx/totalWords;const ending=(idx+1)/totalWords;const wordLength=word.length;const startIdx=currentCharacterIndex;currentCharacterIndex+=wordLength+1// Including space\n;return /*#__PURE__*/_jsx(EachWord,{word:word,progress:scrollYProgress,starting:starting,ending:ending,duration:duration,easing:easing,transitionStartIndex:transitionStartIndex,currentCharacterIndex:startIdx,baseColor:baseColor,activeColor:activeColor},idx);})});}addPropertyControls(Text_Color_Letters,{text:{title:\"Text\",type:ControlType.String,defaultValue:\"Hello Text\"},fontFamily:{title:\"Font Family\",type:ControlType.Enum,options:[\"Clash Grotesk\",\"Space Grotesk\",\"Suse\",\"Inter\",\"Helvetica Neue\",\"Georgia\",\"Playfair Display\",\"Poppins\",\"Manrope\"],defaultValue:\"Suse\"},baseColor:{title:\"Base Color\",type:ControlType.Color,defaultValue:\"#B5B5B5\"},activeColor:{title:\"Active Color\",type:ControlType.Color,defaultValue:\"#1A1A1A\"},fontWeight:{title:\"Weight\",type:ControlType.Enum,options:[\"300\",\"400\",\"500\",\"600\",\"700\"],optionTitles:[\"Light\",\"Regular\",\"Medium\",\"Semibold\",\"Bold\"],defaultValue:\"400\"},fontSize:{title:\"Font Size\",type:ControlType.Number,defaultValue:48,min:10,max:300},lineHeight:{title:\"Line Height\",type:ControlType.Number,defaultValue:100,min:50,max:300,step:5,unit:\"%\"},letterSpacing:{title:\"Letter Spacing\",type:ControlType.Number,defaultValue:-6,min:-50,max:50,step:1,unit:\"%\"},paragraphAlign:{title:\"Paragraph Align\",type:ControlType.Enum,options:[\"flex-start\",\"center\",\"flex-end\"],optionTitles:[\"Left\",\"Center\",\"Right\"],defaultValue:\"center\"},scrollStart:{title:\"Reveal Start\",type:ControlType.Number,defaultValue:100,min:0,max:100,step:1,unit:\"%\",description:\"Section er upor part viewport er kotota niche thakle reveal shuru hobe. 100% dile section viewport e dhoka matro reveal shuru hobe (section shuru = reveal shuru).\"},scrollEnd:{title:\"Reveal End\",type:ControlType.Number,defaultValue:0,min:0,max:100,step:1,unit:\"%\",description:\"Section er niche part viewport er kotota upore thakle reveal shesh hobe. 0% dile section fully viewport chere gele reveal shesh hobe (section shesh = reveal shesh). Full section jure smooth revealer jonno Start=100%, End=0% rakhun.\"},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:22,min:0,max:1e3}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Text_Color_Letters\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CustomText.map"],"mappings":"uPAAgxC,SAAwB,EAAmB,EAAM,CAAC,GAAK,CAAC,OAAK,WAAS,SAAO,WAAS,aAAW,aAAW,gBAAc,iBAAe,uBAAqB,aAAW,YAAU,cAAY,cAAY,aAAW,EAAY,EAAM,EAAK,MAAM,GAAG,EAAQ,EAAW,EAAM,OAAa,EAAIA,EAAO,IAAI,EAAO,CAAC,mBAAiB,EAAU,CAAC,OAAO,E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