You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ToolbarButton.web.js 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import React from 'react';
  2. import Icon from 'react-fontawesome';
  3. import { stopEventPropagation } from '../../base/react';
  4. import AbstractToolbarButton from './AbstractToolbarButton';
  5. /**
  6. * Represents a button in Toolbar on Web.
  7. *
  8. * @extends AbstractToolbarButton
  9. */
  10. export default class ToolbarButton extends AbstractToolbarButton {
  11. /**
  12. * Renders the button of this Toolbar button.
  13. *
  14. * @param {Object} children - The children, if any, to be rendered inside
  15. * the button. Presumably, contains the icon of this Toolbar button.
  16. * @protected
  17. * @returns {ReactElement} The button of this Toolbar button.
  18. */
  19. _renderButton(children) {
  20. const props = {};
  21. 'onClick' in this.props
  22. && (props.onClick = stopEventPropagation(this.props.onClick));
  23. 'style' in this.props && (props.style = this.props.style);
  24. return React.createElement('button', props, children);
  25. }
  26. // eslint-disable-next-line valid-jsdoc
  27. /**
  28. * @inheritdoc
  29. */
  30. _renderIcon() {
  31. return super._renderIcon(Icon);
  32. }
  33. }
  34. /**
  35. * ToolbarButton component's property types.
  36. *
  37. * @static
  38. */
  39. ToolbarButton.propTypes = AbstractToolbarButton.propTypes;