diff --git a/src/dataDisplay/Icon/index.tsx b/src/dataDisplay/Icon/index.tsx
index 9d51ed0f..23cd417a 100644
--- a/src/dataDisplay/Icon/index.tsx
+++ b/src/dataDisplay/Icon/index.tsx
@@ -1,7 +1,7 @@
import React from 'react';
import styled from 'styled-components';
-import Tooltip from '@material-ui/core/Tooltip';
-import { withStyles } from '@material-ui/core/styles';
+
+import { Tooltip } from '../..';
import add from './images/add';
import addressBook from './images/addressBook';
@@ -72,9 +72,8 @@ import transactionsInactive from './images/transactionsInactive';
import unlocked from './images/unlocked';
import userEdit from './images/userEdit';
import wallet from './images/wallet';
-import { rgba } from 'polished';
-import theme, { ThemeColors, ThemeIconSize } from '../../theme';
+import { ThemeColors, ThemeIconSize } from '../../theme';
const StyledIcon = styled.span<{ color?: ThemeColors }>`
display: inline-flex;
@@ -85,18 +84,6 @@ const StyledIcon = styled.span<{ color?: ThemeColors }>`
}
`;
-const StyledTooltip = withStyles(() => ({
- popper: {
- zIndex: 2001,
- },
- tooltip: {
- backgroundColor: theme.colors.overlay.color,
- border: `1px solid ${theme.colors.icon}`,
- boxShadow: `1px 2px 4px ${rgba(theme.colors.shadow.color, 0.08)}`,
- color: theme.colors.text,
- },
-}))(Tooltip);
-
const icons = {
add,
addressBook,
@@ -199,8 +186,8 @@ export const Icon = ({
return tooltip === undefined ? (
IconElement
) : (
-
+
{IconElement}
-
+
);
};
diff --git a/src/dataDisplay/Tooltip/index.stories.tsx b/src/dataDisplay/Tooltip/index.stories.tsx
new file mode 100644
index 00000000..2d568b67
--- /dev/null
+++ b/src/dataDisplay/Tooltip/index.stories.tsx
@@ -0,0 +1,27 @@
+import React from 'react';
+
+import { Tooltip } from './index';
+
+export default {
+ title: 'Data Display/Tooltip',
+ component: Tooltip,
+ parameters: {
+ componentSubtitle: 'Add a tooltip to any ReactElement passed as a child.',
+ },
+};
+
+export const Basic = (): React.ReactElement => {
+ return (
+
+ hover me
+
+ );
+};
+
+export const CustomColor = (): React.ReactElement => {
+ return (
+
+ hover me
+
+ );
+};
diff --git a/src/dataDisplay/Tooltip/index.tsx b/src/dataDisplay/Tooltip/index.tsx
new file mode 100644
index 00000000..e4ee45e7
--- /dev/null
+++ b/src/dataDisplay/Tooltip/index.tsx
@@ -0,0 +1,61 @@
+import React, { ReactElement } from 'react';
+import MUITooltip, { TooltipProps } from '@material-ui/core/Tooltip';
+import { withStyles } from '@material-ui/core/styles';
+import { rgba } from 'polished';
+
+import theme, { ThemeColors } from '../../theme';
+
+type TooltipColors = {
+ backgroundColor?: ThemeColors;
+ borderColor?: ThemeColors;
+ textColor?: ThemeColors;
+};
+
+const customTooltip = ({
+ backgroundColor,
+ borderColor,
+ textColor,
+}: TooltipColors) =>
+ withStyles(() => ({
+ popper: {
+ zIndex: 2001,
+ },
+ tooltip: {
+ backgroundColor: backgroundColor
+ ? (theme.colors[backgroundColor] as string)
+ : theme.colors.overlay.color,
+ border: `1px solid ${
+ borderColor ? (theme.colors[borderColor] as string) : theme.colors.icon
+ }`,
+ boxShadow: `1px 2px 4px ${rgba(theme.colors.shadow.color, 0.08)}`,
+ color: textColor
+ ? (theme.colors[textColor] as string)
+ : theme.colors.text,
+ },
+ }))(MUITooltip);
+
+type Props = {
+ title: string;
+ children: ReactElement;
+} & TooltipColors;
+
+export const Tooltip = ({
+ title,
+ backgroundColor,
+ borderColor,
+ textColor,
+ children,
+ ...rest
+}: Props & TooltipProps): ReactElement => {
+ const StyledTooltip = customTooltip({
+ backgroundColor,
+ borderColor,
+ textColor,
+ });
+
+ return (
+
+ {children}
+
+ );
+};
diff --git a/src/dataDisplay/index.ts b/src/dataDisplay/index.ts
index 5a38ec43..c97ae5c9 100644
--- a/src/dataDisplay/index.ts
+++ b/src/dataDisplay/index.ts
@@ -8,6 +8,7 @@ export * from './Icon';
export { default as IconText } from './IconText';
export { default as Layout } from './Layout';
export * from './Table';
+export * from './Tooltip';
export { default as Text } from './Text';
export { default as Title } from './Title';
export { default as Section } from './Section';