added Tooltip component
authorunknown <ajbura@gmail.com>
Tue, 10 Aug 2021 11:28:16 +0000 (16:58 +0530)
committerunknown <ajbura@gmail.com>
Tue, 10 Aug 2021 11:28:16 +0000 (16:58 +0530)
src/app/atoms/button/IconButton.jsx
src/app/atoms/button/IconButton.scss
src/app/atoms/tooltip/Tooltip.jsx [new file with mode: 0644]
src/app/atoms/tooltip/Tooltip.scss [new file with mode: 0644]

index cda6f98d06c322ea639135a35044ebf36fc835ed..34e2424e2c6a765f6935d70f9a5b7f7df29db026 100644 (file)
@@ -2,8 +2,8 @@ import React from 'react';
 import PropTypes from 'prop-types';
 import './IconButton.scss';
 
-import Tippy from '@tippyjs/react';
 import RawIcon from '../system-icons/RawIcon';
+import Tooltip from '../tooltip/Tooltip';
 import { blurOnBubbling } from './script';
 import Text from '../text/Text';
 
@@ -17,15 +17,9 @@ const IconButton = React.forwardRef(({
   variant, size, type,
   tooltip, tooltipPlacement, src, onClick,
 }, ref) => (
-  <Tippy
-    content={<Text variant="b2">{tooltip}</Text>}
-    className="ic-btn-tippy"
-    touch="hold"
-    arrow={false}
-    maxWidth={250}
+  <Tooltip
     placement={tooltipPlacement}
-    delay={[0, 0]}
-    duration={[100, 0]}
+    content={<Text variant="b2">{tooltip}</Text>}
   >
     <button
       ref={ref}
@@ -36,7 +30,7 @@ const IconButton = React.forwardRef(({
     >
       <RawIcon size={size} src={src} />
     </button>
-  </Tippy>
+  </Tooltip>
 ));
 
 IconButton.defaultProps = {
index 7bd327d21cf78294d63886131429040f41d09e23..a0cabc6a67f05fdc13588abc93be33f10646c04c 100644 (file)
   @include state.hover(var(--bg-surface-hover));
   @include focus(var(--bg-surface-hover));
   @include state.active(var(--bg-surface-active));
-}
-
-.ic-btn-tippy {
-  padding: var(--sp-extra-tight) var(--sp-normal);
-  background-color: var(--bg-tooltip);
-  border-radius: var(--bo-radius);
-  box-shadow: var(--bs-popup);
-
-  .text {
-    color: var(--tc-tooltip);
-  }
 }
\ No newline at end of file
diff --git a/src/app/atoms/tooltip/Tooltip.jsx b/src/app/atoms/tooltip/Tooltip.jsx
new file mode 100644 (file)
index 0000000..131c686
--- /dev/null
@@ -0,0 +1,37 @@
+import React from 'react';
+import PropTypes from 'prop-types';
+import './Tooltip.scss';
+import Tippy from '@tippyjs/react';
+
+function Tooltip({
+  className, placement, content, children,
+}) {
+  return (
+    <Tippy
+      content={content}
+      className={`tooltip ${className}`}
+      touch="hold"
+      arrow={false}
+      maxWidth={250}
+      placement={placement}
+      delay={[0, 0]}
+      duration={[100, 0]}
+    >
+      {children}
+    </Tippy>
+  );
+}
+
+Tooltip.defaultProps = {
+  placement: 'top',
+  className: '',
+};
+
+Tooltip.propTypes = {
+  className: PropTypes.string,
+  placement: PropTypes.string,
+  content: PropTypes.node.isRequired,
+  children: PropTypes.node.isRequired,
+};
+
+export default Tooltip;
diff --git a/src/app/atoms/tooltip/Tooltip.scss b/src/app/atoms/tooltip/Tooltip.scss
new file mode 100644 (file)
index 0000000..f609aa5
--- /dev/null
@@ -0,0 +1,10 @@
+.tooltip {
+  padding: var(--sp-extra-tight) var(--sp-normal);
+  background-color: var(--bg-tooltip);
+  border-radius: var(--bo-radius);
+  box-shadow: var(--bs-popup);
+
+  .text {
+    color: var(--tc-tooltip);
+  }
+}
\ No newline at end of file