Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 102 additions & 22 deletions components/navbar/FloatingNavbarClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,81 @@ import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "../ui/colla
const glassDropdown =
"relative overflow-hidden backdrop-blur-[60px] bg-gray-200/95 bg-gradient-to-br from-white/85 via-gray-200/95 to-gray-300/90 border border-gray-200/70 shadow-[0_22px_54px_rgba(15,23,42,0.22)]";

// Reusable component for mobile category dropdown (Technology/Community)
function MobileCategoryDropdown({
categoryName,
categoryState,
isOpen,
onOpenChange,
urlPrefix,
altTextFallback,
onMenuClose,
}: {
categoryName: string;
categoryState: any[];
isOpen: boolean;
onOpenChange: (open: boolean) => void;
urlPrefix: string;
altTextFallback: string;
onMenuClose: () => void;
}) {
return (
<Collapsible open={isOpen} onOpenChange={onOpenChange}>
<CollapsibleTrigger
className="flex items-center justify-between w-full px-5 py-3.5 rounded-2xl bg-white/60 ring-1 ring-neutral-200/50 hover:bg-white/80 hover:ring-orange-400/60 transition-all duration-200 shadow-sm hover:shadow-md min-h-[52px]"
aria-label={`Toggle ${categoryName} posts dropdown`}
>
<span className="font-semibold text-[15px] text-black/90">{categoryName}</span>
<ChevronDown className={`w-4 h-4 text-neutral-500 transition-transform duration-200 ${isOpen ? 'rotate-180':''}`} />
</CollapsibleTrigger>
<CollapsibleContent className="mt-2.5 space-y-2">
<div className="space-y-2 border-l-2 border-neutral-200/40 pl-4 ml-2">
{/* View All Link */}
<Link
href={urlPrefix}
onClick={onMenuClose}
className="flex items-center justify-between w-full px-4 py-3 rounded-xl bg-white/60 ring-1 ring-neutral-200/50 hover:bg-white/80 hover:ring-orange-400/60 transition-all duration-200 shadow-sm hover:shadow-md min-h-[48px]"
>
<span className="font-medium text-sm text-black/75">View All {categoryName} Posts</span>
<ChevronRight className="w-3.5 h-3.5 text-neutral-400" />
</Link>
{/* Latest Posts */}
{(categoryState.length ? categoryState.slice(0,4) : new Array(4).fill(null)).map((edge, i) => {
if (!edge) {
return (
<div key={`${categoryName.toLowerCase()}-mobile-skel-${i}`} className="rounded-xl overflow-hidden ring-1 ring-neutral-200/60 bg-white/60 animate-pulse p-3 space-y-2 min-h-[60px]">
<div className="h-3 w-3/4 bg-white/60 rounded" />
<div className="h-2 w-2/3 bg-white/50 rounded" />
</div>
);
}
const { node } = edge;
return (
<Link
key={node.slug}
href={`${urlPrefix}/${node.slug}`}
onClick={onMenuClose}
className="flex items-center gap-3 w-full px-4 py-3 rounded-xl bg-white/60 ring-1 ring-neutral-200/50 hover:bg-white/80 hover:ring-orange-400/60 transition-all duration-200 shadow-sm hover:shadow-md min-h-[60px]"
>
<div className="relative w-16 h-12 flex-shrink-0 rounded-md overflow-hidden bg-white/40">
{node?.featuredImage?.node?.sourceUrl && (
<Image src={node.featuredImage.node.sourceUrl} alt={node?.title || altTextFallback} fill className="object-cover" />
)}
</div>
<div className="flex-1 min-w-0">
<h4 className="text-[13px] font-semibold text-neutral-900 line-clamp-2">{node.title}</h4>
<p className="text-[11px] text-neutral-600 mt-0.5">{new Date(node.date).toLocaleDateString()} • {node.ppmaAuthorName || "Keploy"}</p>
</div>
<ChevronRight className="w-3.5 h-3.5 text-neutral-400 flex-shrink-0" />
</Link>
);
})}
</div>
</CollapsibleContent>
</Collapsible>
);
}

