{"version":3,"file":"GradientHeadline.BovxPyLU.mjs","names":["useState","useMemo","__esmMin","init_npm_react_18_3_1","te","pe","_e","init_jsx_runtime","H","ce","addPropertyControls","ControlType","init_framer_BWFVvmND","GradientHeadline","props","animatedAngle","setAnimatedAngle","gradientAngle","animateGradient","animationId","startTime","animate","timestamp","currentRotation","animationSpeed","highlightList","highlightWords","w","wordRegex","words","text","renderWords","word","i","result","str","lastIndex","highlightRegex","match","idx","gradientFrom","gradientTo","font","Tag","tagOptions","tag","isFixedWidth","style","elementStyle","textColor","init_GradientHeadline","t"],"sources":["https:/framerusercontent.com/modules/kBZP0G3FjqZEi94WOYqk/bocSBECRdHlHXpDXA1BR/GradientHeadline.js"],"sourcesContent":["// Headline component with gradient highlight for selected words, tag selection, full font controls, and reusable text via prop\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useMemo,useEffect,useState,startTransition,createElement}from\"react\";import{addPropertyControls,ControlType}from\"framer\";const tagOptions=[\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"p\"];/**\n * Headline with Gradient Highlight\n *\n * - Select tag (h1-h6, p)\n * - Full font controls\n * - Highlight single/multiple words with gradient\n * - Text is reusable via prop\n * - Animated gradient rotation\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight auto\n */export default function GradientHeadline(props){const{text,tag,highlightWords,gradientFrom,gradientTo,gradientAngle,animateGradient,animationSpeed,font,style,textColor}=props;const[animatedAngle,setAnimatedAngle]=useState(gradientAngle);// Animation effect\nuseEffect(()=>{if(!animateGradient){setAnimatedAngle(gradientAngle);return;}let animationId;let startTime;const animate=timestamp=>{if(!startTime)startTime=timestamp;const elapsed=timestamp-startTime;const rotationSpeed=animationSpeed/1e3// Convert to rotations per second\n;const currentRotation=elapsed*rotationSpeed*360%360;startTransition(()=>{setAnimatedAngle(gradientAngle+currentRotation);});animationId=requestAnimationFrame(animate);};animationId=requestAnimationFrame(animate);return()=>{if(animationId){cancelAnimationFrame(animationId);}};},[animateGradient,gradientAngle,animationSpeed]);// Parse highlightWords (comma-separated or array)\nconst highlightList=useMemo(()=>{if(!highlightWords)return[];if(Array.isArray(highlightWords))return highlightWords;return highlightWords.split(\",\").map(w=>w.trim()).filter(Boolean);},[highlightWords]);// Split text into words, preserving spaces\nconst wordRegex=/\\S+|\\s+/g;const words=useMemo(()=>{if(!text)return[];return text.match(wordRegex)||[];},[text]);// Render with highlights\nconst renderWords=()=>{if(!highlightList.length)return words.map((word,i)=>/*#__PURE__*/_jsx(\"span\",{children:word},i));// Join all words into a string, find all highlight substrings, and split accordingly\nlet result=[];let str=text;let lastIndex=0;// Build a regex to match any of the highlight phrases (escape special chars)\nconst highlightRegex=new RegExp(highlightList.map(w=>w.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\")).join(\"|\"),\"gi\");let match;let idx=0;while((match=highlightRegex.exec(str))!==null){if(match.index>lastIndex){result.push(/*#__PURE__*/_jsx(\"span\",{children:str.slice(lastIndex,match.index)},idx++));}result.push(/*#__PURE__*/_jsx(\"span\",{style:{backgroundImage:`linear-gradient(${animatedAngle}deg, ${gradientFrom}, ${gradientTo})`,WebkitBackgroundClip:\"text\",WebkitTextFillColor:\"transparent\",backgroundClip:\"text\",color:undefined,fontWeight:font?.variant?.includes(\"Bold\")?\"bold\":undefined},children:match[0]},idx++));lastIndex=match.index+match[0].length;}if(lastIndex<str.length){result.push(/*#__PURE__*/_jsx(\"span\",{children:str.slice(lastIndex)},idx++));}return result;};const Tag=tagOptions.includes(tag)?tag:\"h1\";// Check if width is set to 100% (fill mode) or auto (fit content mode)\nconst isFixedWidth=style?.width===\"100%\";const elementStyle={...style,...font,margin:0,width:isFixedWidth?\"100%\":\"max-content\",minWidth:isFixedWidth?undefined:\"max-content\",display:isFixedWidth?\"block\":\"inline-block\",color:textColor};return /*#__PURE__*/createElement(Tag,{style:elementStyle},renderWords());}addPropertyControls(GradientHeadline,{text:{type:ControlType.String,title:\"Text\",defaultValue:\"This is a gradient headline\",displayTextArea:true},tag:{type:ControlType.Enum,title:\"Tag\",options:tagOptions,optionTitles:tagOptions.map(t=>t.toUpperCase()),defaultValue:\"h1\"},highlightWords:{type:ControlType.String,title:\"Highlight Words\",placeholder:\"word1, word2\",defaultValue:\"gradient\",description:\"Comma-separated words to highlight\"},gradientFrom:{type:ControlType.Color,title:\"Gradient From\",defaultValue:\"#0099FF\"},gradientTo:{type:ControlType.Color,title:\"Gradient To\",defaultValue:\"#FF5588\"},gradientAngle:{type:ControlType.Number,title:\"Gradient Angle\",defaultValue:90,min:0,max:360,unit:\"deg\",step:1,displayStepper:true},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"40px\",variant:\"Bold\",letterSpacing:\"-0.04em\",lineHeight:\"1em\"}},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},animateGradient:{type:ControlType.Boolean,title:\"Animate Gradient\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},animationSpeed:{type:ControlType.Number,title:\"Animation Speed\",defaultValue:1,min:.1,max:5,step:.1,unit:\"rps\",hidden:({animateGradient})=>!animateGradient}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"GradientHeadline\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"auto\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./GradientHeadline.map"],"mappings":"A,kMAYG,SAAwBa,EAAiB,EAAM,CAAC,GAAK,CAAC,OAAK,MAAI,iBAAe,eAAa,aAAW,gBAAc,kBAAgB,iBAAe,OAAK,QAAM,aAAWC,EAAW,CAACC,EAAcC,GAAkBhB,EAASiB,CAAa,EAC9OR,MAAc,CAAC,GAAG,CAACS,EAAgB,CAACF,EAAiBC,CAAa,EAAE,MAAO,CAAC,IAAIE,EA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