diff --git a/apps/landing/src/components/shared/ApiKeyWidget/apikey-widget.tsx b/apps/landing/src/components/shared/ApiKeyWidget/apikey-widget.tsx index 7e21611..9c85332 100644 --- a/apps/landing/src/components/shared/ApiKeyWidget/apikey-widget.tsx +++ b/apps/landing/src/components/shared/ApiKeyWidget/apikey-widget.tsx @@ -15,7 +15,7 @@ * Must be used within ApiKeyProvider context */ -import { useEffect, useRef } from 'react'; +import { useEffect, useRef, useState } from 'react'; import { useApiKey } from './apikey-context'; export function ApiKeyWidget() { @@ -35,6 +35,22 @@ export function ApiKeyWidget() { const containerRef = useRef(null); const inputRef = useRef(null); + const [isMobileContext, setIsMobileContext] = useState(false); + + // Detect mobile context (inside mobile dropdown menu) + useEffect(() => { + const checkContext = () => { + if (containerRef.current) { + // Check if ancestor has md:hidden class (mobile menu) + const mobileMenu = containerRef.current.closest('.md\\:hidden'); + setIsMobileContext(mobileMenu !== null); + } + }; + + checkContext(); + window.addEventListener('resize', checkContext); + return () => window.removeEventListener('resize', checkContext); + }, []); // Click outside to close useEffect(() => { @@ -72,13 +88,29 @@ export function ApiKeyWidget() { }; return ( -
- {!ui.expanded ? ( - // COLLAPSED STATE - Inline badge in nav + <> + {/* Backdrop for mobile expanded state */} + {ui.expanded && isMobileContext && ( +
setExpanded(false)} + aria-label="Close API key details" + /> + )} + +
+ {/* COLLAPSED STATE - Always rendered to maintain layout space */} - ) : ( - // EXPANDED STATE - Popup dropdown -
+ + {/* EXPANDED STATE - Rendered as overlay when expanded */} + {ui.expanded && ( +
{/* Header */}
@@ -244,6 +281,7 @@ export function ApiKeyWidget() { )}
)} -
+
+ ); } diff --git a/apps/landing/src/components/shared/SubsectionNav.tsx b/apps/landing/src/components/shared/SubsectionNav.tsx index b133450..0274f83 100644 --- a/apps/landing/src/components/shared/SubsectionNav.tsx +++ b/apps/landing/src/components/shared/SubsectionNav.tsx @@ -141,23 +141,37 @@ export const SubsectionNav = ({ items, currentPath, leftSlot, rightSlot }: Subse {/* Mobile Menu Overlay */} {mobileMenuOpen && (
-
- {items.map((item) => { - const active = isActive(item.href); - return ( - setMobileMenuOpen(false)} - className={` - block px-4 py-3 rounded-lg text-sm font-medium transition-colors - ${active ? 'bg-purple-500/10 text-purple-400' : 'text-gray-400 hover:text-white hover:bg-white/5'} - `} - > - {item.label} - - ); - })} +
+ {/* ApiKeyWidget - Mobile */} + {rightSlot && ( + <> +
+ {rightSlot} +
+ {/* Visual separator */} +
)}