mirror of
https://github.com/supabase/supabase.git
synced 2026-10-06 01:45:10 +03:00
AuthorAvatars now caps visible avatars at 4 (showing a "+N" badge for the rest) and collapses author names to "First Author, +N others" once there are more than two, instead of joining every name into one long string. A tooltip shows the full list. <img width="434" height="306" alt="Screenshot 2026-07-21 at 15 14 38" src="https://github.com/user-attachments/assets/507ce37e-b080-4dd6-bd49-ca694252cd72" /> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Enhancements** * Blog author displays now cap at three visible avatars and show a “+N” indicator for additional authors. * Author name labels are now summarized for multi-author posts (with full author names available via tooltip when applicable). * Featured post metadata (author, published date, reading time) has improved spacing, truncation behavior, and responsive visibility on smaller screens. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude <noreply@anthropic.com>
62 lines
2.0 KiB
TypeScript
62 lines
2.0 KiB
TypeScript
import Image from 'next/image'
|
|
import { Tooltip, TooltipContent, TooltipTrigger } from 'ui'
|
|
|
|
import type Author from '@/types/author'
|
|
|
|
interface Props {
|
|
authors: (Author | undefined)[]
|
|
showName?: boolean
|
|
size?: 'sm' | 'md'
|
|
}
|
|
|
|
const MAX_VISIBLE_AVATARS = 4
|
|
|
|
export default function AuthorAvatars({ authors, showName = true, size = 'sm' }: Props) {
|
|
const valid = authors.filter(Boolean) as Author[]
|
|
if (!valid.length) return null
|
|
|
|
const px = size === 'md' ? 'w-6 h-6' : 'w-5 h-5'
|
|
const visibleAvatars = valid.slice(0, MAX_VISIBLE_AVATARS)
|
|
const allNames = valid.map((a) => a.author).join(', ')
|
|
|
|
const nameLabel =
|
|
valid.length > 2
|
|
? `${valid[0].author}, +${valid.length - 1} other${valid.length - 1 > 1 ? 's' : ''}`
|
|
: allNames
|
|
|
|
const content = (
|
|
<div className="flex items-center gap-2 min-w-0" tabIndex={0}>
|
|
<div className="flex items-center -space-x-1.5 shrink-0">
|
|
{visibleAvatars.map((author, i) => (
|
|
<div key={i} className={`relative ${px} rounded-full bg-background shrink-0 p-px`}>
|
|
<div className="relative w-full h-full rounded-full border border-foreground/20 overflow-hidden">
|
|
{author.author_image_url && (
|
|
<Image
|
|
src={
|
|
typeof author.author_image_url === 'string'
|
|
? author.author_image_url
|
|
: (author.author_image_url as { url: string }).url
|
|
}
|
|
fill
|
|
className="object-cover"
|
|
alt={showName ? '' : author.author}
|
|
/>
|
|
)}
|
|
</div>
|
|
</div>
|
|
))}
|
|
</div>
|
|
{showName && <p className="text-foreground-lighter text-xs truncate min-w-0">{nameLabel}</p>}
|
|
</div>
|
|
)
|
|
|
|
return (
|
|
<Tooltip>
|
|
<TooltipTrigger asChild>{content}</TooltipTrigger>
|
|
<TooltipContent side="bottom" className="max-w-[260px]">
|
|
{allNames}
|
|
</TooltipContent>
|
|
</Tooltip>
|
|
)
|
|
}
|