{"version":3,"file":"GradientText.CU_RTSuL.mjs","names":[],"sources":["https:/framerusercontent.com/modules/5EZ2mZPd1TeL8GjtyOOW/EOAWZEloLnNelYZYt9YN/GradientText.js"],"sourcesContent":["// Text component with gradient per line, editable gradient and text with variable connection\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useMemo,useRef,useEffect,useState,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export default function GradientText(props){const{text=\"Hello World\\nThis is line two\\nAnd line three\",gradientStart=\"#4ECDC4\",gradientEnd=\"#FF6B6B\",gradientDirection=0,font,mobileFontSize=24,tabletFontSize=28,desktopFontSize=32,breakpoint=300,textAlignment=\"right\"}=props;const containerRef=useRef(null);const[wrappedLines,setWrappedLines]=useState([]);const[currentFontSize,setCurrentFontSize]=useState(desktopFontSize);const gradientStyle=useMemo(()=>{return{background:`linear-gradient(0deg, ${gradientStart}, ${gradientEnd})`,WebkitBackgroundClip:\"text\",WebkitTextFillColor:\"transparent\",backgroundClip:\"text\",color:\"transparent\",display:\"inline-block\"};},[gradientStart,gradientEnd]);useEffect(()=>{if(typeof window===\"undefined\")return;const updateFontSize=()=>{const width=window.innerWidth;let fontSize=desktopFontSize;if(width<=768){fontSize=mobileFontSize;}else if(width<=1024){fontSize=tabletFontSize;}startTransition(()=>setCurrentFontSize(fontSize));};updateFontSize();window.addEventListener(\"resize\",updateFontSize);return()=>window.removeEventListener(\"resize\",updateFontSize);},[mobileFontSize,tabletFontSize,desktopFontSize]);useEffect(()=>{if(typeof window===\"undefined\"||!containerRef.current)return;const container=containerRef.current;const computedStyle=window.getComputedStyle(container);const containerWidth=container.offsetWidth;// Create a temporary element to measure text\nconst tempElement=document.createElement(\"span\");tempElement.style.visibility=\"hidden\";tempElement.style.position=\"absolute\";tempElement.style.whiteSpace=\"nowrap\";tempElement.style.fontSize=`${currentFontSize}px`;tempElement.style.fontFamily=computedStyle.fontFamily;tempElement.style.fontWeight=computedStyle.fontWeight;tempElement.style.letterSpacing=computedStyle.letterSpacing;document.body.appendChild(tempElement);const lines=[];const paragraphs=text.split(\"\\n\");paragraphs.forEach(paragraph=>{if(paragraph.trim()===\"\"){lines.push(\"\");return;}const words=paragraph.split(\" \");let currentLine=\"\";words.forEach((word,index)=>{const testLine=currentLine?`${currentLine} ${word}`:word;tempElement.textContent=testLine;if(tempElement.offsetWidth<=containerWidth||currentLine===\"\"){currentLine=testLine;}else{lines.push(currentLine);currentLine=word;}if(index===words.length-1){lines.push(currentLine);}});});document.body.removeChild(tempElement);startTransition(()=>setWrappedLines(lines));},[text,font,currentFontSize,props.style?.width]);const isFixedWidth=props?.style&&props.style.width===\"100%\";return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{...props.style,position:\"relative\",display:\"flex\",flexDirection:\"column\",alignItems:textAlignment===\"left\"?\"flex-start\":textAlignment===\"center\"?\"center\":\"flex-end\",...isFixedWidth?{}:{width:\"max-content\"},...font,fontSize:`${currentFontSize}px`,textWrap:\"balance\"},children:wrappedLines.map((line,index)=>/*#__PURE__*/_jsx(\"span\",{style:{...gradientStyle,display:\"block\",margin:0,padding:0,lineHeight:font?.lineHeight||\"1.2em\",minHeight:line.trim()===\"\"?\"1em\":\"auto\"},children:line||\"\\xa0\"},index))});}addPropertyControls(GradientText,{text:{type:ControlType.String,title:\"Text\",defaultValue:\"Hello World\\nThis is line two\\nAnd line three\",displayTextArea:true},gradientStart:{type:ControlType.Color,title:\"Gradient Start\",defaultValue:\"#FF6B6B\"},gradientEnd:{type:ControlType.Color,title:\"Gradient End\",defaultValue:\"#4ECDC4\"},textAlignment:{type:ControlType.Enum,title:\"Text Alignment\",options:[\"left\",\"center\",\"right\"],optionTitles:[\"Left\",\"Center\",\"Right\"],defaultValue:\"right\",displaySegmentedControl:true},mobileFontSize:{type:ControlType.Number,title:\"Mobile Font Size\",defaultValue:24,min:8,max:100,step:1,unit:\"px\"},tabletFontSize:{type:ControlType.Number,title:\"Tablet Font Size\",defaultValue:28,min:8,max:100,step:1,unit:\"px\"},desktopFontSize:{type:ControlType.Number,title:\"Desktop Font Size\",defaultValue:32,min:8,max:100,step:1,unit:\"px\"},font:{type:ControlType.Font,title:\"Font\",defaultValue:{variant:\"Bold\",letterSpacing:\"-0.08em\",lineHeight:\"1.2em\"},controls:\"extended\",defaultFontType:\"sans-serif\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"GradientText\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./GradientText.map"],"mappings":"yUAIG,SAAwB,EAAa,EAAM,CAAC,GAAK,CAAC,OAAK;;gBAAgD,gBAAc,UAAU,cAAY,UAAU,oBAAkB,EAAE,OAAK,iBAAe,GAAG,iBAAe,GAAG,kBAAgB,GAAG,aAAW,IAAI,gBAAc,QAAQ,CAAC,EAAY,EAAa,EAAO,KAAK,CAAM,CAAC,EAAa,EAAgB,CAAC,EAAS,CAAE,EAAC,CAAM,CAAC,EAAgB,EAAmB,CAAC,EAAS,EAAgB,CAAO,EAAc,EAAQ,KAAW,CAAC,YAAY,wBAAwB,EAAc,IAAI,EAAY,GAAG,qBAAqB,OAAO,oBAAoB,cAAc,eAAe,OAAO,MAAM,cAAc,QAAQ,cAAe,GAAG,CAAC,EAAc,CAAY,EAAC,CAAwc,AAAvc,EAAU,IAAI,CAAC,GAAU,WAAqB,OAAO,IAAM,EAAe,IAAI,CAAC,IAAM,EAAM,EAAO,WAAe,EAAS,EAAsG,AAAnF,GAAO,IAAK,EAAS,EAAwB,GAAO,OAAM,EAAS,GAAgB,EAAgB,IAAI,EAAmB,EAAS,CAAC,AAAE,EAAmE,MAAlE,IAAgB,CAAC,EAAO,iBAAiB,SAAS,EAAe,CAAO,IAAI,EAAO,oBAAoB,SAAS,E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