import React, { useState } from 'react'; import { Button } from './ui/button'; import { Download, ClipboardList, Sparkles } from 'lucide-react'; import { toast } from 'sonner@2.0.3'; import type { User } from '../App'; interface FloatingActionButtonsProps { user: User | null; isLoggedIn: boolean; onOpenPanel: () => void; onExport: () => void; onQuiz: () => void; onSummary: () => void; } export function FloatingActionButtons({ user, isLoggedIn, onOpenPanel, onExport, onQuiz, onSummary, }: FloatingActionButtonsProps) { const [hoveredButton, setHoveredButton] = useState(null); const handleAction = (action: () => void, actionName: string, shouldOpenPanel: boolean = false) => { if (!isLoggedIn) { toast.error('Please log in to use this feature'); return; } action(); if (shouldOpenPanel) { onOpenPanel(); } }; const buttons = [ { id: 'export', icon: Download, label: 'Export Conversation', action: onExport, openPanel: true, // Open panel for export }, { id: 'quiz', icon: ClipboardList, label: "Let's Try (Micro-Quiz)", action: onQuiz, openPanel: false, // Don't open panel for quiz }, { id: 'summary', icon: Sparkles, label: 'Summarization', action: onSummary, openPanel: true, // Open panel for summary }, ]; return (
{buttons.map((button, index) => { const Icon = button.icon; const isHovered = hoveredButton === button.id; return (
setHoveredButton(button.id)} onMouseLeave={() => setHoveredButton(null)} > {/* Tooltip */}
{button.label}
{/* Floating Button */}
); })}
); }