# Description of Changes <!-- Please provide a summary of the changes, including: - What was changed - Why the change was made - Any challenges encountered Closes #(issue_number) --> --- ## Checklist ### General - [x] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [x] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md) (if applicable) - [x] I have read the [How to add new languages to Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md) (if applicable) - [x] I have performed a self-review of my own code - [x] My changes generate no new warnings ### Documentation - [ ] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed) - [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) ### UI Changes (if applicable) - [ ] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) ### Testing (if applicable) - [ ] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md#6-testing) for more details.
108 lines
3.4 KiB
TypeScript
108 lines
3.4 KiB
TypeScript
import { useRainbowThemeContext } from '../shared/RainbowThemeProvider';
|
|
import { useToolWorkflow } from '../../contexts/ToolWorkflowContext';
|
|
import ToolPicker from './ToolPicker';
|
|
import SearchResults from './SearchResults';
|
|
import ToolRenderer from './ToolRenderer';
|
|
import ToolSearch from './toolPicker/ToolSearch';
|
|
import { useSidebarContext } from "../../contexts/SidebarContext";
|
|
import rainbowStyles from '../../styles/rainbow.module.css';
|
|
import { ScrollArea } from '@mantine/core';
|
|
|
|
// No props needed - component uses context
|
|
|
|
export default function ToolPanel() {
|
|
const { isRainbowMode } = useRainbowThemeContext();
|
|
const { sidebarRefs } = useSidebarContext();
|
|
const { toolPanelRef } = sidebarRefs;
|
|
|
|
|
|
// Use context-based hooks to eliminate prop drilling
|
|
const {
|
|
leftPanelView,
|
|
isPanelVisible,
|
|
searchQuery,
|
|
filteredTools,
|
|
toolRegistry,
|
|
setSearchQuery,
|
|
} = useToolWorkflow();
|
|
|
|
const { selectedToolKey, handleToolSelect } = useToolWorkflow();
|
|
const { setPreviewFile } = useToolWorkflow();
|
|
|
|
return (
|
|
<div
|
|
ref={toolPanelRef}
|
|
data-sidebar="tool-panel"
|
|
className={`h-screen flex flex-col overflow-hidden bg-[var(--bg-toolbar)] border-r border-[var(--border-subtle)] transition-all duration-300 ease-out ${
|
|
isRainbowMode ? rainbowStyles.rainbowPaper : ''
|
|
}`}
|
|
style={{
|
|
width: isPanelVisible ? '18.5rem' : '0',
|
|
padding: '0'
|
|
}}
|
|
>
|
|
<div
|
|
style={{
|
|
opacity: isPanelVisible ? 1 : 0,
|
|
transition: 'opacity 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94)',
|
|
height: '100%',
|
|
display: 'flex',
|
|
flexDirection: 'column'
|
|
}}
|
|
>
|
|
{/* Search Bar - Always visible at the top */}
|
|
<div
|
|
style={{
|
|
backgroundColor: 'var(--tool-panel-search-bg)',
|
|
borderBottom: '1px solid var(--tool-panel-search-border-bottom)',
|
|
padding: '0.75rem 1rem',
|
|
}}
|
|
>
|
|
<ToolSearch
|
|
value={searchQuery}
|
|
onChange={setSearchQuery}
|
|
toolRegistry={toolRegistry}
|
|
mode="filter"
|
|
/>
|
|
</div>
|
|
|
|
{searchQuery.trim().length > 0 ? (
|
|
// Searching view (replaces both picker and content)
|
|
<div className="flex-1 flex flex-col overflow-y-auto">
|
|
<SearchResults
|
|
filteredTools={filteredTools}
|
|
onSelect={handleToolSelect}
|
|
searchQuery={searchQuery}
|
|
/>
|
|
</div>
|
|
) : leftPanelView === 'toolPicker' ? (
|
|
// Tool Picker View
|
|
<div className="flex-1 flex flex-col overflow-auto">
|
|
<ToolPicker
|
|
selectedToolKey={selectedToolKey}
|
|
onSelect={handleToolSelect}
|
|
filteredTools={filteredTools}
|
|
isSearching={Boolean(searchQuery && searchQuery.trim().length > 0)}
|
|
/>
|
|
</div>
|
|
) : (
|
|
// Selected Tool Content View
|
|
<div className="flex-1 flex flex-col overflow-hidden">
|
|
{/* Tool content */}
|
|
<div className="flex-1 min-h-0 overflow-hidden">
|
|
<ScrollArea h="100%">
|
|
{selectedToolKey && (
|
|
<ToolRenderer
|
|
selectedToolKey={selectedToolKey}
|
|
onPreviewFile={setPreviewFile}
|
|
/>
|
|
)}
|
|
</ScrollArea>
|
|
</div>
|
|
</div>
|
|
)}
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|