mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-07-15 19:10:47 +02:00
Restructure frontend code to allow for extensions (#4721)
# Description of Changes Move frontend code into `core` folder and add infrastructure for `proprietary` folder to include premium, non-OSS features
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import { SidebarRefs, SidebarState, SidebarInfo } from '@app/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
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user