feat: MeasurementsPanel API definition + content
This commit is contained in:
parent
8f566c7ef4
commit
a3f2080834
@ -25,6 +25,7 @@ export {
|
||||
InputMultiSelect,
|
||||
InputText,
|
||||
Label,
|
||||
MeasurementsPanel,
|
||||
MeasurementTable,
|
||||
NavBar,
|
||||
Notification,
|
||||
|
||||
@ -1,11 +1,9 @@
|
||||
import React, { useState } from 'react';
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import classnames from 'classnames';
|
||||
import { Icon } from '@ohif/ui';
|
||||
|
||||
const MeasurementTable = ({ title, amount, data }) => {
|
||||
const [activeItem, setActiveItem] = useState(null);
|
||||
|
||||
const MeasurementTable = ({ data, title, amount, onClick, onEdit }) => {
|
||||
return (
|
||||
<div>
|
||||
<div className="flex justify-between px-2 py-1 bg-secondary-main">
|
||||
@ -14,29 +12,22 @@ const MeasurementTable = ({ title, amount, data }) => {
|
||||
</span>
|
||||
<span className="text-base font-bold text-white">{amount}</span>
|
||||
</div>
|
||||
<div className="overflow-y-auto overflow-x-hidden ohif-scrollbar max-h-80">
|
||||
<div className="overflow-y-auto overflow-x-hidden ohif-scrollbar max-h-112">
|
||||
{!!data.length &&
|
||||
data.map((e, i) => {
|
||||
const itemKey = i;
|
||||
const currentItem = i + 1;
|
||||
const isActive = !!activeItem && activeItem[title] === i;
|
||||
data.map((measurementItem) => {
|
||||
const { id, label, displayText, isActive } = measurementItem;
|
||||
return (
|
||||
<div
|
||||
key={i}
|
||||
key={id}
|
||||
className={classnames(
|
||||
'group flex cursor-default bg-black border border-transparent transition duration-300 ',
|
||||
{
|
||||
'rounded overflow-hidden border-primary-light': isActive,
|
||||
}
|
||||
)}
|
||||
onClick={() => {
|
||||
setActiveItem((s) => {
|
||||
return {
|
||||
...s,
|
||||
[title]: s && s[title] === itemKey ? null : itemKey,
|
||||
};
|
||||
});
|
||||
}}
|
||||
onClick={() => onClick(measurementItem.id)}
|
||||
onKeyDown={() => onClick(measurementItem.id)}
|
||||
role="button"
|
||||
>
|
||||
<div
|
||||
className={classnames(
|
||||
@ -47,14 +38,14 @@ const MeasurementTable = ({ title, amount, data }) => {
|
||||
}
|
||||
)}
|
||||
>
|
||||
{currentItem}
|
||||
{id}
|
||||
</div>
|
||||
<div className="px-2 py-1 flex flex-1 flex-col relative">
|
||||
<span className="text-base text-primary-light mb-1">
|
||||
Label short description
|
||||
{label}
|
||||
</span>
|
||||
<span className="pl-2 border-l border-primary-light text-base text-white">
|
||||
24.0 x 24.0 mm (S:4, I:22)
|
||||
{displayText}
|
||||
</span>
|
||||
<Icon
|
||||
className={classnames(
|
||||
@ -72,7 +63,7 @@ const MeasurementTable = ({ title, amount, data }) => {
|
||||
onClick={(e) => {
|
||||
// stopPropagation needed to avoid disable the current active item
|
||||
e.stopPropagation();
|
||||
alert('Edit');
|
||||
onEdit(id);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
@ -105,12 +96,23 @@ const MeasurementTable = ({ title, amount, data }) => {
|
||||
MeasurementTable.defaultProps = {
|
||||
amount: null,
|
||||
data: [],
|
||||
onClick: () => {},
|
||||
onEdit: () => {},
|
||||
};
|
||||
|
||||
MeasurementTable.propTypes = {
|
||||
title: PropTypes.string.isRequired,
|
||||
amount: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
||||
data: PropTypes.array, // TODO: define better the array structure
|
||||
data: PropTypes.arrayOf(
|
||||
PropTypes.shape({
|
||||
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
||||
label: PropTypes.string,
|
||||
displayText: PropTypes.string,
|
||||
isActive: PropTypes.bool,
|
||||
})
|
||||
),
|
||||
onClick: PropTypes.func,
|
||||
onEdit: PropTypes.func,
|
||||
};
|
||||
|
||||
export default MeasurementTable;
|
||||
|
||||
@ -0,0 +1,65 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { MeasurementTable } from '@ohif/ui';
|
||||
|
||||
const MeasurementsPanel = ({
|
||||
descriptionData,
|
||||
measurementTableData,
|
||||
actionButtons,
|
||||
}) => {
|
||||
const { date, modality, description } = descriptionData;
|
||||
return (
|
||||
<>
|
||||
<div className="overflow-y-auto overflow-x-hidden invisible-scrollbar">
|
||||
<div className="p-2">
|
||||
<div className="leading-none">
|
||||
<span className="text-white text-base mr-2">{date}</span>
|
||||
<span className="px-1 text-black bg-common-bright text-base rounded-sm font-bold">
|
||||
{modality}
|
||||
</span>
|
||||
</div>
|
||||
<div className="leading-none">
|
||||
<span className="text-base text-primary-light">{description}</span>
|
||||
</div>
|
||||
</div>
|
||||
<MeasurementTable
|
||||
data={measurementTableData.data}
|
||||
title={measurementTableData.title}
|
||||
amount={measurementTableData.amount}
|
||||
onClick={measurementTableData.onClick}
|
||||
onEdit={measurementTableData.onEdit}
|
||||
/>
|
||||
</div>
|
||||
<div className="p-4 flex justify-center">{actionButtons}</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
MeasurementsPanel.defaultProps = {
|
||||
actionButtons: null,
|
||||
};
|
||||
|
||||
MeasurementsPanel.propTypes = {
|
||||
descriptionData: PropTypes.shape({
|
||||
date: PropTypes.string,
|
||||
modality: PropTypes.string,
|
||||
description: PropTypes.string,
|
||||
}).isRequired,
|
||||
measurementTableData: PropTypes.shape({
|
||||
title: PropTypes.string,
|
||||
amount: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
||||
data: PropTypes.arrayOf(
|
||||
PropTypes.shape({
|
||||
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
||||
label: PropTypes.string,
|
||||
displayText: PropTypes.string,
|
||||
isActive: PropTypes.bool,
|
||||
})
|
||||
),
|
||||
onClick: PropTypes.func,
|
||||
onEdit: PropTypes.func,
|
||||
}).isRequired,
|
||||
actionButtons: PropTypes.node,
|
||||
};
|
||||
|
||||
export default MeasurementsPanel;
|
||||
2
platform/ui/src/components/MeasurementsPanel/index.js
Normal file
2
platform/ui/src/components/MeasurementsPanel/index.js
Normal file
@ -0,0 +1,2 @@
|
||||
import MeasurementsPanel from './MeasurementsPanel';
|
||||
export default MeasurementsPanel;
|
||||
@ -11,6 +11,7 @@ import InputLabelWrapper from './InputLabelWrapper';
|
||||
import InputMultiSelect from './InputMultiSelect';
|
||||
import InputText from './InputText';
|
||||
import Label from './Label';
|
||||
import MeasurementsPanel from './MeasurementsPanel';
|
||||
import MeasurementTable from './MeasurementTable';
|
||||
import NavBar from './NavBar';
|
||||
import Notification from './Notification';
|
||||
@ -53,6 +54,7 @@ export {
|
||||
InputMultiSelect,
|
||||
InputText,
|
||||
Label,
|
||||
MeasurementsPanel,
|
||||
MeasurementTable,
|
||||
NavBar,
|
||||
Notification,
|
||||
|
||||
@ -9,7 +9,7 @@ import {
|
||||
NavBar,
|
||||
SidePanel,
|
||||
Svg,
|
||||
MeasurementTable,
|
||||
MeasurementsPanel,
|
||||
SegmentationTable,
|
||||
ButtonGroup,
|
||||
Button,
|
||||
@ -28,15 +28,23 @@ import ViewportToolbar from './components/ViewportToolBar';
|
||||
|
||||
<Playground>
|
||||
{() => {
|
||||
const [activeMeasurementItem, setActiveMeasurementItem] = useState(null);
|
||||
const descriptionData = {
|
||||
date: '07-Sep-2010',
|
||||
modality: 'CT',
|
||||
description: 'CHEST/ABD/PELVIS W CONTRAST',
|
||||
};
|
||||
const measurementTableData = {
|
||||
title: 'Measurements',
|
||||
amount: 10,
|
||||
data: new Array(10).fill(''),
|
||||
};
|
||||
const segmentationTableData = {
|
||||
title: 'Segments',
|
||||
amount: 12,
|
||||
data: new Array(12).fill(''),
|
||||
data: new Array(10).fill({}).map((el, i) => ({
|
||||
id: i + 1,
|
||||
label: 'Label short description',
|
||||
displayText: '24.0 x 24.0 mm (S:4, I:22)',
|
||||
isActive: activeMeasurementItem === i + 1,
|
||||
})),
|
||||
onClick: (id) => setActiveMeasurementItem((s) => (s === id ? null : id)),
|
||||
onEdit: (id) => alert(`Edit: ${id}`),
|
||||
};
|
||||
return (
|
||||
<div>
|
||||
@ -93,52 +101,41 @@ import ViewportToolbar from './components/ViewportToolBar';
|
||||
iconName="list-bullets"
|
||||
iconLabel="Measure"
|
||||
componentLabel="Measurements"
|
||||
defaultIsOpen={false}
|
||||
defaultIsOpen={true}
|
||||
>
|
||||
<div className="overflow-y-auto overflow-x-hidden invisible-scrollbar">
|
||||
<div className="p-2">
|
||||
<div className="leading-none">
|
||||
<span className="text-white text-base mr-2">07-Sep-2010</span>
|
||||
<span className="px-1 text-black bg-common-bright text-base rounded-sm font-bold">
|
||||
CT
|
||||
</span>
|
||||
</div>
|
||||
<div className="leading-none">
|
||||
<span className="text-base text-primary-light">
|
||||
CHEST/ABD/PELVIS W CONTRAST
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<MeasurementTable {...measurementTableData} />
|
||||
<SegmentationTable {...segmentationTableData} />
|
||||
</div>
|
||||
<div className="p-4 flex justify-center">
|
||||
<ButtonGroup onClick={() => alert('Export')}>
|
||||
<Button
|
||||
className="text-white border-primary-main bg-black text-base py-2 px-2"
|
||||
size="initial"
|
||||
color="inherit"
|
||||
>
|
||||
Export
|
||||
</Button>
|
||||
<IconButton
|
||||
className="bg-black border-primary-main px-2 text-white px-2"
|
||||
color="inherit"
|
||||
size="initial"
|
||||
>
|
||||
<Icon name="arrow-down" />
|
||||
</IconButton>
|
||||
</ButtonGroup>
|
||||
<Button
|
||||
className="text-white border border-primary-main bg-black text-base py-2 px-2 ml-2"
|
||||
variant="outlined"
|
||||
size="initial"
|
||||
color="inherit"
|
||||
onClick={() => alert('Create Report')}
|
||||
>
|
||||
Create Report
|
||||
</Button>
|
||||
</div>
|
||||
<MeasurementsPanel
|
||||
descriptionData={descriptionData}
|
||||
measurementTableData={measurementTableData}
|
||||
actionButtons={
|
||||
<>
|
||||
<ButtonGroup onClick={() => alert('Export')}>
|
||||
<Button
|
||||
className="text-white border-primary-main bg-black text-base py-2 px-2"
|
||||
size="initial"
|
||||
color="inherit"
|
||||
>
|
||||
Export
|
||||
</Button>
|
||||
<IconButton
|
||||
className="bg-black border-primary-main px-2 text-white px-2"
|
||||
color="inherit"
|
||||
size="initial"
|
||||
>
|
||||
<Icon name="arrow-down" />
|
||||
</IconButton>
|
||||
</ButtonGroup>
|
||||
<Button
|
||||
className="text-white border border-primary-main bg-black text-base py-2 px-2 ml-2"
|
||||
variant="outlined"
|
||||
size="initial"
|
||||
color="inherit"
|
||||
onClick={() => alert('Create Report')}
|
||||
>
|
||||
Create Report
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
</SidePanel>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -173,6 +173,10 @@ module.exports = {
|
||||
'64': '16rem',
|
||||
'72': '18rem',
|
||||
'80': '20rem',
|
||||
'88': '22rem',
|
||||
'96': '24rem',
|
||||
'104': '26rem',
|
||||
'112': '28rem',
|
||||
'250px': '250px',
|
||||
},
|
||||
backgroundColor: (theme) => theme('colors'),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user