import React, { useState, useRef } from "react"; import { ActionIcon, Stack, Tooltip, Divider } from "@mantine/core"; import MenuBookIcon from "@mui/icons-material/MenuBookRounded"; import AppsIcon from "@mui/icons-material/AppsRounded"; import SettingsIcon from "@mui/icons-material/SettingsRounded"; import AutoAwesomeIcon from "@mui/icons-material/AutoAwesomeRounded"; import FolderIcon from "@mui/icons-material/FolderRounded"; import PersonIcon from "@mui/icons-material/PersonRounded"; import NotificationsIcon from "@mui/icons-material/NotificationsRounded"; import { useRainbowThemeContext } from "./RainbowThemeProvider"; import rainbowStyles from '../../styles/rainbow.module.css'; import AppConfigModal from './AppConfigModal'; import { useIsOverflow } from '../../hooks/useIsOverflow'; import './QuickAccessBar.css'; interface QuickAccessBarProps { onToolsClick: () => void; onReaderToggle: () => void; selectedToolKey?: string; toolRegistry: any; leftPanelView: 'toolPicker' | 'toolContent'; readerMode: boolean; } interface ButtonConfig { id: string; name: string; icon: React.ReactNode; tooltip: string; isRound?: boolean; size?: 'sm' | 'md' | 'lg' | 'xl'; onClick: () => void; } function NavHeader({ activeButton, setActiveButton, onReaderToggle, onToolsClick }: { activeButton: string; setActiveButton: (id: string) => void; onReaderToggle: () => void; onToolsClick: () => void; }) { return ( <>
{/* Divider after top icons */} {/* All Tools button below divider */}
{ setActiveButton('tools'); onReaderToggle(); onToolsClick(); }} style={{ backgroundColor: activeButton === 'tools' ? 'var(--icon-tools-bg)' : 'var(--icon-inactive-bg)', color: activeButton === 'tools' ? 'var(--icon-tools-color)' : 'var(--icon-inactive-color)', border: 'none', borderRadius: '8px', }} className={activeButton === 'tools' ? 'activeIconScale' : ''} > All Tools
); } const QuickAccessBar = ({ onToolsClick, onReaderToggle, selectedToolKey, toolRegistry, leftPanelView, readerMode, }: QuickAccessBarProps) => { const { isRainbowMode } = useRainbowThemeContext(); const [configModalOpen, setConfigModalOpen] = useState(false); const [activeButton, setActiveButton] = useState('tools'); const scrollableRef = useRef(null); const isOverflow = useIsOverflow(scrollableRef); const buttonConfigs: ButtonConfig[] = [ { id: 'read', name: 'Read', icon: , tooltip: 'Read documents', size: 'lg', isRound: false, onClick: () => { setActiveButton('read'); onReaderToggle(); } }, { id: 'sign', name: 'Sign', icon: signature , tooltip: 'Sign your document', size: 'lg', isRound: false, onClick: () => setActiveButton('sign') }, { id: 'automate', name: 'Automate', icon: , tooltip: 'Automate workflows', size: 'lg', isRound: false, onClick: () => setActiveButton('automate') }, { id: 'files', name: 'Files', icon: , tooltip: 'Manage files', isRound: true, size: 'lg', onClick: () => setActiveButton('files') }, { id: 'activity', name: 'Activity', icon: vital_signs , tooltip: 'View activity and analytics', isRound: true, size: 'lg', onClick: () => setActiveButton('activity') }, { id: 'config', name: 'Config', icon: , tooltip: 'Configure settings', size: 'lg', onClick: () => { setConfigModalOpen(true); } } ]; const CIRCULAR_BORDER_RADIUS = '50%'; const ROUND_BORDER_RADIUS = '8px'; const getBorderRadius = (config: ButtonConfig): string => { return config.isRound ? CIRCULAR_BORDER_RADIUS : ROUND_BORDER_RADIUS; }; const getButtonStyle = (config: ButtonConfig) => { const isActive = activeButton === config.id; if (isActive) { return { backgroundColor: `var(--icon-${config.id}-bg)`, color: `var(--icon-${config.id}-color)`, border: 'none', borderRadius: getBorderRadius(config), }; } // Inactive state - use consistent inactive colors return { backgroundColor: 'var(--icon-inactive-bg)', color: 'var(--icon-inactive-color)', border: 'none', borderRadius: getBorderRadius(config), }; }; return (
{/* Fixed header outside scrollable area */}
{/* Conditional divider when overflowing */} {isOverflow && ( )} {/* Scrollable content area */}
{ // Prevent the wheel event from bubbling up to parent containers e.stopPropagation(); }} >
{/* Top section with main buttons */} {buttonConfigs.slice(0, -1).map((config, index) => (
{config.icon} {config.name}
{/* Add divider after Automate button (index 2) */} {index === 2 && ( )}
))}
{/* Spacer to push Config button to bottom */}
{/* Config button at the bottom */}
{ setConfigModalOpen(true); }} style={{ backgroundColor: 'var(--icon-inactive-bg)', color: 'var(--icon-inactive-color)', border: 'none', borderRadius: '8px', }} > Config
setConfigModalOpen(false)} />
); }; export default QuickAccessBar;