From c179b970e1303d9d5f7088a32b0ff368ab41c684 Mon Sep 17 00:00:00 2001
From: cchaos
Date: Thu, 9 Aug 2018 15:08:30 -0400
Subject: [PATCH] Added a delay option to tooltip
and wrapped action items with tooltip **if enabled and has description**
---
src-docs/src/views/tool_tip/tool_tip.js | 10 +++++
.../basic_table/collapsed_item_actions.js | 11 +++++-
.../basic_table/default_item_action.js | 39 +++++++++++--------
src/components/tool_tip/_tool_tip.scss | 5 +++
src/components/tool_tip/tool_tip.js | 15 +++++++
5 files changed, 62 insertions(+), 18 deletions(-)
diff --git a/src-docs/src/views/tool_tip/tool_tip.js b/src-docs/src/views/tool_tip/tool_tip.js
index 58f4fbff504..2e8d25501cf 100644
--- a/src-docs/src/views/tool_tip/tool_tip.js
+++ b/src-docs/src/views/tool_tip/tool_tip.js
@@ -45,6 +45,16 @@ export default () => (
+
+ This tooltip has a long delay because it might be in a repeatable component{' '}
+
+ wink
+
+
+
This tooltip appears on the bottom of this icon:{' '}
);
+ const withTooltip = !allDisabled && (
+
+ {popoverButton}
+
+ );
+
return (
action.onClick(item);
const color = this.resolveActionColor();
const icon = this.resolveActionIcon();
+
+ let button;
if (action.type === 'icon') {
if (!icon) {
throw new Error(`Cannot render item action [${action.name}]. It is configured to render as an icon but no
icon is provided. Make sure to set the 'icon' property of the action`);
}
- return (
+ button = (
);
+ } else {
+ button = (
+
+ {action.name}
+
+ );
}
- return (
-
- {action.name}
-
- );
+ return (enabled && action.description) ? (
+
+ {button}
+
+ ) : button;
}
resolveActionIcon() {
diff --git a/src/components/tool_tip/_tool_tip.scss b/src/components/tool_tip/_tool_tip.scss
index 100e7818c5e..3d882c51fc4 100644
--- a/src/components/tool_tip/_tool_tip.scss
+++ b/src/components/tool_tip/_tool_tip.scss
@@ -16,6 +16,11 @@
animation: euiToolTipTop $euiAnimSpeedSlow ease-out $euiAnimSpeedNormal forwards;
z-index: $euiZLevel9;
+ // Animation delays
+ &.euiToolTip--delayLong {
+ animation-delay: $euiAnimSpeedNormal * 5;
+ }
+
// Custom sizing
$arrowSize: $euiSizeM;
$arrowPlusSize: (($arrowSize/2) + 1px) * -1; /* 1 */
diff --git a/src/components/tool_tip/tool_tip.js b/src/components/tool_tip/tool_tip.js
index ed9ae1e20d8..78183f23d22 100644
--- a/src/components/tool_tip/tool_tip.js
+++ b/src/components/tool_tip/tool_tip.js
@@ -22,6 +22,13 @@ const positionsToClassNameMap = {
export const POSITIONS = Object.keys(positionsToClassNameMap);
+const delayToClassNameMap = {
+ regular: null,
+ long: 'euiToolTip--delayLong',
+};
+
+export const DELAY = Object.keys(delayToClassNameMap);
+
const DEFAULT_TOOLTIP_STYLES = {
// position the tooltip content near the top-left
// corner of the window so it can't create scrollbars
@@ -161,6 +168,7 @@ export class EuiToolTip extends Component {
anchorClassName,
content,
title,
+ delay,
...rest
} = this.props;
@@ -169,6 +177,7 @@ export class EuiToolTip extends Component {
const classes = classNames(
'euiToolTip',
positionsToClassNameMap[this.state.calculatedPosition],
+ delayToClassNameMap[delay],
className
);
@@ -254,6 +263,11 @@ EuiToolTip.propTypes = {
*/
position: PropTypes.oneOf(POSITIONS),
+ /**
+ * Delay before showing tooltip. Good for repeatable items.
+ */
+ delay: PropTypes.oneOf(DELAY),
+
/**
* Passes onto the tooltip itself, not the trigger.
*/
@@ -267,4 +281,5 @@ EuiToolTip.propTypes = {
EuiToolTip.defaultProps = {
position: 'top',
+ delay: 'regular',
};