53 lines
1.3 KiB
TypeScript
53 lines
1.3 KiB
TypeScript
"use client";
|
|
|
|
/**
|
|
* PostViews — grid-only renderer for post lists.
|
|
*
|
|
* Renders a 3-up square grid (Instagram pattern). The previous
|
|
* Grid/Scroll tab toggle is gone — the scroll feed lives at
|
|
* /u/<handle>/posts and is reached by clicking a grid thumbnail
|
|
* (which sets `?hl=` and a hash anchor).
|
|
*
|
|
* Callers pass `hrefFor(post)` if they want each thumbnail to link to a
|
|
* specific URL (e.g. the scroll feed). When omitted, each card defaults
|
|
* to its source-passage URL.
|
|
*/
|
|
|
|
import type { Post } from "@/lib/social";
|
|
import { PostGridCard } from "./post-grid-card";
|
|
|
|
export function PostViews({
|
|
posts,
|
|
onDelete,
|
|
onUpdated,
|
|
emptyMessage,
|
|
hrefFor,
|
|
}: {
|
|
posts: Post[];
|
|
onDelete?: (id: string) => void;
|
|
onUpdated?: (updated: Post) => void;
|
|
emptyMessage?: string;
|
|
hrefFor?: (post: Post) => string;
|
|
}) {
|
|
if (posts.length === 0) {
|
|
return (
|
|
<p className="text-sm text-muted-foreground">
|
|
{emptyMessage ?? "Nothing here yet."}
|
|
</p>
|
|
);
|
|
}
|
|
return (
|
|
<div className="grid grid-cols-2 gap-2 sm:gap-3">
|
|
{posts.map((p) => (
|
|
<PostGridCard
|
|
key={p.id}
|
|
post={p}
|
|
onDelete={onDelete}
|
|
onUpdated={onUpdated}
|
|
href={hrefFor?.(p)}
|
|
/>
|
|
))}
|
|
</div>
|
|
);
|
|
}
|