{"version":3,"file":"Text_Opacity_Words.ixTkbc7T.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/rBGDMo7vIz9JWQj6FXq7/8NOHrgukm14vrN6hQWaN/Text_Opacity_Words.js"],"sourcesContent":["// Welcome to Code in Framer\n// Get Started: https://www.framer.com/developers\n// Text reveal component with scroll-based opacity animation\n// Features: Multiple paragraphs, adjustable opacity for faded/active states, customizable spacing\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{motion,useScroll,useTransform}from\"framer-motion\";import{useRef}from\"react\";const EachWord=({word,starting,ending,progress,fadedOpacity,activeOpacity,isBold,isHighlight,highlightColor,customHighlightColor,boldWeight})=>{const progressVal=useTransform(progress,[starting,ending],[fadedOpacity,activeOpacity]);// Support highlighting quoted phrases as one chunk\nlet shownWord=word;let inlineColor=customHighlightColor;let highlight=isHighlight;// Remove double quotes if present for display\nif(typeof word===\"string\"&&word.startsWith('\"')&&word.endsWith('\"')){shownWord=word.slice(1,-1);}return /*#__PURE__*/_jsxs(motion.span,{style:{opacity:progressVal,fontWeight:isBold?boldWeight:\"inherit\",color:highlight?inlineColor||highlightColor:undefined,padding:highlight?\"2px 4px\":\"0\",borderRadius:highlight?\"3px\":\"0\",transition:\"color 0.2s, opacity 0.5s\"},children:[shownWord,\" \"]});};/**\n * These annotations control how your component sizes\n * Learn more: https://www.framer.com/developers/#code-components-auto-sizing\n *\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export default function Text_Opacity_Words(props){const{passages,font,textColor,fadedOpacity,activeOpacity,paragraphSpacing,highlightColor,boldWeight}=props;const ref=useRef(null);const{scrollYProgress}=useScroll({target:ref,// Reveal completes when the component reaches the center of the viewport\noffset:[\"start center\",\"center center\"]});// Calculate total words across all passages\nconst allWords=passages.flatMap(passage=>passage.text.split(\" \"));const totalWords=allWords.length;let wordIndex=0;// Helper to detect {{highlight}} patterns\nfunction extractWordParts(word){// Match phrases within double quotes as highlight spans\nconst quotePhraseMatch=word.match(/^\"([^\"]*)\"$/);if(quotePhraseMatch){return{core:word,isHighlightBracket:true,customColor:null};}// Curly brace method fallback\nconst curlyMatch=word.match(/\\{{2}(.+?)(:[^}]*)?\\}{2}/);if(curlyMatch){const colorMatch=curlyMatch[2]?curlyMatch[2].slice(1):null// remove leading `:`\n;return{core:curlyMatch[1],isHighlightBracket:true,customColor:colorMatch};}return{core:word,isHighlightBracket:false,customColor:null};}return /*#__PURE__*/_jsx(\"div\",{ref:ref,style:{display:\"flex\",flexDirection:\"column\",gap:`${paragraphSpacing}px`},children:passages.map((passage,passageIdx)=>{const words=[];const matches=Array.from(passage.text.matchAll(/\"([^\"]+)\"|\\S+/g));for(const match of matches){if(match[1]){// Quoted phrase\nwords.push('\"'+match[1]+'\"');}else{words.push(match[0]);}}const boldWords=passage.boldWords||[];const highlightWords=passage.highlightWords||[];return /*#__PURE__*/_jsx(\"p\",{style:{...font,color:textColor,margin:0},children:words.map((word,idx)=>{const currentWordIndex=wordIndex++;const starting=currentWordIndex/totalWords;const ending=(currentWordIndex+1)/totalWords;const cleanWord=word.toLowerCase().replace(/[.,!?;:]/g,\"\");// Extract {{word}} or {{word:#color}} highlight markup\nconst{core,isHighlightBracket,customColor}=extractWordParts(word);const isBold=boldWords.some(bw=>bw.toLowerCase()===cleanWord);// Either explicit highlight list or bracketed\nconst isHighlight=isHighlightBracket||highlightWords.some(hw=>hw.toLowerCase()===cleanWord);// Add highlight for hardcoded phrases\nlet hardcodedHighlight=false;let hardcodedColor=undefined;const fullWordText=core.toLowerCase();if(passageIdx===0&&[\"batch -process resumes,\",\"no one ever saw your resume\",\"early access\",\"hidden jobs\",\"competition is low\"].some(phrase=>phrase===fullWordText)){hardcodedHighlight=true;// Color for each phrase\nif(fullWordText===\"batch -process resumes,\")hardcodedColor=\"#FF064E\";if(fullWordText===\"no one ever saw your resume\")hardcodedColor=\"#0A6EFF\";if(fullWordText===\"early access\")hardcodedColor=\"#5BDA47\";if(fullWordText===\"hidden jobs\")hardcodedColor=\"#B388FF\";if(fullWordText===\"competition is low\")hardcodedColor=\"#F88B2B\";}return /*#__PURE__*/_jsx(EachWord,{word:core,starting:starting,ending:ending,progress:scrollYProgress,fadedOpacity:fadedOpacity,activeOpacity:activeOpacity,isBold:isBold,isHighlight:isHighlight||hardcodedHighlight,highlightColor:hardcodedColor||customColor||highlightColor,customHighlightColor:undefined,boldWeight:boldWeight},idx);})},passageIdx);})});}addPropertyControls(Text_Opacity_Words,{passages:{type:ControlType.Array,title:\"Passages\",control:{type:ControlType.Object,controls:{text:{type:ControlType.String,title:\"Text\",displayTextArea:true,defaultValue:\"This is a passage that will reveal as you scroll.\"}}},defaultValue:[{text:\"This is the first passage. It will smoothly reveal as you scroll down the page, allowing you to {{batch -process resumes,:#FF064E}} so that {{no one ever saw your resume:#0A6EFF}} until it's {{early access:#5BDA47}} for the {{hidden jobs:#B388FF}} where {{competition is low:#F88B2B}}.\"},{text:\"This is the second passage. Each word fades in progressively creating a beautiful effect.\"},{text:\"This is the third passage. You can customize the opacity levels and spacing between paragraphs.\"}]},paragraphSpacing:{type:ControlType.Number,title:\"Paragraph Spacing\",defaultValue:24,min:0,max:100,step:1,unit:\"px\"},fadedOpacity:{type:ControlType.Number,title:\"Faded Opacity\",defaultValue:.1,min:0,max:1,step:.05},activeOpacity:{type:ControlType.Number,title:\"Active Opacity\",defaultValue:1,min:0,max:1,step:.05},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"32px\",variant:\"Regular\",letterSpacing:\"-0.02em\",lineHeight:\"1.4em\"}},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},highlightColor:{type:ControlType.Color,title:\"Highlight Color\",defaultValue:\"#FFE066\"},boldWeight:{type:ControlType.Number,title:\"Bold Weight\",min:400,max:900,step:100,defaultValue:700}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Text_Opacity_Words\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"any\",\"framerSupportedLayoutWidth\":\"any\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Text_Opacity_Words.map"],"mappings":"gPAYG,SAAwB,EAAmB,EAAM,CAAC,GAAK,CAAC,WAAS,OAAK,YAAU,eAAa,gBAAc,mBAAiB,iBAAe,cAAY,EAAY,EAAIA,EAAO,KAAK,CAAM,CAAC,mBAAiB,EAAU,CAAC,OAAO,EAChO,OAAO,CAAC,eAAe,gBAAgB,CAAC,CAAC,CAC+B,EAAzD,EAAS,QAAQ,GAAS,EAAQ,KAAK,MAAM,IAAI,CAAC,CAA2B,OAAW,EAAU,EACjH,SAAS,EAAiB,EAAK,CACkB,GAA1B,EAAK,MAAM,cAAc,CAAsB,MAAM,CAAC,KAAK,EAAK,mBAAmB,GAAK,YAAY,KAAK,CAChI,IAAM,EAAW,EAAK,MAAM,2BAA2B,CAAC,GAAG,EAAW,CAAC,IAAM,EAAW,EAAW,GAAG,EAAW,GAAG,MAAM,EAAE,CAAC,KAC5H,MAAM,CAAC,KAAK,EAAW,GAAG,mBAAmB,GAAK,YAAY,EAAW,CAAE,MAAM,CAAC,KAAK,EAAK,mBAAmB,GAAM,YAAY,KAAK,CAAE,OAAoB,EAAK,MAAM,CAAK,MAAI,MAAM,CAAC,QAAQ,OAAO,cAAc,SAAS,IAAI,GAAG,EAAiB,IAAI,CAAC,SAAS,EAAS,KAAK,EAAQ,IAAa,CAAC,IAAM,EAAM,EAAE,CAAO,EAAQ,MAAM,KAAK,EAAQ,KAAK,SAAS,iBAAiB,CAAC,CAAC,IAAI,IAAM,KAAS,EAAY,EAAM,GAC9Z,EAAM,KAAK,IAAI,EAAM,GAAG,IAAI,CAAO,EAAM,KAAK,EAAM,GAAG,CAAG,IAAM,EAAU,EAAQ,WAAW,EAAE,CAAO,EAAe,EAAQ,gBAAgB,E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