Files
supabase/apps/www/components/Contribute/RepliesList.tsx
Danny White 476d4a5851 refactor(ui): drop redundant Button variant="default" props (#50161)
## What kind of change does this PR introduce?

Mechanical cleanup on top of the Button default-variant change (#50160).

## What is the current behavior?

Many callsites still pass `variant="default"` even though that is now
the component default.

## What is the new behavior?

Removes redundant static `variant="default"` from legacy `Button` and
`ButtonTooltip` callsites. Keeps explicit defaults where they document
the API:

- `button-default.tsx` and `button-sizes.tsx` demos
- `DocsButton`, which pins neutral styling at the wrapper boundary

## To test

Studio:

- [Auth → Rate
Limits](https://studio-staging-2s957kwc4-supabase.vercel.app/dashboard/project/_/auth/rate-limits):
dirty the form so Cancel appears; Cancel stays neutral, Save stays green
- [Project Settings → API
Keys](https://studio-staging-2s957kwc4-supabase.vercel.app/dashboard/project/_/settings/api-keys):
`DocsButton` in the header actions stays neutral

Design system:

- [Design system →
Button](https://design-system-git-dnywh-dc924ac1-supabase.vercel.app/design-system/docs/components/button):
`button-default` / `button-sizes` still show explicit default styling;
Primary (green) is restricted to the Primary section (and `asChild`)

WWW:

- [www → Brand
assets](https://zone-www-dot-com-git-dnywh-dc924ac1-supabase.vercel.app/brand-assets):
Download logo kit / Download button kit stay neutral
2026-09-11 17:05:26 +10:00

102 lines
3.5 KiB
TypeScript

'use client'
import Link from 'next/link'
import { useState } from 'react'
import ReactMarkdown from 'react-markdown'
import remarkGfm from 'remark-gfm'
import { Badge, Button, Card, CardContent, CardFooter, CardHeader, CardTitle } from 'ui'
import { markdownComponents } from './markdownComponents'
interface Reply {
id: string
content: string | null
author: string | null
ts: string | null
external_activity_url: string | null
}
interface RepliesListProps {
replies: Reply[]
questionAuthor: string | null
totalReplyCount?: number
}
export function RepliesList({ replies, questionAuthor, totalReplyCount }: RepliesListProps) {
const [isExpanded, setIsExpanded] = useState(false)
const hasMoreThanThree = replies.length > 3
const displayedReplies = isExpanded ? replies : replies.slice(0, 3)
if (replies.length === 0) {
return null
}
const displayCount = totalReplyCount || replies.length
return (
<div className="flex flex-col gap-3">
<Card className="relative">
<CardHeader>
<CardTitle>
Replies{' '}
<span className="text-foreground-muted tabular-nums font-normal">({displayCount})</span>
</CardTitle>
</CardHeader>
<CardContent className="flex flex-col p-0">
{displayedReplies.map((reply, index) => {
const timestamp = reply.ts ? new Date(reply.ts).toLocaleString() : null
const isOP = reply.author === questionAuthor
return (
<div key={reply.id} className="border-b border-border last:border-b-0">
<div className="px-6 py-6">
<div className="text-sm text-foreground mb-3 min-w-0">
<ReactMarkdown components={markdownComponents} remarkPlugins={[remarkGfm]}>
{reply.content || ''}
</ReactMarkdown>
</div>
<div className="flex items-center gap-x-1 text-xs text-foreground-lighter">
{reply.author && (
<>
{isOP && <Badge variant="success">OP</Badge>}
<Link
href={`/contribute/u/${encodeURIComponent(reply.author)}`}
className="hover:text-foreground transition-colors"
>
{reply.author}
</Link>
</>
)}
{reply.author && timestamp && <span>·</span>}
{timestamp && reply.external_activity_url ? (
<a
href={reply.external_activity_url}
target="_blank"
rel="noopener noreferrer"
className="hover:text-foreground transition-colors"
>
{timestamp}
</a>
) : (
timestamp && <span>{timestamp}</span>
)}
</div>
</div>
</div>
)
})}
</CardContent>
{hasMoreThanThree && (
<CardFooter className="flex justify-center">
<Button size="tiny" onClick={() => setIsExpanded(!isExpanded)} className="w-min">
{isExpanded
? 'Show fewer replies'
: `Show ${replies.length - 3} more ${replies.length - 3 === 1 ? 'reply' : 'replies'}`}
</Button>
</CardFooter>
)}
</Card>
</div>
)
}