import { useId, useState, type MouseEvent } from "react"; import { ArrowUpRight, X } from "lucide-react"; import type { Announcement, AnnouncementAction } from "@paperclipai/shared"; import { Link } from "@/lib/router"; import { Button } from "@/components/ui/button"; import { Card } from "@/components/ui/card"; import { cn } from "@/lib/utils"; import { useAnnouncementAnimation } from "@/hooks/useAnnouncementAnimation"; export interface AnnouncementCardProps { announcement: Announcement; onDismiss: () => void; imageSrc?: string; animationSrc?: string; className?: string; } function Action({ action, primary, onClick }: { action: AnnouncementAction; primary?: boolean; onClick: () => void }) { const content = <>{action.label}{!primary && action.kind === "external" && }>; const onAuxClick = (event: MouseEvent) => { if (event.button === 1) onClick(); }; return ( {action.kind === "external" ? ( {content} ) : {content}} ); } export function AnnouncementCard({ announcement, onDismiss, imageSrc, animationSrc, className }: AnnouncementCardProps) { const titleId = useId(); const [failedImage, setFailedImage] = useState(null); const src = imageSrc ?? `/api/announcements/${encodeURIComponent(announcement.id)}/image`; const showImage = Boolean(announcement.image && failedImage !== src); const animationDocument = useAnnouncementAnimation(announcement, animationSrc); const showAnimation = Boolean(animationDocument); return ( { if (event.key === "Escape") { event.preventDefault(); event.stopPropagation(); onDismiss(); } }} > {(showImage || animationDocument) && {showImage && setFailedImage(src)} className="h-full w-full object-cover" />} {showAnimation && } } {announcement.eyebrow} {announcement.title} {announcement.description} {announcement.secondaryLink && } ); }
{announcement.eyebrow}
{announcement.description}