2026-01-16 11:34:43 +02:00
|
|
|
"use client";
|
|
|
|
|
|
2026-01-20 19:49:34 +05:30
|
|
|
import { MessageSquarePlus } from "lucide-react";
|
2026-01-16 11:34:43 +02:00
|
|
|
import { Button } from "@/components/ui/button";
|
|
|
|
|
import { cn } from "@/lib/utils";
|
|
|
|
|
import type { CommentTriggerProps } from "./types";
|
|
|
|
|
|
2026-01-19 14:37:38 +02:00
|
|
|
export function CommentTrigger({ commentCount, isOpen, onClick, disabled }: CommentTriggerProps) {
|
2026-01-16 11:34:43 +02:00
|
|
|
const hasComments = commentCount > 0;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Button
|
2026-01-19 14:37:38 +02:00
|
|
|
variant={hasComments ? "outline" : isOpen ? "secondary" : "ghost"}
|
|
|
|
|
size="icon"
|
|
|
|
|
disabled={disabled}
|
2026-01-16 11:34:43 +02:00
|
|
|
className={cn(
|
2026-01-19 14:37:38 +02:00
|
|
|
"relative size-10 rounded-full transition-all duration-200",
|
|
|
|
|
hasComments
|
|
|
|
|
? "border-primary/50 bg-primary/5 text-primary hover:bg-primary/10 hover:border-primary"
|
|
|
|
|
: isOpen
|
|
|
|
|
? "text-foreground"
|
|
|
|
|
: "text-muted-foreground hover:text-foreground",
|
|
|
|
|
!hasComments && !isOpen && "opacity-0 group-hover:opacity-100",
|
|
|
|
|
disabled && "cursor-not-allowed opacity-50"
|
2026-01-16 11:34:43 +02:00
|
|
|
)}
|
|
|
|
|
onClick={onClick}
|
|
|
|
|
>
|
2026-01-20 19:49:34 +05:30
|
|
|
<MessageSquarePlus className={cn("size-5", (hasComments || isOpen) && "fill-current")} />
|
2026-01-16 11:34:43 +02:00
|
|
|
{hasComments && (
|
2026-01-19 14:37:38 +02:00
|
|
|
<span className="absolute -top-1 -right-1 flex size-5 items-center justify-center rounded-full bg-primary text-[10px] font-bold text-primary-foreground">
|
|
|
|
|
{commentCount > 9 ? "9+" : commentCount}
|
|
|
|
|
</span>
|
2026-01-16 11:34:43 +02:00
|
|
|
)}
|
|
|
|
|
</Button>
|
|
|
|
|
);
|
|
|
|
|
}
|