{"version":3,"file":"NavStaggerLink.CYEdT5F7.mjs","names":["useRef","useState","useMemo","useCallback"],"sources":["https:/framerusercontent.com/modules/08WTk74Svy1a3dTOCBZJ/vE1yxR6nKkZ6gYTfIMV1/NavStaggerLink.js"],"sourcesContent":["// Instructions: Create a Framer component that follows the Framer component rules and achieves the user's goal.\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useInView}from\"framer-motion\";import{startTransition,useCallback,useEffect,useMemo,useRef,useState}from\"react\";function cssEasingFromTransition(t,fallback){const ease=t?.ease;if(!ease)return fallback;if(typeof ease===\"string\")return ease;if(Array.isArray(ease)&&ease.length===4&&ease.every(n=>typeof n===\"number\")){return`cubic-bezier(${ease.join(\", \")})`;}return fallback;}/**\n * NavStaggerLink\n *\n * @framerIntrinsicWidth 160\n * @framerIntrinsicHeight 44\n *\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function NavStaggerLink(props){const{label=\"Work,\",font,baseColor=\"#131410\",hoverColor=\"#F63D18\",transition,stagger=.0125,direction=\"up\",transform=\"none\",padding=\"0px\",trigger=\"hover\",onAppear,onHover,style}=props;const spanRef=useRef(null);const isInView=useInView(spanRef,{once:true});// oldString: triggers\nconst[appeared,setAppeared]=useState(trigger===\"hover\");useEffect(()=>{if(!isInView)return;if(trigger===\"appear\"||trigger===\"both\"){startTransition(()=>setAppeared(true));onAppear?.();}},[isInView,onAppear,trigger]);const[hover,setHover]=useState(false);const translate=direction===\"up\"?\"-1em\":\"1em\";const incomingTranslate=direction===\"up\"?\"1em\":\"-1em\";const chars=useMemo(()=>Array.from(label),[label]);const setHoverSafe=useCallback(next=>{startTransition(()=>setHover(next));},[]);const hoverEnabled=trigger===\"hover\"||trigger===\"both\";const onEnter=useCallback(()=>{if(!hoverEnabled)return;onHover?.();setHoverSafe(true);},[hoverEnabled,onHover,setHoverSafe]);const onLeave=useCallback(()=>{if(!hoverEnabled)return;setHoverSafe(false);},[hoverEnabled,setHoverSafe]);const duration=typeof transition?.duration===\"number\"?transition.duration:.6;const easing=cssEasingFromTransition(transition,\"cubic-bezier(0.22, 1, 0.36, 1)\");// Opacity transitions ~35% as long as the transform slide, capped at 200ms.\n// This makes each char \"lock in\" visually early, then complete its slide\n// crisply instead of fading throughout the travel.\nconst opacityDuration=Math.min(duration*.35,.2);const wrapStyle=useMemo(()=>({...style,position:\"relative\",display:\"inline-block\",overflow:\"hidden\",textTransform:transform,padding,color:hover?hoverColor:baseColor,transition:`color ${duration}s ${easing}`,cursor:\"pointer\",verticalAlign:\"top\",whiteSpace:\"nowrap\",...font}),[style,hover,hoverColor,baseColor,duration,easing,transform,padding,font]);const charStyle=useCallback(i=>({display:\"inline-block\",position:\"relative\",// translateZ(0) keeps the char on the compositor layer throughout,\n    // even when the transform reaches its rest state. This prevents\n    // the micro-jank from the GPU re-promoting the layer.\n    transform:!appeared?`translateY(${incomingTranslate}) translateZ(0)`:hover?`translateY(${translate}) translateZ(0)`:\"translateY(0) translateZ(0)\",opacity:appeared?1:0,transition:`transform ${duration}s ${easing}, opacity ${opacityDuration}s ${easing}`,transitionDelay:`${i*stagger}s`,whiteSpace:\"pre\",backfaceVisibility:\"hidden\",willChange:\"transform, opacity\"}),[appeared,hover,incomingTranslate,translate,duration,easing,opacityDuration,stagger]);const incomingCharStyle=useCallback(i=>({display:\"inline-block\",position:\"relative\",transform:hover?\"translateY(0) translateZ(0)\":`translateY(${incomingTranslate}) translateZ(0)`,opacity:hover?1:0,transition:`transform ${duration}s ${easing}, opacity ${opacityDuration}s ${easing}`,transitionDelay:`${i*stagger}s`,whiteSpace:\"pre\",backfaceVisibility:\"hidden\",willChange:\"transform, opacity\"}),[hover,incomingTranslate,duration,easing,opacityDuration,stagger]);return /*#__PURE__*/_jsx(\"span\",{ref:spanRef,style:wrapStyle,onMouseEnter:onEnter,onMouseLeave:onLeave,onFocus:onEnter,onBlur:onLeave,onPointerEnter:onEnter,onPointerLeave:onLeave,\"aria-label\":label,role:\"text\",tabIndex:0,children:/*#__PURE__*/_jsxs(\"span\",{style:{position:\"relative\",display:\"inline-block\",minWidth:\"max-content\"},children:[/*#__PURE__*/_jsx(\"span\",{\"aria-hidden\":hover,style:{display:\"inline-block\"},children:chars.map((ch,i)=>/*#__PURE__*/_jsx(\"span\",{style:charStyle(i),children:ch},`out-${ch}-${i}`))}),/*#__PURE__*/_jsx(\"span\",{\"aria-hidden\":!hover,style:{position:\"absolute\",top:0,left:0,display:\"inline-block\",pointerEvents:\"none\"},children:chars.map((ch,i)=>/*#__PURE__*/_jsx(\"span\",{style:incomingCharStyle(i),children:ch},`in-${ch}-${i}`))})]})});}addPropertyControls(NavStaggerLink,{trigger:{type:ControlType.Enum,title:\"Trigger\",options:[\"hover\",\"appear\",\"both\"],optionTitles:[\"Hover\",\"On Appear\",\"Both\"],defaultValue:\"hover\"},label:{type:ControlType.String,title:\"Label\",defaultValue:\"Work,\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"32px\",variant:\"Bold\",letterSpacing:\"-0.02em\",lineHeight:\"1.1em\"}},transform:{type:ControlType.Enum,title:\"Transform\",options:[\"none\",\"capitalize\",\"uppercase\",\"lowercase\"],optionTitles:[\"None\",\"Capitalise\",\"Uppercase\",\"Lowercase\"],defaultValue:\"none\"},padding:{type:ControlType.Padding,title:\"Padding\",defaultValue:\"0px\"},baseColor:{type:ControlType.Color,title:\"Color\",defaultValue:\"#131410\"},hoverColor:{type:ControlType.Color,title:\"Hover\",defaultValue:\"#F63D18\"},transition:{type:ControlType.Transition,title:\"Transition\"},stagger:{type:ControlType.Number,title:\"Stagger\",defaultValue:.0125,min:0,max:.2,step:.0025,unit:\"s\"},direction:{type:ControlType.Enum,title:\"Direction\",options:[\"up\",\"down\"],optionTitles:[\"Up\",\"Down\"],defaultValue:\"up\",displaySegmentedControl:true,description:\"Crafted with ❤️ by [Cee](https://x.com/ohheycobi)\"},onAppear:{type:ControlType.EventHandler,title:\"On Appear\"},onHover:{type:ControlType.EventHandler,title:\"On Hover\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"NavStaggerLink\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"auto\",\"framerIntrinsicHeight\":\"44\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"auto\",\"framerIntrinsicWidth\":\"160\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./NavStaggerLink.map"],"mappings":"qQACmO,SAAS,EAAwB,EAAE,EAAS,CAAC,IAAM,EAAK,GAAG,KAA2L,OAAlL,EAAwB,OAAO,GAAO,SAAgB,EAAQ,MAAM,QAAQ,EAAK,EAAE,EAAK,SAAS,GAAG,EAAK,MAAM,GAAG,OAAO,GAAI,SAAS,CAAQ,gBAAgB,EAAK,KAAK,KAAK,CAAC,GAAW,EAA7K,EAQhT,SAAwB,EAAe,EAAM,CAAC,GAAK,CAAC,QAAM,QAAQ,OAAK,YAAU,UAAU,aAAW,UAAU,aAAW,UAAQ,MAAM,YAAU,KAAK,YAAU,OAAO,UAAQ,MAAM,UAAQ,QAAQ,WAAS,UAAQ,SAAO,EAAY,EAAQA,EAAO,KAAK,CAAO,EAAS,EAAU,EAAQ,CAAC,KAAK,GAAK,CAAC,CAC3S,CAAC,EAAS,GAAaC,EAAS,IAAU,QAAQ,CAAC,MAAc,CAAK,IAAmB,IAAU,UAAU,IAAU,UAAQ,MAAoB,EAAY,GAAK,CAAC,CAAC,KAAY,GAAI,CAAC,EAAS,EAAS,EAAQ,CAAC,CAAC,GAAK,CAAC,EAAM,GAAUA,EAAS,GAAM,CAAO,EAAU,IAAY,KAAK,OAAO,MAAY,EAAkB,IAAY,KAAK,MAAM,OAAa,EAAMC,MAAY,MAAM,KAAK,EAAM,CAAC,CAAC,EAAM,CAAC,CAAO,EAAaC,EAAY,GAAM,CAAC,MAAoB,EAAS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