-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(SidePanel): new side panel tab look-and-feel (#3657)
- Loading branch information
Showing
22 changed files
with
828 additions
and
247 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
extensions/default/src/Components/SidePanelWithServices.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import { SidePanel } from '@ohif/ui'; | ||
import { PanelService, ServicesManager } from '@ohif/core'; | ||
|
||
export type SidePanelWithServicesProps = { | ||
servicesManager: ServicesManager; | ||
side: 'left' | 'right'; | ||
className: string; | ||
activeTabIndex: number; | ||
tabs: any; | ||
}; | ||
|
||
const SidePanelWithServices = ({ | ||
servicesManager, | ||
side, | ||
className, | ||
activeTabIndex: activeTabIndexProp, | ||
tabs, | ||
}) => { | ||
const panelService: PanelService = servicesManager?.services?.panelService; | ||
|
||
// Tracks whether this SidePanel has been opened at least once since this SidePanel was inserted into the DOM. | ||
// Thus going to the Study List page and back to the viewer resets this flag for a SidePanel. | ||
const [hasBeenOpened, setHasBeenOpened] = useState(false); | ||
const [activeTabIndex, setActiveTabIndex] = useState(activeTabIndexProp); | ||
|
||
useEffect(() => { | ||
if (panelService) { | ||
const activatePanelSubscription = panelService.subscribe( | ||
panelService.EVENTS.ACTIVATE_PANEL, | ||
(activatePanelEvent: Types.ActivatePanelEvent) => { | ||
if (!hasBeenOpened || activatePanelEvent.forceActive) { | ||
const tabIndex = tabs.findIndex(tab => tab.id === activatePanelEvent.panelId); | ||
if (tabIndex !== -1) { | ||
setActiveTabIndex(tabIndex); | ||
} | ||
} | ||
} | ||
); | ||
|
||
return () => { | ||
activatePanelSubscription.unsubscribe(); | ||
}; | ||
} | ||
}, [tabs, hasBeenOpened, panelService]); | ||
|
||
return ( | ||
<SidePanel | ||
side={side} | ||
className={className} | ||
activeTabIndex={activeTabIndex} | ||
tabs={tabs} | ||
onOpen={() => { | ||
setHasBeenOpened(true); | ||
}} | ||
></SidePanel> | ||
); | ||
}; | ||
|
||
export default SidePanelWithServices; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.