Create new ToolbarButton type for Layout Selector; wire up custom UI; prep for viewportGridService usage
This commit is contained in:
1 parent
83eb24337c
commit
9146a9ee32
18 files changed
+166
-162
No files matched your search
@@ -0,0 +1,41 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { LayoutSelector as OHIFLayoutSelector, ToolbarButton } from '@ohif/ui';
|
||||
|
||||
function LayoutSelector() {
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
function LayoutSelector() {
|
||||
if (isOpen) {
|
||||
setIsOpen(false);
|
||||
}
|
||||
}
|
||||
window.addEventListener('click', LayoutSelector);
|
||||
return () => {
|
||||
window.removeEventListener('click', LayoutSelector);
|
||||
};
|
||||
}, [isOpen]);
|
||||
|
||||
const dropdownContent = isOpen ? OHIFLayoutSelector : undefined;
|
||||
|
||||
return (
|
||||
<ToolbarButton
|
||||
id="Layout"
|
||||
label="Grid Layout"
|
||||
icon="tool-layout"
|
||||
onClick={() => {
|
||||
setIsOpen(!isOpen);
|
||||
}}
|
||||
dropdownContent={dropdownContent}
|
||||
isActive={isOpen}
|
||||
type="primary"
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
LayoutSelector.propTypes = {
|
||||
children: PropTypes.any.isRequired,
|
||||
};
|
||||
|
||||
export default LayoutSelector;
|
||||
Reference in new issue
Block a user