From af7f2f525b046c02f1ffbf13e996a2279d40e1f2 Mon Sep 17 00:00:00 2001 From: Rodrigo Antinarelli Date: Fri, 10 Apr 2020 15:05:06 -0300 Subject: [PATCH] create segmentation and measurement mdx --- platform/ui/index.js | 1 + .../MeasurementTable/MeasurementTable.jsx | 317 +++++------------- .../MeasurementTable/MeasurementTable.mdx | 21 +- .../SegmentationTable/SegmentationTable.jsx | 114 +++++++ .../SegmentationTable/SegmentationTable.mdx | 37 ++ .../src/components/SegmentationTable/index.js | 3 + platform/ui/src/components/index.js | 2 + platform/ui/src/views/Viewer/Viewer.mdx | 136 ++++++-- 8 files changed, 367 insertions(+), 264 deletions(-) create mode 100644 platform/ui/src/components/SegmentationTable/SegmentationTable.jsx create mode 100644 platform/ui/src/components/SegmentationTable/SegmentationTable.mdx create mode 100644 platform/ui/src/components/SegmentationTable/index.js diff --git a/platform/ui/index.js b/platform/ui/index.js index c3ecf8ce2..7005902cd 100644 --- a/platform/ui/index.js +++ b/platform/ui/index.js @@ -28,6 +28,7 @@ export { MeasurementTable, NavBar, Select, + SegmentationTable, SidePanel, StudyListExpandedRow, StudyListPagination, diff --git a/platform/ui/src/components/MeasurementTable/MeasurementTable.jsx b/platform/ui/src/components/MeasurementTable/MeasurementTable.jsx index ac6621b29..211d49b91 100644 --- a/platform/ui/src/components/MeasurementTable/MeasurementTable.jsx +++ b/platform/ui/src/components/MeasurementTable/MeasurementTable.jsx @@ -1,255 +1,116 @@ import React, { useState } from 'react'; +import PropTypes from 'prop-types'; import classnames from 'classnames'; -import { Icon, ButtonGroup, Button, IconButton } from '@ohif/ui'; +import { Icon } from '@ohif/ui'; -const MeasurementTable = () => { - const tableData = new Array(12).fill(''); +const MeasurementTable = ({ title, amount, data }) => { const [activeItem, setActiveItem] = useState(null); - const colorLUT = [ - '#932a13', - '#821393', - '#2b7fc4', - '#12c457', - '#7f7d2e', - '#7f2e4a', - '#866943', - '#65ae7f', - '#334b5f', - '#3cb0dc', - '#292ac9', - '#629753', - ]; - - const renderTable = (title, amount, data) => { - return ( -
-
- - {title} - - {amount} -
- {/* MEASUREMENT ITEMS */} -
- {!!data.length && - data.map((e, i) => { - const itemKey = i; - const currentItem = i + 1; - const isActive = !!activeItem && activeItem[title] === i; - return ( + return ( +
+
+ + {title} + + {amount} +
+
+ {!!data.length && + data.map((e, i) => { + const itemKey = i; + const currentItem = i + 1; + const isActive = !!activeItem && activeItem[title] === i; + return ( +
{ + setActiveItem((s) => { + return { + ...s, + [title]: s && s[title] === itemKey ? null : itemKey, + }; + }); + }} + >
{ - setActiveItem((s) => { - return { - ...s, - [title]: s && s[title] === itemKey ? null : itemKey, - }; - }); - }} > -
+
+ + Label short description + + + 24.0 x 24.0 mm (S:4, I:22) + + - {currentItem} -
-
- - Label short description - - - 24.0 x 24.0 mm (S:4, I:22) - - { - // stopPropagation needed to avoid disable the current active item - e.stopPropagation(); - alert('Edit'); - }} - /> -
+ name="pencil" + style={{ + top: 4, + right: 4, + transform: isActive ? '' : 'translateX(100%)', + }} + onClick={(e) => { + // stopPropagation needed to avoid disable the current active item + e.stopPropagation(); + alert('Edit'); + }} + />
- ); - })} - {!data.length && ( +
+ ); + })} + {!data.length && ( +
-
-
- - No tracked measurements - -
+ >
+
+ + No tracked measurements +
- )} -
-
- ); - }; - - const renderSegments = (title, amount, data) => { - return ( -
-
- - {title} - -
- {amount} - alert('TBD')} - />
-
-
- {!!data.length && - data.map((e, i) => { - const itemKey = i; - const currentItem = i + 1; - const isActive = !!activeItem && activeItem[title] === i; - return ( -
{ - setActiveItem((s) => { - return { - ...s, - [title]: s && s[title] === itemKey ? null : itemKey, - }; - }); - }} - > -
- {currentItem} -
-
- -
- Label short description -
- { - // stopPropagation needed to avoid disable the current active item - e.stopPropagation(); - alert('Toggle'); - }} - /> -
-
- ); - })} -
-
- ); - }; - - return ( -
- {/* HEADER */} -
-
- 07-Sep-2010 - - CT - -
-
- - CHEST/ABD/PELVIS W CONTRAST - -
-
- {/* TABLE */} - {renderTable('Measurements', null, [])} - {renderTable('Measurements', 5, tableData)} - {renderTable('ADDITIONAL FINDINGS', 5, tableData)} - {renderSegments('SEGMENTS', 12, tableData)} - - {/* BUTTONS */} -
- alert('Export')}> - - - - - - + )}
); }; +MeasurementTable.defaultProps = { + amount: null, + data: [], +}; + +MeasurementTable.propTypes = { + title: PropTypes.string.isRequired, + amount: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), + data: PropTypes.array, // TODO: define better the array structure +}; + export default MeasurementTable; diff --git a/platform/ui/src/components/MeasurementTable/MeasurementTable.mdx b/platform/ui/src/components/MeasurementTable/MeasurementTable.mdx index ba62387c6..5b3db5c36 100644 --- a/platform/ui/src/components/MeasurementTable/MeasurementTable.mdx +++ b/platform/ui/src/components/MeasurementTable/MeasurementTable.mdx @@ -19,9 +19,26 @@ import { MeasurementTable } from '@ohif/ui'; {() => { + const tableData = { + title: 'Measurements', + amount: 10, + data: new Array(10).fill(''), + }; return ( -
- +
+ +
+ ); + }} + + +## Empty Data + + + {() => { + return ( +
+
); }} diff --git a/platform/ui/src/components/SegmentationTable/SegmentationTable.jsx b/platform/ui/src/components/SegmentationTable/SegmentationTable.jsx new file mode 100644 index 000000000..743aa210f --- /dev/null +++ b/platform/ui/src/components/SegmentationTable/SegmentationTable.jsx @@ -0,0 +1,114 @@ +import React, { useState } from 'react'; +import PropTypes from 'prop-types'; +import classnames from 'classnames'; +import { Icon } from '@ohif/ui'; + +const SegmentationTable = ({ title, amount, data }) => { + const [activeItem, setActiveItem] = useState(null); + + // TODO: colorLUT should be defined in the application + const colorLUT = [ + '#932a13', + '#821393', + '#2b7fc4', + '#12c457', + '#7f7d2e', + '#7f2e4a', + '#866943', + '#65ae7f', + '#334b5f', + '#3cb0dc', + '#292ac9', + '#629753', + ]; + + return ( +
+
+ + {title} + +
+ {amount} + alert('TBD')} + /> +
+
+
+ {!!data.length && + data.map((e, i) => { + const itemKey = i; + const currentItem = i + 1; + const isActive = !!activeItem && activeItem[title] === i; + return ( +
{ + setActiveItem((s) => { + return { + ...s, + [title]: s && s[title] === itemKey ? null : itemKey, + }; + }); + }} + > +
+ {currentItem} +
+
+ +
+ Label short description +
+ { + // stopPropagation needed to avoid disable the current active item + e.stopPropagation(); + alert('Toggle'); + }} + /> +
+
+ ); + })} +
+
+ ); +}; + +SegmentationTable.defaultProps = { + amount: null, + data: [], +}; + +SegmentationTable.propTypes = { + title: PropTypes.string.isRequired, + amount: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), + data: PropTypes.array, // TODO: define better the array structure +}; + +export default SegmentationTable; diff --git a/platform/ui/src/components/SegmentationTable/SegmentationTable.mdx b/platform/ui/src/components/SegmentationTable/SegmentationTable.mdx new file mode 100644 index 000000000..e9c1b9072 --- /dev/null +++ b/platform/ui/src/components/SegmentationTable/SegmentationTable.mdx @@ -0,0 +1,37 @@ +--- +name: Segmentation Table +menu: Data Display +route: components/segmentationTable +--- + +import { Playground, Props } from 'docz'; +import { SegmentationTable } from '@ohif/ui'; + +# Segmentation Table + +## Import + +```javascript +import { SegmentationTable } from '@ohif/ui'; +``` + +## Basic usage + + + {() => { + const tableData = { + title: 'Segments', + amount: 12, + data: new Array(12).fill(''), + }; + return ( +
+ +
+ ); + }} +
+ +## Properties + + diff --git a/platform/ui/src/components/SegmentationTable/index.js b/platform/ui/src/components/SegmentationTable/index.js new file mode 100644 index 000000000..944e21e4f --- /dev/null +++ b/platform/ui/src/components/SegmentationTable/index.js @@ -0,0 +1,3 @@ +import SegmentationTable from './SegmentationTable'; + +export default SegmentationTable; diff --git a/platform/ui/src/components/index.js b/platform/ui/src/components/index.js index 27fbd9c27..05cb336f5 100644 --- a/platform/ui/src/components/index.js +++ b/platform/ui/src/components/index.js @@ -14,6 +14,7 @@ import Label from './Label'; import MeasurementTable from './MeasurementTable'; import NavBar from './NavBar'; import Select from './Select'; +import SegmentationTable from './SegmentationTable'; import SidePanel from './SidePanel'; import Svg from './Svg'; import StudyListExpandedRow from './StudyListExpandedRow'; @@ -44,6 +45,7 @@ export { MeasurementTable, NavBar, Select, + SegmentationTable, SidePanel, Svg, StudyListExpandedRow, diff --git a/platform/ui/src/views/Viewer/Viewer.mdx b/platform/ui/src/views/Viewer/Viewer.mdx index 1890df091..c1e711fdd 100644 --- a/platform/ui/src/views/Viewer/Viewer.mdx +++ b/platform/ui/src/views/Viewer/Viewer.mdx @@ -5,44 +5,112 @@ route: examples/viewer --- import { Playground, Props } from 'docz'; -import { NavBar, SidePanel, Svg, MeasurementTable } from '@ohif/ui'; +import { + NavBar, + SidePanel, + Svg, + MeasurementTable, + SegmentationTable, + ButtonGroup, + Button, + Icon, + IconButton, +} from '@ohif/ui'; # Viewer -
- -
- -
-
-
- -
- panel placeholder + {() => { + const measurementTableData = { + title: 'Measurements', + amount: 10, + data: new Array(10).fill(''), + }; + const segmentationTableData = { + title: 'Segments', + amount: 12, + data: new Array(12).fill(''), + }; + return ( +
+ +
+ +
+
+
+ +
+ panel placeholder +
+
+
+ CONTENT +
+ +
+ {/* HEADER */} +
+
+ 07-Sep-2010 + + CT + +
+
+ + CHEST/ABD/PELVIS W CONTRAST + +
+
+ + +
+
+ alert('Export')}> + + + + + + +
+
- -
- CONTENT
- - - -
-
+ ); + }}