Files
ohif-viewer/platform/ui/src/components/ViewportGrid/ViewportGrid.jsx
T

33 lines
806 B
React
Raw Normal View History

2020-04-13 07:44:38 -03:00
import React from 'react';
import PropTypes from 'prop-types';
2020-05-14 21:31:28 -04:00
function ViewportGrid({ numRows, numCols, children }) {
const rowSize = 100 / numRows;
const colSize = 100 / numCols;
2020-04-13 07:44:38 -03:00
return (
<div
2020-05-14 21:31:28 -04:00
data-cy="viewport-grid"
style={{
display: 'grid',
gridTemplateRows: `repeat(${numRows}, ${rowSize}%)`,
gridTemplateColumns: `repeat(${numCols}, ${colSize}%)`,
height: '100%',
width: '100%',
}}
2020-04-13 07:44:38 -03:00
>
2020-05-14 21:31:28 -04:00
{children}
2020-04-13 07:44:38 -03:00
</div>
);
2020-05-14 21:31:28 -04:00
}
2020-04-13 07:44:38 -03:00
ViewportGrid.propTypes = {
2020-05-14 21:31:28 -04:00
/** Number of columns */
numRows: PropTypes.number.isRequired,
/** Number of rows */
numCols: PropTypes.number.isRequired,
/** Array of React Components to render within grid */
children: PropTypes.arrayOf(PropTypes.node).isRequired,
2020-04-13 07:44:38 -03:00
};
export default ViewportGrid;