+ {
+ tooltipRef.current = node;
+ if (forwardRef) forwardRef(node);
+ }}
+ {...rest}
+ />
+ {useAriaLabel && (
+
+ {ariaLabel}
+
+ )}
+
+ );
+});
+
+////////////////////////////////////////////////////////////////////////////////
+// TODO: research longpress tooltips on Android, iOS, implement here.
+// - Probably want to position it by default above, since your thumb
+// is below and would cover it
+// - I'm thinking after longpress, display the tooltip and cancel any
+// click events. Then on touchend, hide the tooltip after a timer
+// in case their hand is obstructing it, then can remove and read
+// the tooltip
+
+// feels awkward when it's perfectly aligned w/ the trigger
+const OFFSET = 8;
+
+const getStyles = (position, triggerRect, tooltipRect) => {
+ const haventMeasuredTooltipYet = !tooltipRect;
+ if (haventMeasuredTooltipYet) {
+ return { visibility: "hidden" };
+ }
+ return position(triggerRect, tooltipRect);
+};
+
+const positionDefault = (triggerRect, tooltipRect) => {
+ const styles = {
+ left: `${triggerRect.left + window.scrollX}px`,
+ top: `${triggerRect.top + triggerRect.height + window.scrollY}px`
+ };
+
+ const collisions = {
+ top: triggerRect.top - tooltipRect.height < 0,
+ right: window.innerWidth < triggerRect.left + tooltipRect.width,
+ bottom:
+ window.innerHeight < triggerRect.bottom + tooltipRect.height + OFFSET,
+ left: triggerRect.left - tooltipRect.width < 0
+ };
+
+ const directionRight = collisions.right && !collisions.left;
+ const directionUp = collisions.bottom && !collisions.top;
+
+ return {
+ ...styles,
+ left: directionRight
+ ? `${triggerRect.right +
+ OFFSET / 2 -
+ tooltipRect.width +
+ window.scrollX}px`
+ : `${triggerRect.left - OFFSET / 2 + window.scrollX}px`,
+ top: directionUp
+ ? `${triggerRect.top - OFFSET - tooltipRect.height + window.scrollY}px`
+ : `${triggerRect.top + OFFSET + triggerRect.height + window.scrollY}px`
+ };
+};
diff --git a/vendor/@reach/tooltip/styles.css b/vendor/@reach/tooltip/styles.css
new file mode 100644
index 0000000000..9c5e395afa
--- /dev/null
+++ b/vendor/@reach/tooltip/styles.css
@@ -0,0 +1,11 @@
+[data-reach-tooltip] {
+ pointer-events: none;
+ position: absolute;
+ padding: 0.25em;
+ box-shadow: 2px 2px 10px hsla(0, 0%, 0%, 0.1);
+ white-space: nowrap;
+ font-size: 85%;
+ background: #f0f0f0;
+ color: #444;
+ border: solid 1px #ccc;
+}
diff --git a/yarn.lock b/yarn.lock
index 5b81a1d831..8fad6396cc 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1052,10 +1052,8 @@
react-lifecycles-compat "^3.0.4"
warning "^3.0.0"
-"@reach/tooltip@^0.1.1":
- version "0.1.1"
- resolved "https://registry.yarnpkg.com/@reach/tooltip/-/tooltip-0.1.1.tgz#7f0385624eaffabcd4f075a098ef0fe4b472ce5d"
- integrity sha512-EawPeRdeajl5HwtM8Q1rz0aNzOgRKnbs4GNW4tUa/6+F8yN93nZGxfYyefYGQgjzVOd0HdgeatUVqDQMgcldYA==
+"@reach/tooltip@file:./vendor/@reach/tooltip":
+ version "0.1.2"
dependencies:
"@reach/auto-id" "0.2.0"
"@reach/portal" "^0.2.0"