SPB Git

Repository Public MIT

answer-actions.tsx 2.1 KB 52 lines tsx

1import { useState } from "react";2import { Check, Copy } from "lucide-react";3import { Button } from "@/components/ui/button";4import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";5import { DownloadButtons } from "./download-buttons";6import { ShareButton } from "./share-button";7import { cn } from "@/lib/utils";89interface AnswerActionsProps {10  question: string;11  answer: string;12  toolResults?: unknown[];13  sources?: unknown[];14  customPythonFigures?: unknown[];15  figureUrls?: string[];16  contentRef?: React.RefObject<HTMLElement>;17  className?: string;18  /** masque le partage (rapport déjà partagé) */19  hideShare?: boolean;20}2122/** Barre d'actions sous une réponse : copier, exporter, partager. */23export function AnswerActions({ question, answer, toolResults = [], sources = [], customPythonFigures = [], figureUrls = [], contentRef, className, hideShare }: AnswerActionsProps) {24  const [copied, setCopied] = useState(false);2526  const copy = async () => {27    try {28      await navigator.clipboard.writeText(answer);29      setCopied(true);30      setTimeout(() => setCopied(false), 1600);31    } catch { /* ignore */ }32  };3334  return (35    <div className={cn("flex flex-wrap items-center gap-1.5", className)} data-testid="share-button-container">36      <Tooltip>37        <TooltipTrigger asChild>38          <Button variant="ghost" size="sm" onClick={copy} className="h-8 rounded-lg px-2.5 text-muted-foreground hover:text-foreground" aria-label="Copier la réponse">39            {copied ? <Check className="h-4 w-4 text-success" /> : <Copy className="h-4 w-4" />}40            <span className="hidden sm:inline">{copied ? "Copié" : "Copier"}</span>41          </Button>42        </TooltipTrigger>43        <TooltipContent side="top">Copier le Markdown</TooltipContent>44      </Tooltip>45      <DownloadButtons question={question} answer={answer} contentRef={contentRef} figureUrls={figureUrls} />46      {!hideShare && (47        <ShareButton question={question} answer={answer} toolResults={toolResults} sources={sources} customPythonFigures={customPythonFigures} />48      )}49    </div>50  );51}52
Files main
Menu

Theme