{"version":3,"file":"FloatingPillNavigation.DXnFAtHi.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/rl7d7Vf87QGDeF4IBjBw/qwsogf78G8HhJg4I53jE/FloatingPillNavigation.js"],"sourcesContent":["// Pill-shaped navigation with animated background that shifts between links on click\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{motion}from\"framer-motion\";import{useState,startTransition,useEffect,useRef}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function FloatingPillNavigation(props){const{items,backgroundColor,textColor,activeBackgroundColor,activeTextColor,padding,gap,font,activeLink=\"Home\",transition,linkPadding}=props;// Internal state for interactive clicking\nconst[internalActiveLink,setInternalActiveLink]=useState(activeLink);const navRef=useRef(null);const linkRef=useRef(null);const[navBorderRadius,setNavBorderRadius]=useState(50);const[linkBorderRadius,setLinkBorderRadius]=useState(25);// Sync internal state when activeLink prop changes\nuseEffect(()=>{startTransition(()=>{setInternalActiveLink(activeLink);});},[activeLink]);// Calculate border radii based on heights\nuseEffect(()=>{const updateBorderRadii=()=>{if(navRef.current){const navHeight=navRef.current.offsetHeight;setNavBorderRadius(navHeight/2);}if(linkRef.current){const linkHeight=linkRef.current.offsetHeight;setLinkBorderRadius(linkHeight/2);}};updateBorderRadii();// Use ResizeObserver to update when size changes\nconst resizeObserver=new ResizeObserver(updateBorderRadii);if(navRef.current)resizeObserver.observe(navRef.current);if(linkRef.current)resizeObserver.observe(linkRef.current);return()=>resizeObserver.disconnect();},[linkPadding,font,items]);const handleClick=(label,href,target)=>{startTransition(()=>{setInternalActiveLink(label);});// Navigate if href is provided\nif(href&&typeof window!==\"undefined\"){// Add https:// if the URL doesn't have a protocol and isn't a relative path\nlet finalHref=href;if(!href.match(/^(https?:\\/\\/|mailto:|tel:|#|\\/)/)){finalHref=`https://${href}`;}if(target===\"_blank\"){window.open(finalHref,\"_blank\");}else{window.location.href=finalHref;}}};return /*#__PURE__*/_jsx(\"nav\",{ref:navRef,style:{display:\"inline-flex\",backgroundColor,borderRadius:navBorderRadius,padding,gap,position:\"relative\",width:\"max-content\",userSelect:\"none\",WebkitUserSelect:\"none\",MozUserSelect:\"none\"},children:items.map((item,index)=>{const isActive=item.label===internalActiveLink;return /*#__PURE__*/_jsxs(\"div\",{ref:index===0?linkRef:null,onClick:()=>handleClick(item.label,item.href,item.target),style:{position:\"relative\",padding:linkPadding,textDecoration:\"none\",color:isActive?activeTextColor:textColor,cursor:\"pointer\",zIndex:1,transition:\"color 0.3s ease\",userSelect:\"none\",WebkitUserSelect:\"none\",MozUserSelect:\"none\",...font},children:[isActive&&/*#__PURE__*/_jsx(motion.div,{layoutId:\"activeBackground\",style:{position:\"absolute\",top:0,left:0,right:0,bottom:0,backgroundColor:activeBackgroundColor,borderRadius:linkBorderRadius,zIndex:-1},transition:transition}),item.label]},index);})});}addPropertyControls(FloatingPillNavigation,{activeLink:{type:ControlType.String,title:\"Active Link\",defaultValue:\"All products\",description:\"Enter the label of the link you want to be active initially\"},transition:{type:ControlType.Transition,title:\"Transition\",defaultValue:{type:\"spring\",stiffness:800,damping:60,mass:1}},linkPadding:{type:ControlType.Padding,title:\"Link Padding\",defaultValue:\"12px 22px 12px 22px\"},items:{type:ControlType.Array,control:{type:ControlType.Object,controls:{label:{type:ControlType.String,defaultValue:\"Link\"},href:{type:ControlType.String,title:\"Link To\",placeholder:\"/page or #section\",description:\"Optional: Link to a page or section\"},target:{type:ControlType.Enum,title:\"Open In\",options:[\"_self\",\"_blank\"],optionTitles:[\"Same Tab\",\"New Tab\"],defaultValue:\"_self\",hidden:props=>!props.href}}},defaultValue:[{label:\"All products\"},{label:\"Laptops\"},{label:\"Desktops\"},{label:\"Displays\"}]},backgroundColor:{type:ControlType.Color,defaultValue:\"#E8E8ED\"},textColor:{type:ControlType.Color,defaultValue:\"#000000\",title:\"Inactive Text\"},activeBackgroundColor:{type:ControlType.Color,defaultValue:\"#1D1D1F\",title:\"Active BG\"},activeTextColor:{type:ControlType.Color,defaultValue:\"#FFFFFF\",title:\"Active Text\"},padding:{type:ControlType.Number,defaultValue:6,min:0,max:20,step:1,unit:\"px\"},gap:{type:ControlType.Number,defaultValue:0,min:0,max:20,step:1,unit:\"px\"},font:{type:ControlType.Font,controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"17px\",variant:\"Regular\",letterSpacing:\"-0.37px\",lineHeight:\"20px\"}}});FloatingPillNavigation.displayName=\"Floating Pill Navigation\";\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"FloatingPillNavigation\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"auto\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./FloatingPillNavigation.map"],"mappings":"sQAIG,SAAwB,EAAuB,EAAM,CAAC,GAAK,CAAC,QAAM,kBAAgB,YAAU,wBAAsB,kBAAgB,UAAQ,MAAI,OAAK,aAAW,OAAO,aAAW,eAAa,EAC3L,CAAC,EAAmB,GAAuBA,EAAS,CAAU,EAAQ,EAAOC,EAAO,IAAI,EAAQ,EAAQA,EAAO,IAAI,EAAO,CAAC,EAAgB,GAAoBD,EAAS,EAAE,EAAO,CAAC,EAAiB,GAAqBA,EAAS,EAAE,EACxO,MAAc,CAAC,MAAoB,CAAC,EAAsB,CAAU,CAAE,CAAC,CAAE,EAAE,CAAC,CAAU,CAAC,EACvF,MAAc,CAAC,IAAM,MAAsB,CAAC,GAAG,EAAO,QAAQ,CAAC,IAAM,EAAU,EAAO,QAAQ,aAAa,EAAmB,EAAU,CAAC,CAAE,CAAC,GAAG,EAAQ,QAAQ,CAAC,IAAM,EAAW,EAAQ,QAAQ,aAAa,EAAoB,EAAW,CAAC,CAAE,CAAC,EAAE,EAAkB,EACrQ,IAAM,EAAe,IAAI,eAAe,CAAiB,EAAs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