Close #1828 Squashed commit of the following: commit a3955c989a939866c6772b147547344b3f8769c4 Merge: c91c41cb2759d81aAuthor: ArtemBaskal <a.baskal@adguard.com> Date: Mon Jul 13 15:14:47 2020 +0300 Merge branch 'master' into fix/1828 commit c91c41cbc5f616e0af1092424e42b909d2f43f7c Author: ArtemBaskal <a.baskal@adguard.com> Date: Mon Jul 13 13:48:54 2020 +0300 Fix cell overflow commit 19e1d31a40f2e1bb1189a85b72507bcc364d4e0c Merge: af31f48ca33164bfAuthor: ArtemBaskal <a.baskal@adguard.com> Date: Mon Jul 13 12:36:44 2020 +0300 Merge branch 'master' into fix/1828 commit af31f48c4d2699ebfbd2034711c51499b42e40f5 Author: ArtemBaskal <a.baskal@adguard.com> Date: Mon Jul 13 10:45:57 2020 +0300 minor commit d9507c5f3f5758e587766ae0fa45f1b9ad703ccf Author: ArtemBaskal <a.baskal@adguard.com> Date: Fri Jul 10 18:34:22 2020 +0300 - client: Fix query logs UI issues
67 lines
2.0 KiB
JavaScript
67 lines
2.0 KiB
JavaScript
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import TooltipTrigger from 'react-popper-tooltip';
|
|
import { Trans } from 'react-i18next';
|
|
import classNames from 'classnames';
|
|
import './Tooltip.css';
|
|
import 'react-popper-tooltip/dist/styles.css';
|
|
import { HIDE_TOOLTIP_DELAY } from '../../../helpers/constants';
|
|
import { processContent } from '../../../helpers/helpers';
|
|
|
|
const getHintElement = ({
|
|
className,
|
|
contentItemClass,
|
|
columnClass,
|
|
canShowTooltip = true,
|
|
xlinkHref,
|
|
title,
|
|
placement,
|
|
tooltipClass,
|
|
content,
|
|
renderContent = content ? React.Children.map(
|
|
processContent(content),
|
|
(item, idx) => <div key={idx} className={contentItemClass}>
|
|
<Trans>{item || '—'}</Trans>
|
|
</div>,
|
|
) : null,
|
|
}) => <TooltipTrigger placement={placement} trigger="hover" delayHide={HIDE_TOOLTIP_DELAY} tooltip={
|
|
({
|
|
tooltipRef,
|
|
getTooltipProps,
|
|
}) => <div {...getTooltipProps({
|
|
ref: tooltipRef,
|
|
className: classNames('tooltip__container', tooltipClass, { 'd-none': !canShowTooltip }),
|
|
})}
|
|
>
|
|
{title && <div className="pb-4 h-25 grid-content font-weight-bold">
|
|
<Trans>{title}</Trans>
|
|
</div>}
|
|
<div className={classNames(columnClass)}>{renderContent}</div>
|
|
</div>
|
|
}>{({
|
|
getTriggerProps, triggerRef,
|
|
}) => <span {...getTriggerProps({ ref: triggerRef })}>
|
|
{xlinkHref && <svg className={className}>
|
|
<use xlinkHref={`#${xlinkHref}`} />
|
|
</svg>}
|
|
</span>}
|
|
</TooltipTrigger>;
|
|
|
|
getHintElement.propTypes = {
|
|
className: PropTypes.string,
|
|
contentItemClass: PropTypes.string,
|
|
columnClass: PropTypes.string,
|
|
tooltipClass: PropTypes.string,
|
|
title: PropTypes.string,
|
|
placement: PropTypes.string,
|
|
canShowTooltip: PropTypes.string,
|
|
xlinkHref: PropTypes.string,
|
|
content: PropTypes.oneOfType([
|
|
PropTypes.string,
|
|
PropTypes.array,
|
|
]),
|
|
renderContent: PropTypes.arrayOf(PropTypes.element),
|
|
};
|
|
|
|
export default getHintElement;
|