export default function FloatingNavbarClient({ techLatest = [], communityLatest = [] as any[], isScrolled = false }: { techLatest?: any[]; communityLatest?: any[]; isScrolled?: boolean }) {
const router = useRouter();
const [showTechDropdown, setShowTechDropdown] = useState(false);
Expand Down Expand Up @@ -190,7 +265,7 @@ export default function FloatingNavbarClient({ techLatest = [], communityLatest
<div className="relative basis-[38%] min-w-0">
<div className="relative w-full h-full min-h-[120px] aspect-[16/12]">
{node?.featuredImage?.node?.sourceUrl && (
<Image src={node.featuredImage.node.sourceUrl} alt={node.title} fill className="object-contain object-center bg-white/20" />
<Image src={node.featuredImage.node.sourceUrl} alt={node.title || "Technology post featured image"} fill className="object-contain object-center bg-white/20" />
)}
</div>
</div>
Expand Down Expand Up @@ -260,7 +335,7 @@ export default function FloatingNavbarClient({ techLatest = [], communityLatest
<div className="relative basis-[38%] min-w-0">
<div className="relative w-full h-full min-h-[120px] aspect-[16/12]">
{node?.featuredImage?.node?.sourceUrl && (
<Image src={node.featuredImage.node.sourceUrl} alt={node.title} fill className="object-contain object-center bg-white/20" />
<Image src={node.featuredImage.node.sourceUrl} alt={node.title || "Technology post featured image"} fill className="object-contain object-center bg-white/20" />
)}
</div>
</div>
Expand Down Expand Up @@ -447,29 +522,34 @@ export default function FloatingNavbarClient({ techLatest = [], communityLatest
<div className="relative z-10 flex flex-col flex-1 overflow-hidden min-h-0" style={{ maxHeight: 'calc(100vh - 18rem)' }}>
<div className="overflow-y-auto overscroll-contain px-5 py-5 flex-1 min-h-0">
<div className="space-y-2.5">
{/* Technology Link */}
<Link
href="/technology"
onClick={()=>setMobileMenuOpen(false)}
className="flex items-center justify-between w-full px-5 py-3.5 rounded-2xl bg-white/60 ring-1 ring-neutral-200/50 hover:bg-white/80 hover:ring-orange-400/60 transition-all duration-200 shadow-sm hover:shadow-md min-h-[52px]"
>
<span className="font-semibold text-[15px] text-black/90">Technology</span>
<ChevronRight className="w-4 h-4 text-neutral-500" />
</Link>
{/* Technology Collapsible */}
<MobileCategoryDropdown
categoryName="Technology"
categoryState={techState}
isOpen={mobileTechOpen}
onOpenChange={setMobileTechOpen}
urlPrefix="/technology"
altTextFallback="Technology post featured image"
onMenuClose={() => setMobileMenuOpen(false)}
/>

{/* Community Link */}
<Link
href="/community"
onClick={()=>setMobileMenuOpen(false)}
className="flex items-center justify-between w-full px-5 py-3.5 rounded-2xl bg-white/60 ring-1 ring-neutral-200/50 hover:bg-white/80 hover:ring-orange-400/60 transition-all duration-200 shadow-sm hover:shadow-md min-h-[52px]"
>
<span className="font-semibold text-[15px] text-black/90">Community</span>
<ChevronRight className="w-4 h-4 text-neutral-500" />
</Link>
{/* Community Collapsible */}
<MobileCategoryDropdown
categoryName="Community"
categoryState={communityState}
isOpen={mobileCommunityOpen}
onOpenChange={setMobileCommunityOpen}
urlPrefix="/community"
altTextFallback="Community post featured image"
onMenuClose={() => setMobileMenuOpen(false)}
/>

{/* Resources Collapsible */}
<Collapsible open={mobileResourcesOpen} onOpenChange={setMobileResourcesOpen}>
<CollapsibleTrigger className="flex items-center justify-between w-full px-5 py-3.5 rounded-2xl bg-white/60 ring-1 ring-neutral-200/50 hover:bg-white/80 hover:ring-orange-400/60 transition-all duration-200 shadow-sm hover:shadow-md min-h-[52px]">
<CollapsibleTrigger
className="flex items-center justify-between w-full px-5 py-3.5 rounded-2xl bg-white/60 ring-1 ring-neutral-200/50 hover:bg-white/80 hover:ring-orange-400/60 transition-all duration-200 shadow-sm hover:shadow-md min-h-[52px]"
aria-label="Toggle Resources dropdown"
>
<span className="font-semibold text-[15px] text-black/90">Resources</span>
<ChevronDown className={`w-4 h-4 text-neutral-500 transition-transform duration-200 ${mobileResourcesOpen ? 'rotate-180':''}`} />
</CollapsibleTrigger>
Expand Down Expand Up @@ -753,7 +833,7 @@ function SearchBox({ onClose, techLatest = [], communityLatest = [] as any[] }:
<Link href={toPath(node)} className="group flex w-full items-center gap-3 p-2 rounded-xl ring-1 ring-neutral-200/60 hover:ring-orange-400/60 transition-all bg-white/80 backdrop-blur-sm">
<div className="relative w-16 h-12 flex-shrink-0 rounded-md overflow-hidden bg-white/40">
{node?.featuredImage?.node?.sourceUrl && (
<Image src={node.featuredImage.node.sourceUrl} alt={node.title} fill className="object-cover" />
<Image src={node.featuredImage.node.sourceUrl} alt={node?.title || "Blog post featured image"} fill className="object-cover" />
)}
</div>
<div className="flex-1 min-w-0">
Expand Down