{"version":3,"file":"GradientText.nDSOGAgN.mjs","names":["useRef","useState","useMemo"],"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,SAAS,EAAY,EAAaA,EAAO,KAAK,CAAM,CAAC,EAAa,GAAiBC,EAAS,EAAE,CAAC,CAAM,CAAC,EAAgB,GAAoBA,EAAS,EAAgB,CAAO,EAAcC,OAAmB,CAAC,WAAW,yBAAyB,EAAc,IAAI,EAAY,GAAG,qBAAqB,OAAO,oBAAoB,cAAc,eAAe,OAAO,MAAM,cAAc,QAAQ,eAAe,EAAG,CAAC,EAAc,EAAY,CAAC,CAAC,MAAc,CAAC,GAAU,IAAS,OAAY,OAAO,IAAM,MAAmB,CAAC,IAAM,EAAM,EAAO,WAAe,EAAS,EAAmB,GAAO,IAAK,EAAS,EAAwB,GAAO,OAAM,EAAS,GAAgB,MAAoB,EAAmB,EAAS,CAAC,EAAqE,OAAlE,GAAgB,CAAC,EAAO,iBAAiB,SAAS,EAAe,KAAW,EAAO,oBAAoB,SAAS,EAAe,EAAG,CAAC,EAAe,EAAe,EAAgB,CAAC,CAA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