Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement right-side panels bar #3318

Merged
merged 11 commits into from
Jan 9, 2025
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"ml-tree-similarity": "^2.2.0",
"multiplet-analysis": "^2.1.5",
"nmr-correlation": "^2.3.3",
"nmr-load-save": "^2.2.0",
"nmr-load-save": "^2.3.0",
"nmr-processing": "^14.0.5",
"nmredata": "^0.9.11",
"numeral": "^2.0.6",
Expand Down
2 changes: 1 addition & 1 deletion src/component/hooks/useToolsFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useChartData } from '../context/ChartContext.js';
import { useDispatch } from '../context/DispatchContext.js';
import { usePreferences } from '../context/PreferencesContext.js';
import { useToaster } from '../context/ToasterContext.js';
import { TOOLS_PANELS_ACCORDION } from '../panels/Panels.js';
import { TOOLS_PANELS_ACCORDION } from '../panels/accordionItems.js';
import { options } from '../toolbar/ToolTypes.js';

export default function useToolsFunctions() {
Expand Down
27 changes: 17 additions & 10 deletions src/component/main/InnerNMRiumContents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import { ExportManagerController } from '../elements/export/ExportManager.js';
import { PrintContent } from '../elements/print/PrintContent.js';
import { Header } from '../header/Header.js';
import DropZone from '../loader/DropZone.js';
import Panels from '../panels/Panels.js';
import { PanelOpenProviderProvider, Panels } from '../panels/Panels.js';
import { PanelsBar } from '../panels/PanelsBar.js';
import ToolBar from '../toolbar/ToolBar.js';

import { useNMRiumRefAPI } from './NMRiumRefAPI.js';
Expand Down Expand Up @@ -150,15 +151,21 @@ export function InnerNMRiumContents(props: InnerNMRiumContentsProps) {
height: '100%',
}}
>
<ToolBar />
<SplitPaneWrapper>
<div css={viewerContainerStyle}>
<KeysListenerTracker mainDivRef={mainDivRef} />

<NMRiumViewer emptyText={emptyText} viewerRef={viewerRef} />
</div>
<Panels />
</SplitPaneWrapper>
<PanelOpenProviderProvider>
<ToolBar />
<SplitPaneWrapper>
<div css={viewerContainerStyle}>
<KeysListenerTracker mainDivRef={mainDivRef} />

<NMRiumViewer
emptyText={emptyText}
viewerRef={viewerRef}
/>
</div>
<Panels />
</SplitPaneWrapper>
<PanelsBar />
</PanelOpenProviderProvider>
<div
ref={elementsWrapperRef}
key={String(isFullScreen)}
Expand Down
21 changes: 20 additions & 1 deletion src/component/main/SplitPaneWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@ import type { SplitPaneSize } from 'react-science/ui';
import { SplitPane } from 'react-science/ui';

import { usePreferences } from '../context/PreferencesContext.js';
import { useAccordionItems } from '../panels/hooks/useAccordionItems.js';
import { useGetPanelOptions } from '../panels/hooks/useGetPanelOptions.js';

export function SplitPaneWrapper({ children }) {
const { current, dispatch } = usePreferences();
const getPanelPreferences = useGetPanelOptions();

const {
general: { verticalSplitterPosition, verticalSplitterCloseThreshold },
display: { general = {} },
} = current;
const items = useAccordionItems();

function resizeHandler(value: SplitPaneSize) {
dispatch({
Expand All @@ -19,12 +24,26 @@ export function SplitPaneWrapper({ children }) {
});
}

const displayedPanels = items.filter((item) => {
const panelOptions = getPanelPreferences(item);
return panelOptions.display;
});
const hasDisplayedPanels = displayedPanels.length > 0;

if (items?.length === 0 || !hasDisplayedPanels) {
return <div style={{ width: '100%', height: '100%' }}>{children}</div>;
}

const closed: number | boolean = general?.hidePanelOnLoad
? true
: verticalSplitterCloseThreshold;

return (
<SplitPane
size={verticalSplitterPosition}
direction="horizontal"
controlledSide="end"
closed={general?.hidePanelOnLoad ? true : verticalSplitterCloseThreshold}
closed={closed}
onResize={resizeHandler}
>
{children}
Expand Down
14 changes: 13 additions & 1 deletion src/component/modal/setting/settings-tabs/DisplayTabContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,18 @@ function DisplayTabContent() {
},
{
index: 2,
Header: 'Visible',
style: { textAlign: 'center' },
Cell: ({ row }) => (
<Checkbox
style={{ margin: 0 }}
{...register(`display.${row.original.name}.visible`)}
defaultChecked={false}
/>
),
},
{
index: 3,
Header: 'Active',
style: { textAlign: 'center' },
Cell: ({ row }) => (
Expand All @@ -104,7 +116,7 @@ function DisplayTabContent() {
),
},
{
index: 3,
index: 4,
Header: 'Open on load',
style: { textAlign: 'center' },
Cell: ({ row }) => (
Expand Down
Loading
Loading