"use client"; /** * NewUsersStrip — the "new on the platform" discovery row at the top of the * home feed. Up to 5 accounts that joined in the last 24h, each rendered as a * card tile. The row scrolls horizontally (native touch/trackpad swipe + a * mouse drag-to-scroll affordance) and bleeds to the section's edges with a * gutter so tiles peek in from the sides. Renders nothing when empty. */ import { useRef } from "react"; import Link from "next/link"; import type { UserSummary } from "@/lib/social"; import { UserAvatar } from "@/components/ui/user-avatar"; export function NewUsersStrip({ users }: { users: UserSummary[] }) { const scrollRef = useRef(null); // Mouse drag-to-scroll. Touch/trackpad use native overflow scrolling, so we // only engage for mouse; `moved` suppresses the click that would otherwise // fire after a drag (and navigate to a profile). const drag = useRef({ down: false, startX: 0, startScroll: 0, moved: false, pointerId: -1, captured: false, }); if (users.length === 0) return null; function onPointerDown(e: React.PointerEvent) { if (e.pointerType !== "mouse") return; const el = scrollRef.current; if (!el) return; // Record the start but DON'T capture yet — capturing here would retarget // the click to this container, so a plain click on a card never reaches // the (no navigation). We capture only once a real drag starts. drag.current = { down: true, startX: e.clientX, startScroll: el.scrollLeft, moved: false, pointerId: e.pointerId, captured: false, }; } function onPointerMove(e: React.PointerEvent) { if (!drag.current.down) return; const el = scrollRef.current; if (!el) return; const dx = e.clientX - drag.current.startX; if (Math.abs(dx) > 4) { drag.current.moved = true; // Capture now so the drag keeps tracking even if the pointer leaves // the strip; a click (no movement) never gets here, so it navigates. if (!drag.current.captured) { el.setPointerCapture(drag.current.pointerId); drag.current.captured = true; } } if (drag.current.moved) el.scrollLeft = drag.current.startScroll - dx; } function onPointerUp() { if (!drag.current.down) return; drag.current.down = false; if (drag.current.captured) { scrollRef.current?.releasePointerCapture(drag.current.pointerId); drag.current.captured = false; } } function onClickCapture(e: React.MouseEvent) { if (drag.current.moved) { e.preventDefault(); e.stopPropagation(); } } return (

New to Prabhupāda Says

Welcome them by sending a follow request.

{/* Bleed to the page edges, with a matching inner gutter so the first and last tiles still have breathing room as they scroll past. The negative margin MUST match the feed container's horizontal padding (`main` is `px-4 sm:px-6`). It was `-mx-5` (20px) against a 16px mobile padding, so the row hung 4px past each edge and gave the whole document a horizontal scrollbar. Keep these three in lockstep with the page padding if it ever changes. */}
{users.map((u) => ( {u.name} @{u.handle} ))}
); }