2018-10-30 05:02:23 +00:00
|
|
|
/* @flow */
|
|
|
|
|
2017-06-19 16:01:44 +00:00
|
|
|
import React, { Component } from 'react';
|
2017-08-15 22:14:49 +00:00
|
|
|
import Tooltip from '@atlaskit/tooltip';
|
2017-06-19 16:01:44 +00:00
|
|
|
|
2017-08-15 22:14:49 +00:00
|
|
|
import { translate } from '../../../base/i18n';
|
2017-06-19 16:01:44 +00:00
|
|
|
|
2018-10-30 05:02:23 +00:00
|
|
|
/**
|
|
|
|
* The type of the React {@code Component} props of {@link BaseIndicator}.
|
|
|
|
*/
|
|
|
|
type Props = {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Additional CSS class names to set on the icon container.
|
|
|
|
*/
|
|
|
|
className: string,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The CSS classnames to set on the icon element of the component.
|
|
|
|
*/
|
|
|
|
iconClassName: string,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The font size for the icon.
|
|
|
|
*/
|
|
|
|
iconSize: string,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The ID attribue to set on the root element of the component.
|
|
|
|
*/
|
|
|
|
id: string,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Invoked to obtain translated strings.
|
|
|
|
*/
|
|
|
|
t: Function,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The translation key to use for displaying a tooltip when hovering over
|
|
|
|
* the component.
|
|
|
|
*/
|
|
|
|
tooltipKey: string,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* From which side of the indicator the tooltip should appear from,
|
|
|
|
* defaulting to "top".
|
|
|
|
*/
|
|
|
|
tooltipPosition: string
|
|
|
|
};
|
|
|
|
|
2017-06-19 16:01:44 +00:00
|
|
|
/**
|
|
|
|
* React {@code Component} for showing an icon with a tooltip.
|
|
|
|
*
|
|
|
|
* @extends Component
|
|
|
|
*/
|
2018-10-30 05:02:23 +00:00
|
|
|
class BaseIndicator extends Component<Props> {
|
2017-08-15 22:14:49 +00:00
|
|
|
/**
|
|
|
|
* Default values for {@code BaseIndicator} component's properties.
|
|
|
|
*
|
|
|
|
* @static
|
|
|
|
*/
|
2017-07-10 22:29:44 +00:00
|
|
|
static defaultProps = {
|
|
|
|
className: '',
|
|
|
|
iconClassName: '',
|
|
|
|
iconSize: 'auto',
|
2017-08-15 22:14:49 +00:00
|
|
|
id: '',
|
|
|
|
tooltipPosition: 'top'
|
2017-07-10 22:29:44 +00:00
|
|
|
};
|
|
|
|
|
2017-06-19 16:01:44 +00:00
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
render() {
|
2017-08-15 22:14:49 +00:00
|
|
|
const {
|
|
|
|
className,
|
|
|
|
iconClassName,
|
|
|
|
iconSize,
|
|
|
|
id,
|
|
|
|
t,
|
|
|
|
tooltipKey,
|
|
|
|
tooltipPosition
|
|
|
|
} = this.props;
|
2017-06-19 16:01:44 +00:00
|
|
|
|
2017-08-15 22:14:49 +00:00
|
|
|
const iconContainerClassName = `indicator-icon-container ${className}`;
|
2017-06-19 16:01:44 +00:00
|
|
|
|
2017-08-15 22:14:49 +00:00
|
|
|
return (
|
|
|
|
<div className = 'indicator-container'>
|
|
|
|
<Tooltip
|
2018-04-16 17:21:01 +00:00
|
|
|
content = { t(tooltipKey) }
|
2017-08-15 22:14:49 +00:00
|
|
|
position = { tooltipPosition }>
|
|
|
|
<span
|
|
|
|
className = { iconContainerClassName }
|
|
|
|
id = { id }>
|
|
|
|
<i
|
|
|
|
className = { iconClassName }
|
|
|
|
style = {{ fontSize: iconSize }} />
|
|
|
|
</span>
|
|
|
|
</Tooltip>
|
|
|
|
</div>
|
2017-06-19 16:01:44 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-15 22:14:49 +00:00
|
|
|
export default translate(BaseIndicator);
|