{"version":3,"file":"TextReveal.ui7DK9Za.mjs","names":["useRef","Tag","__esmMin","init_npm_react_18_3_1","ce","p","c","init_jsx_runtime","de","useScroll","motion","useTransform","init_framer_motion_DhsWWWsN","addPropertyControls","ControlType","init_framer_BWFVvmND","TextReveal","props","words","text","totalWords","ref","offsetReference","offsetStart","offsetEnd","font","style","currentCharacterIndex","tag","paragraphAlign","starting","idx","ending","wordLength","word","startIdx","EachWord","scrollYProgress","EachCharacter","init_TextReveal","colorProgress","progress","start","end","initialColor","finalColor","staticColor","index","transitionStartIndex","char","characters","step","charStart","charEnd"],"sources":["https:/framerusercontent.com/modules/h2HDlSCE6CGXoqO3DzBS/9BUzFBsKEynchmdZoVBQ/TextReveal.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,transition,index,transitionStartIndex,initialColor,finalColor})=>{const colorProgress=useTransform(progress,[start,end],[initialColor,finalColor]);const staticColor=index<transitionStartIndex?finalColor:initialColor;return /*#__PURE__*/_jsx(motion.span,{style:{color:index<transitionStartIndex?staticColor:colorProgress},transition:transition,children:char});};const EachWord=({word,progress,starting,ending,transition,transitionStartIndex,currentCharacterIndex,initialColor,finalColor})=>{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,transition:transition,index:currentCharacterIndex+idx,transitionStartIndex:transitionStartIndex,initialColor:initialColor,finalColor:finalColor},idx);}),\"\\xa0\"]});};/**\n * Text Reveal\n * @framerDisableUnlink\n *\n * @framerIntrinsicWidth 400\n * @framerIntrinsicHeight 60\n *\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight auto\n */export default function TextReveal(props){const{text,transition,font,paragraphAlign,transitionStartIndex,offsetStart,offsetEnd,textTransform,initialColor,finalColor,offsetReference,tag}=props;const words=text.split(\" \");const totalWords=words.length;const ref=useRef(null);const{scrollYProgress}=useScroll({target:ref,offset:[`${offsetReference} ${offsetStart}`,`${offsetReference} ${offsetEnd}`]});useEffect(()=>{if(font?.family){const style=document.createElement(\"style\");style.appendChild(document.createTextNode(`\n                @import url('https://fonts.googleapis.com/css2?family=${font.family.replace(/ /g,\"+\")}:wght@400&display=swap');\n            `));document.head.appendChild(style);return()=>{document.head.removeChild(style);};}},[font]);let currentCharacterIndex=0;const Tag=tag;return /*#__PURE__*/_jsx(Tag,{ref:ref,style:{...font,color:\"#573337\",display:\"flex\",flexWrap:\"wrap\",justifyContent:paragraphAlign,margin:0,textTransform:textTransform},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,transition:transition,transitionStartIndex:transitionStartIndex,currentCharacterIndex:startIdx,initialColor:initialColor,finalColor:finalColor},idx);})});}addPropertyControls(TextReveal,{text:{title:\"Text\",type:ControlType.String,defaultValue:\"Hello Text\",displayTextArea:true},initialColor:{title:\"Initial Color\",type:ControlType.Color,defaultValue:\"#E5E5E5\"},finalColor:{title:\"Final Color\",type:ControlType.Color,defaultValue:\"#000000\"},font:{title:\"Font\",type:ControlType.Font,controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"28px\",variant:\"Medium\",lineHeight:\"1.2em\",letterSpacing:\"0px\"}},textTransform:{title:\"Text Transform\",type:ControlType.Enum,options:[\"none\",\"uppercase\",\"lowercase\",\"capitalize\"],optionTitles:[\"None\",\"Uppercase\",\"Lowercase\",\"Capitalize\"],defaultValue:\"none\"},paragraphAlign:{title:\"Align\",type:ControlType.Enum,options:[\"flex-start\",\"center\",\"flex-end\"],optionTitles:[\"Left\",\"Center\",\"Right\"],defaultValue:\"flex-start\",displaySegmentedControl:true},offsetReference:{title:\"Offset Reference\",type:ControlType.Enum,options:[\"start\",\"center\",\"end\"],optionTitles:[\"Top\",\"Middle\",\"Bottom\"],defaultValue:\"start\",displaySegmentedControl:false},offsetStart:{title:\"Offset Start\",type:ControlType.Number,defaultValue:.9,min:0,max:1,step:.05},offsetEnd:{title:\"Offset End\",type:ControlType.Number,defaultValue:.2,min:0,max:1,step:.05},transitionStartIndex:{title:\"Start Index\",type:ControlType.Number,defaultValue:0,min:0,max:1e3},transition:{title:\"Transition\",type:ControlType.Transition,defaultValue:{type:\"tween\",duration:.3,ease:\"easeInOut\"}},tag:{title:\"Tag\",type:ControlType.Enum,options:[\"p\",\"span\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\"],defaultValue:\"p\",displaySegmentedControl:false,description:\"More components at [Framerize](https://dub.sh/frmze-cc).\"}});TextReveal.displayName=\"Text Reveal\";\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TextReveal\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerIntrinsicWidth\":\"400\",\"framerDisableUnlink\":\"*\",\"framerIntrinsicHeight\":\"60\",\"framerSupportedLayoutHeight\":\"auto\",\"framerSupportedLayoutWidth\":\"any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TextReveal.map"],"mappings":"A,0PASG,SAAwBgB,EAAW,EAAM,CAAC,GAAK,CAAC,OAAK,aAAW,OAAK,iBAAe,uBAAqB,cAAY,YAAU,gBAAc,eAAa,aAAW,kBAAgB,OAAKC,EAAYC,EAAMC,EAAK,MAAM,GAAG,EAAQC,EAAWF,EAAM,OAAaG,EAAIrB,EAAO,IAAI,EAAO,CAAC,mBAAiBS,EAAU,CAAC,OAAOY,EAAI,OAAO,CAAC,GAAGC,E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