您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

BaseIndicator.js 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. import React, { Component } from 'react';
  2. import Tooltip from '@atlaskit/tooltip';
  3. import { translate } from '../../../base/i18n';
  4. /**
  5. * React {@code Component} for showing an icon with a tooltip.
  6. *
  7. * @extends Component
  8. */
  9. class BaseIndicator extends Component {
  10. /**
  11. * Default values for {@code BaseIndicator} component's properties.
  12. *
  13. * @static
  14. */
  15. static defaultProps = {
  16. className: '',
  17. iconClassName: '',
  18. iconSize: 'auto',
  19. id: '',
  20. tooltipPosition: 'top'
  21. };
  22. /**
  23. * {@code BaseIndicator} component's property types.
  24. *
  25. * @static
  26. */
  27. static propTypes = {
  28. /**
  29. * Additional CSS class names to set on the icon container.
  30. */
  31. className: React.PropTypes.string,
  32. /**
  33. * The CSS classnames to set on the icon element of the component.
  34. */
  35. iconClassName: React.PropTypes.string,
  36. /**
  37. * The font size for the icon.
  38. */
  39. iconSize: React.PropTypes.string,
  40. /**
  41. * The ID attribue to set on the root element of the component.
  42. */
  43. id: React.PropTypes.string,
  44. /**
  45. * Invoked to obtain translated strings.
  46. */
  47. t: React.PropTypes.func,
  48. /**
  49. * The translation key to use for displaying a tooltip when hovering
  50. * over the component.
  51. */
  52. tooltipKey: React.PropTypes.string,
  53. /**
  54. * From which side of the indicator the tooltip should appear from.
  55. * Defaults to "top".
  56. */
  57. tooltipPosition: React.PropTypes.string
  58. };
  59. /**
  60. * Implements React's {@link Component#render()}.
  61. *
  62. * @inheritdoc
  63. * @returns {ReactElement}
  64. */
  65. render() {
  66. const {
  67. className,
  68. iconClassName,
  69. iconSize,
  70. id,
  71. t,
  72. tooltipKey,
  73. tooltipPosition
  74. } = this.props;
  75. const iconContainerClassName = `indicator-icon-container ${className}`;
  76. return (
  77. <div className = 'indicator-container'>
  78. <Tooltip
  79. description = { t(tooltipKey) }
  80. position = { tooltipPosition }>
  81. <span
  82. className = { iconContainerClassName }
  83. id = { id }>
  84. <i
  85. className = { iconClassName }
  86. style = {{ fontSize: iconSize }} />
  87. </span>
  88. </Tooltip>
  89. </div>
  90. );
  91. }
  92. }
  93. export default translate(BaseIndicator);