mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-08-27 14:49:23 +00:00

# Description of Changes - added tooltips to ocr and compress - added the tooltip component which can be used either directly, or through the toolstep component --- ## Checklist ### General - [ ] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [ ] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md) (if applicable) - [ ] 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) - [ ] I have performed a self-review of my own code - [ ] 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.
34 lines
1.2 KiB
TypeScript
34 lines
1.2 KiB
TypeScript
import { SidebarRefs, SidebarState, SidebarInfo } from '../types/sidebar';
|
|
|
|
/**
|
|
* Gets the All tools sidebar information using React refs and state
|
|
* @param refs - Object containing refs to sidebar elements
|
|
* @param state - Current sidebar state
|
|
* @returns Object containing the sidebar rect and whether the tool panel is active
|
|
*/
|
|
export function getSidebarInfo(refs: SidebarRefs, state: SidebarState): SidebarInfo {
|
|
const { quickAccessRef, toolPanelRef } = refs;
|
|
const { sidebarsVisible, readerMode } = state;
|
|
|
|
// Determine if tool panel should be active based on state
|
|
const isToolPanelActive = sidebarsVisible && !readerMode;
|
|
|
|
let rect: DOMRect | null = null;
|
|
|
|
if (isToolPanelActive && toolPanelRef.current) {
|
|
// Tool panel is expanded: use its rect
|
|
rect = toolPanelRef.current.getBoundingClientRect();
|
|
} else if (quickAccessRef.current) {
|
|
// Fall back to quick access bar
|
|
// This probably isn't needed but if we ever have tooltips or modals that need to be positioned relative to the quick access bar, we can use this
|
|
rect = quickAccessRef.current.getBoundingClientRect();
|
|
}
|
|
|
|
return {
|
|
rect,
|
|
isToolPanelActive,
|
|
sidebarState: state
|
|
};
|
|
}
|
|
|
|
|