Spaces:
Running
Running
File size: 1,996 Bytes
538d81e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | import { useState } from "react";
import { Button } from "@/components/ui/button";
import { Textarea } from "@/components/ui/textarea";
import { StickyNote, X } from "lucide-react";
import { cn } from "@/lib/utils";
interface TextAnnotationProps {
onAdd: (text: string) => void;
}
const TextAnnotation = ({ onAdd }: TextAnnotationProps) => {
const [isOpen, setIsOpen] = useState(false);
const [text, setText] = useState("");
const handleAdd = () => {
if (text.trim()) {
onAdd(text.trim());
setText("");
setIsOpen(false);
}
};
return (
<div className="relative">
<Button
onClick={() => setIsOpen(!isOpen)}
size="sm"
variant={isOpen ? "default" : "outline"}
title="Ajouter une note"
>
<StickyNote className="w-4 h-4 mr-1" />
Note
</Button>
{isOpen && (
<div className="absolute top-full right-0 mt-2 w-72 bg-card border border-border rounded-lg shadow-lg p-4 z-50 animate-scale-in">
<div className="flex items-center justify-between mb-2">
<span className="text-sm font-medium">Nouvelle note</span>
<button
onClick={() => setIsOpen(false)}
className="hover:bg-muted rounded p-1"
>
<X className="w-4 h-4" />
</button>
</div>
<Textarea
value={text}
onChange={(e) => setText(e.target.value)}
placeholder="Écrivez votre observation..."
className="mb-2 min-h-[80px]"
autoFocus
/>
<div className="flex gap-2">
<Button onClick={handleAdd} size="sm" className="flex-1">
Ajouter sur le plan
</Button>
<Button onClick={() => setIsOpen(false)} size="sm" variant="outline">
Annuler
</Button>
</div>
</div>
)}
</div>
);
};
export default TextAnnotation;
|