From 59dd5820dd6dc9917ce6ea6876083f0325223824 Mon Sep 17 00:00:00 2001 From: Gustavo Lelis Date: Tue, 7 Apr 2020 14:03:47 -0300 Subject: [PATCH] Side pannels --- .../ui/src/components/SidePanel/SidePanel.jsx | 114 ++++++++++++------ platform/ui/src/views/Viewer/Viewer.js | 16 ++- 2 files changed, 90 insertions(+), 40 deletions(-) diff --git a/platform/ui/src/components/SidePanel/SidePanel.jsx b/platform/ui/src/components/SidePanel/SidePanel.jsx index eebdcd703..a4faf4bd5 100644 --- a/platform/ui/src/components/SidePanel/SidePanel.jsx +++ b/platform/ui/src/components/SidePanel/SidePanel.jsx @@ -4,64 +4,107 @@ import classnames from 'classnames'; import { Button, Icon } from '@ohif/ui'; +const borderSize = 4; +const expandedWidth = 320; +const collapsedWidth = 60; + const baseStyle = { - maxWidth: '320px', + maxWidth: `${expandedWidth}px`, + width: `${expandedWidth}px`, }; -const dynamicStyle = { +const styleMap = { open: { - left: {}, - right: {}, + left: { marginLeft: '0px' }, + right: { marginRight: '0px' }, }, closed: { - left: {}, - right: {}, + left: { marginLeft: `-${expandedWidth - collapsedWidth - borderSize}px` }, + right: { marginRight: `-${expandedWidth - collapsedWidth - borderSize}px` }, }, }; -const sideClasses = { - left: 'border-r-4', - right: 'border-l-4', -}; - const baseClassName = - 'transition-all duration-300 ease-in-out h-100 bg-primary-light border-black'; + 'transition-all duration-300 ease-in-out h-100 bg-primary-dark border-black flex flex-col justify-start'; + +const classesMap = { + open: { + left: `border-r-${borderSize}`, + right: `border-l-${borderSize}`, + }, + closed: { + left: `border-r-${borderSize} items-end`, + right: `border-l-${borderSize} items-start`, + }, +}; const SidePanel = ({ side, className, children, defaultIsOpen, - componentName, + componentLabel, + iconLabel, iconName, }) => { const [isOpen, setIsOpen] = useState(defaultIsOpen); const openStatus = isOpen ? 'open' : 'closed'; - const style = Object.assign({}, dynamicStyle[openStatus][side]); + const style = Object.assign({}, styleMap[openStatus][side], baseStyle); + const openIconName = { + left: 'chevron-right', + right: 'chevron-right', + }; + + const sidePanelHeader = () => { + return ( + + {isOpen ? ( + + ) : ( + + )} + + ); + }; return (
- {isOpen ? ( - -
- {componentName} - -
- {children} -
- ) : ( - - )} + {sidePanelHeader(isOpen, side, iconLabel, iconName)} + {isOpen && children}
); }; @@ -72,9 +115,12 @@ SidePanel.defaultProps = { SidePanel.propTypes = { side: PropTypes.oneOf(['left', 'right']).isRequired, + iconLabel: PropTypes.string.isRequired, + componentLabel: PropTypes.string.isRequired, + iconName: PropTypes.string.isRequired, + defaultIsOpen: PropTypes.bool, className: PropTypes.string, children: PropTypes.node, - isOpen: PropTypes.bool, }; export default SidePanel; diff --git a/platform/ui/src/views/Viewer/Viewer.js b/platform/ui/src/views/Viewer/Viewer.js index 8a2805533..2e296ede7 100644 --- a/platform/ui/src/views/Viewer/Viewer.js +++ b/platform/ui/src/views/Viewer/Viewer.js @@ -15,20 +15,24 @@ const Viewer = () => { > -
GUSTAVO
+
LEFT SIDE PANE CONTENT
CONTENT
-
GUSTAVO DO OUTRO LADO
+
RIGHT SIDE PANEL CONTENT