import React from 'react'; import PropTypes from 'prop-types'; import IconButton from '../IconButton'; import Icon from '../Icon'; import Tooltip from '../Tooltip'; const ToolbarButton = ({ id, icon, label, commands, onInteraction, dropdownContent, // className, size, toolTipClassName, disableToolTip = false, ...rest // }) => { const shouldShowDropdown = !!dropdownContent; const iconEl = icon ? :
{label || 'Missing icon and label'}
; const sizeToUse = size ?? 'toolbar'; const toolTipClassNameToUse = toolTipClassName !== undefined ? toolTipClassName : sizeToUse === 'toolbar' ? 'w-[40px] h-[40px]' : 'w-[32px] h-[32px]'; return (
{ onInteraction({ itemId: id, commands, }); }} name={label} key={id} id={id} {...rest} > {iconEl}
); }; ToolbarButton.defaultProps = { dropdownContent: null, }; ToolbarButton.propTypes = { /* Influences background/hover styling */ id: PropTypes.string.isRequired, className: PropTypes.string, commands: PropTypes.oneOfType([PropTypes.array, PropTypes.object, PropTypes.string]), onInteraction: PropTypes.func, icon: PropTypes.string.isRequired, label: PropTypes.string.isRequired, /** Tooltip content can be replaced for a customized content by passing a node to this value. */ dropdownContent: PropTypes.oneOfType([PropTypes.node, PropTypes.func]), size: PropTypes.string, toolTipClassName: PropTypes.string, disableToolTip: PropTypes.bool, }; export default ToolbarButton;