ohif-viewer/platform/ui-next/src/components/Viewport/ViewportActionButton.tsx
Dan Rukas 230ae9758b
ui(components): Viewport components added to ui-next (#4649)
Co-authored-by: sedghi <ar.sedghi@gmail.com>
2025-01-08 14:23:34 -05:00

32 lines
762 B
TypeScript

import React from 'react';
import PropTypes from 'prop-types';
/**
* A button that can trigger commands when clicked.
*/
function ViewportActionButton({ onInteraction, commands, id, children }) {
return (
<div
className="bg-primary-main hover:bg-primary-light ml-1 cursor-pointer rounded px-1.5 hover:text-black"
// Using onMouseUp because onClick wasn't firing if pointer-events are none.
onMouseUp={() => {
onInteraction({
itemId: id,
commands,
});
}}
>
{children}
</div>
);
}
ViewportActionButton.propTypes = {
id: PropTypes.string,
onInteraction: PropTypes.func.isRequired,
commands: PropTypes.array,
children: PropTypes.node,
};
export { ViewportActionButton };