import * as React from "react"; import { Tooltip } from "@dndbeyond/character-common-components/es"; import { CharacterTheme } from "@dndbeyond/character-rules-engine/es"; interface Props { className: string; tooltip: string; onClick?: () => void; enableTooltip: boolean; showIconOnEdge: boolean; showIcon: boolean; theme: CharacterTheme; } export default class ManageIcon extends React.PureComponent { static defaultProps = { tooltip: "Manage", enableTooltip: true, showIconOnEdge: true, showIcon: true, className: "", }; handleClick = (evt: React.MouseEvent): void => { const { onClick } = this.props; if (onClick) { evt.stopPropagation(); evt.nativeEvent.stopImmediatePropagation(); onClick(); } }; render() { const { tooltip, children, onClick, enableTooltip, showIconOnEdge, showIcon, className, theme, } = this.props; let classNames: Array = [className, "ddbc-manage-icon"]; if (showIconOnEdge) { classNames.push("ddbc-manage-icon--edge-icon"); } if (showIcon) { classNames.push("ddbc-manage-icon--interactive"); } if (theme?.isDarkMode) { classNames.push("ddbc-manage-icon--dark-mode"); } let contentNode: React.ReactNode = ( {children && ( {children} )} {showIcon && ( )} ); if (enableTooltip) { return ( {contentNode} ); } return ( {contentNode} ); } }