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

64 lines
1.7 KiB
React
Raw Normal View History

import React from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import { useDrop } from 'react-dnd';
2020-05-14 22:01:34 -04:00
// NOTE: If we found a way to make `useDrop` conditional,
// Or we provided a HOC of this component, we could provide
// this UI without the DragAndDropContext dependency.
2020-05-18 17:21:57 +02:00
function ViewportPane({
children,
className,
isActive,
onDrop,
acceptDropsFor,
}) {
2020-05-18 23:40:28 +02:00
/*const [{ isHovered, isHighlighted }, drop] = useDrop({
2020-05-18 17:21:57 +02:00
accept: acceptDropsFor,
// TODO: pass in as prop?
2020-05-18 17:21:57 +02:00
drop: (droppedItem, monitor) => {
const canDrop = monitor.canDrop();
const isOver = monitor.isOver();
if (canDrop && isOver && onDrop) {
2020-05-18 17:21:57 +02:00
onDrop(droppedItem);
}
},
// Monitor, and collect props; returned as values by `useDrop`
collect: monitor => ({
isHighlighted: monitor.canDrop(),
isHovered: monitor.isOver(),
}),
2020-05-18 23:40:28 +02:00
});*/
2020-05-18 23:40:28 +02:00
// ref={drop}
return (
<div
className={classnames(
'rounded-lg hover:border-primary-light transition duration-300 outline-none overflow-hidden',
{
2020-05-14 22:55:17 -04:00
'border-2 border-primary-light m-0': isActive,
'border border-secondary-light': !isActive,
2020-05-14 22:25:01 -04:00
},
className
)}
>
{children}
</div>
);
}
ViewportPane.propTypes = {
/** The ViewportComp */
children: PropTypes.node.isRequired,
2020-05-14 22:25:01 -04:00
/** Classes to append to container */
className: PropTypes.string,
/** Bool to show active styling */
isActive: PropTypes.bool.isRequired,
2020-05-18 17:21:57 +02:00
/** Indicates drag items we should accept for drops */
acceptDropsFor: PropTypes.string.isRequired,
/** Function that handles drop events */
onDrop: PropTypes.func.isRequired,
};
export default ViewportPane;