{"version":3,"file":"TextCycle.DUKRDDAn.mjs","names":["useState","_Fragment"],"sources":["https:/framerusercontent.com/modules/htL8xlNCPPNJfZfmRjS5/TbgFRa9BDGNQAG1fYwH1/TextCycle.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import{useEffect,useState}from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";import{motion,AnimatePresence}from\"framer-motion\";/**\n * TEXT CYCLE\n *\n * A headline with a static lead-in and a highlighted phrase that\n * cycles through a list. Highlighted phrase animates in/out with a\n * choice of transitions.\n *\n * @framerIntrinsicWidth 600\n * @framerIntrinsicHeight 240\n *\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export default function TextCycle(props){const{staticText,cyclePhrases,breakBeforeCycle,font,textColor,cycleColor,speed,animation,duration,stagger}=props;// The extended Font control already carries family, weight, size, line\n// height, letter spacing AND alignment as a ready-to-spread style object.\nconst typography=font;const align=font&&font.textAlign||\"left\";const phrases=cyclePhrases&&cyclePhrases.length>0?cyclePhrases:[\"known shoppers.\"];const isStatic=RenderTarget.current()!==RenderTarget.preview;const[index,setIndex]=useState(0);// Advance the cycle on an interval (only in live preview / published site)\nuseEffect(()=>{if(isStatic||phrases.length<2)return;const id=setInterval(()=>setIndex(i=>(i+1)%phrases.length),Math.max(speed,duration*1e3+200));return()=>clearInterval(id);},[isStatic,phrases.length,speed,duration]);const current=phrases[index%phrases.length];// ---- Whole-phrase variants (slide / fade) -------------------------\nconst slideTop={initial:{y:\"-110%\",opacity:0},animate:{y:\"0%\",opacity:1},exit:{y:\"110%\",opacity:0}};const slideBottom={initial:{y:\"110%\",opacity:0},animate:{y:\"0%\",opacity:1},exit:{y:\"-110%\",opacity:0}};const fade={initial:{opacity:0},animate:{opacity:1},exit:{opacity:0}};const transition={duration,ease:[.22,1,.36,1]};const cycleStyle={...typography,color:cycleColor,display:\"inline-block\",whiteSpace:\"pre\"};// Renders the currently active phrase based on the chosen animation\nfunction renderCycle(){// --- staggered: by word / by letter ---------------------------\nif(animation===\"word\"||animation===\"letter\"){const units=animation===\"word\"?current.split(\" \").map((w,i,a)=>i<a.length-1?w+\" \":w):current.split(\"\");const container={animate:{transition:{staggerChildren:stagger}},exit:{transition:{staggerChildren:stagger/2,staggerDirection:-1}}};const child={initial:{y:\"0.6em\",opacity:0},animate:{y:\"0em\",opacity:1,transition},exit:{y:\"-0.4em\",opacity:0,transition:{duration:duration/2}}};return /*#__PURE__*/_jsx(motion.span,{variants:container,initial:\"initial\",animate:\"animate\",exit:\"exit\",style:{...cycleStyle,whiteSpace:\"pre-wrap\"},children:units.map((u,i)=>/*#__PURE__*/_jsx(motion.span,{variants:child,style:{display:\"inline-block\",whiteSpace:\"pre\"},children:u},i))},index);}// --- whole phrase: slide top / bottom / fade ------------------\nconst variant=animation===\"slideTop\"?slideTop:animation===\"slideBottom\"?slideBottom:fade;return /*#__PURE__*/_jsx(motion.span,{initial:\"initial\",animate:\"animate\",exit:\"exit\",variants:variant,transition:transition,style:cycleStyle,children:current},index);}return /*#__PURE__*/_jsx(\"div\",{style:{...typography,color:textColor,width:\"100%\",height:\"100%\",display:\"flex\",flexDirection:\"column\",justifyContent:\"center\"},children:/*#__PURE__*/_jsxs(\"div\",{style:{textAlign:align,width:\"100%\"},children:[staticText?/*#__PURE__*/_jsxs(_Fragment,{children:[staticText,breakBeforeCycle?/*#__PURE__*/_jsx(\"br\",{}):\" \"]}):null,/*#__PURE__*/_jsx(\"span\",{style:{display:\"inline-block\",overflow:\"hidden\",verticalAlign:\"bottom\",lineHeight:typography&&typography.lineHeight},children:/*#__PURE__*/_jsx(AnimatePresence,{mode:\"wait\",children:renderCycle()})})]})});}TextCycle.defaultProps={staticText:\"Turn anonymous visitors into\",cyclePhrases:[\"known shoppers.\",\"loyal customers.\",\"real revenue.\"],breakBeforeCycle:true,textColor:\"#FFFFFF\",cycleColor:\"#B6E62E\",speed:2500,animation:\"slideTop\",duration:.6,stagger:.06};addPropertyControls(TextCycle,{staticText:{type:ControlType.String,title:\"Static Text\",placeholder:\"Lead-in text\",displayTextArea:true},cyclePhrases:{type:ControlType.Array,title:\"Cycle Text\",control:{type:ControlType.String,placeholder:\"Phrase\"},defaultValue:[\"known shoppers.\",\"loyal customers.\",\"real revenue.\"]},breakBeforeCycle:{type:ControlType.Boolean,title:\"Line Break\",enabledTitle:\"New line\",disabledTitle:\"Inline\",defaultValue:true},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",displayFontSize:true,displayTextAlignment:true,defaultFontType:\"sans-serif\",defaultValue:{fontSize:64,variant:\"Bold\",lineHeight:1.1,letterSpacing:-.02,textAlign:\"left\"}},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#FFFFFF\"},cycleColor:{type:ControlType.Color,title:\"Cycle Color\",defaultValue:\"#B6E62E\"},animation:{type:ControlType.Enum,title:\"Animation\",options:[\"slideTop\",\"slideBottom\",\"fade\",\"word\",\"letter\"],optionTitles:[\"Slide In Top\",\"Slide In Bottom\",\"Fade In\",\"Load By Word\",\"Load By Letter\"],defaultValue:\"slideTop\"},speed:{type:ControlType.Number,title:\"Cycle Speed\",min:800,max:1e4,step:100,unit:\"ms\",defaultValue:2500},duration:{type:ControlType.Number,title:\"Anim Duration\",min:.1,max:2,step:.05,unit:\"s\",defaultValue:.6},stagger:{type:ControlType.Number,title:\"Stagger\",min:.01,max:.3,step:.01,unit:\"s\",defaultValue:.06,hidden:props=>props.animation!==\"word\"&&props.animation!==\"letter\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TextCycle\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"any\",\"framerIntrinsicWidth\":\"600\",\"framerIntrinsicHeight\":\"240\",\"framerSupportedLayoutWidth\":\"any\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TextCycle.map"],"mappings":"8PAYG,S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