{"version":3,"file":"Hello_text.C0XNfbwl.mjs","names":["React.useRef","React.useState","React.useCallback"],"sources":["https:/framerusercontent.com/modules/UowKNQhKBn5oFofcSatD/UlJRPQR5VD2qiSFyWSRL/Hello_text.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight auto\n */export default function FitTextMobile(props){const{text,font,color,breakpoint}=props;const boxRef=React.useRef(null);const measureRef=React.useRef(null);const[isMobile,setIsMobile]=React.useState(false);const[size,setSize]=React.useState(100);// Detect mobile based on the viewport width\nReact.useLayoutEffect(()=>{const check=()=>setIsMobile(window.innerWidth<=breakpoint);check();window.addEventListener(\"resize\",check);return()=>window.removeEventListener(\"resize\",check);},[breakpoint]);// Fit the text to the container width (mobile only)\nconst fit=React.useCallback(()=>{const box=boxRef.current;const probe=measureRef.current;if(!box||!probe)return;const textWidth=probe.getBoundingClientRect().width;if(textWidth>0)setSize(box.clientWidth/textWidth*100);},[]);React.useLayoutEffect(()=>{if(!isMobile)return;fit();const observer=new ResizeObserver(fit);if(boxRef.current)observer.observe(boxRef.current);return()=>observer.disconnect();},[isMobile,fit,text,font]);// Desktop and tablet: normal text with the font settings from the panel\nif(!isMobile){return /*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",...font,color,margin:0},children:text});}// Mobile: scale the text so it fills the width\nconst base={...font,color,whiteSpace:\"nowrap\",lineHeight:1,margin:0};return /*#__PURE__*/_jsxs(\"div\",{ref:boxRef,style:{width:\"100%\",overflow:\"hidden\"},children:[/*#__PURE__*/_jsx(\"span\",{ref:measureRef,style:{...base,fontSize:100,position:\"absolute\",visibility:\"hidden\",pointerEvents:\"none\"},children:text}),/*#__PURE__*/_jsx(\"div\",{style:{...base,fontSize:size},children:text})]});}FitTextMobile.displayName=\"Fit Text (Mobile)\";addPropertyControls(FitTextMobile,{text:{type:ControlType.String,title:\"Text\",defaultValue:\"Hello.\"},font:{type:ControlType.Font,controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:120,lineHeight:1}},color:{type:ControlType.Color,title:\"Color\",defaultValue:\"#fff\"},breakpoint:{type:ControlType.Number,title:\"Mobile Max\",defaultValue:810,min:320,max:1200,unit:\"px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"FitTextMobile\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\",\"framerSupportedLayoutWidth\":\"fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Hello_text.map"],"mappings":"oNAGG,SAAwB,EAAc,EAAM,CAAC,GAAK,CAAC,OAAK,OAAK,QAAM,cAAY,EAAY,EAAOA,EAAa,IAAI,EAAQ,EAAWA,EAAa,IAAI,EAAO,CAAC,EAAS,GAAaC,EAAe,EAAK,EAAO,CAAC,EAAK,GAASA,EAAe,GAAG,EACpP,MAA0B,CAAC,IAAM,MAAU,EAAY,EAAO,YAAY,CAAU,EAAkD,OAAhD,EAAM,EAAE,EAAO,iBAAiB,SAAS,CAAK,MAAY,EAAO,oBAAoB,SAAS,CAAK,CAAE,EAAE,CAAC,CAAU,CAAC,EACzM,IAAM,EAAIC,MAAsB,CAAC,IAAM,EAAI,EAAO,QAAc,EAAM,EAAW,QAAQ,GAAG,CAAC,GAAK,CAAC,EAAM,OAAO,IAAM,EAAU,EAAM,sBAAsB,CAAC,CAAC,MAAS,EAAU,GAAE,EAAQ,EAAI,YAAY,EAAU,GAAG,CAAE,EAAE,CAAC,CAAC,EAC9N,GADgO,MAA0B,CAAC,GAAG,CAAC,EAAS,OAAO,EAAI,EAAE,IAAM,EAAS,IAAI,eAAe,CAAG,EAAqD,OAAhD,EAAO,SAAQ,EAAS,QAAQ,EAAO,OAAO,MAAY,EAAS,WAAW,CAAE,EAAE,CAAC,EAAS,EAAI,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