Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

ToolbarButton.web.js 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import Tooltip from '@atlaskit/tooltip';
  2. import PropTypes from 'prop-types';
  3. import React from 'react';
  4. import AbstractToolbarButton from './AbstractToolbarButton';
  5. /**
  6. * Represents a button in the toolbar.
  7. *
  8. * @extends AbstractToolbarButton
  9. */
  10. class ToolbarButton extends AbstractToolbarButton {
  11. /**
  12. * Default values for {@code ToolbarButton} component's properties.
  13. *
  14. * @static
  15. */
  16. static defaultProps = {
  17. tooltipPosition: 'top'
  18. };
  19. /**
  20. * {@code ToolbarButton} component's property types.
  21. *
  22. * @static
  23. */
  24. static propTypes = {
  25. ...AbstractToolbarButton.propTypes,
  26. /**
  27. * The text to display in the tooltip.
  28. */
  29. tooltip: PropTypes.string,
  30. /**
  31. * From which direction the tooltip should appear, relative to the
  32. * button.
  33. */
  34. tooltipPosition: PropTypes.string
  35. }
  36. /**
  37. * Renders the button of this {@code ToolbarButton}.
  38. *
  39. * @param {Object} children - The children, if any, to be rendered inside
  40. * the button. Presumably, contains the icon of this {@code ToolbarButton}.
  41. * @protected
  42. * @returns {ReactElement} The button of this {@code ToolbarButton}.
  43. */
  44. _renderButton(children) {
  45. return (
  46. <div
  47. aria-label = { this.props.accessibilityLabel }
  48. className = 'toolbox-button'
  49. onClick = { this.props.onClick }>
  50. { this.props.tooltip
  51. ? <Tooltip
  52. content = { this.props.tooltip }
  53. position = { this.props.tooltipPosition }>
  54. { children }
  55. </Tooltip>
  56. : children }
  57. </div>
  58. );
  59. }
  60. /**
  61. * Renders the icon of this {@code ToolbarButton}.
  62. *
  63. * @inheritdoc
  64. */
  65. _renderIcon() {
  66. return (
  67. <div className = 'toolbox-icon'>
  68. <i className = { this.props.iconName } />
  69. </div>
  70. );
  71. }
  72. }
  73. export default ToolbarButton;