@artsy/palette-mobile 13.0.9 → 13.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ # v13.0.10 (Mon Sep 18 2023)
2
+
3
+ #### 🐛 Bug Fix
4
+
5
+ - fix: Add flowDirection prop to tooltip component [#151](https://github.com/artsy/palette-mobile/pull/151) ([@olerichter00](https://github.com/olerichter00))
6
+
7
+ #### Authors: 1
8
+
9
+ - Ole ([@olerichter00](https://github.com/olerichter00))
10
+
11
+ ---
12
+
1
13
  # v13.0.9 (Fri Sep 15 2023)
2
14
 
3
15
  #### 🐛 Bug Fix
@@ -6,6 +6,8 @@ interface ToolTipContextValues {
6
6
  interface ToolTipProps {
7
7
  children?: React.ReactNode;
8
8
  enabled?: Boolean;
9
+ /** The direction the tooltip should flow. If not provided, the tooltip will flow to the left if it is near the right edge of the screen, and vice-versa */
10
+ flowDirection?: "LEFT" | "RIGHT";
9
11
  initialToolTipText?: string;
10
12
  maxWidth?: number;
11
13
  onPress?: () => void;
@@ -33,7 +33,7 @@ exports.ToolTipContext = (0, react_1.createContext)({
33
33
  * </ToolTip>
34
34
  *
35
35
  */
36
- const ToolTip = ({ children, enabled = true, initialToolTipText, maxWidth, onPress, position = "TOP", tapToDismiss = false, testID, xOffset = 0, yOffset = 5, }) => {
36
+ const ToolTip = ({ children, enabled = true, flowDirection, initialToolTipText, maxWidth, onPress, position = "TOP", tapToDismiss = false, testID, xOffset = 0, yOffset = 5, }) => {
37
37
  const { space } = (0, useTheme_1.useTheme)();
38
38
  const mWidth = (0, useScreenDimensions_1.useScreenDimensions)().width - space(2) * 2; // 40 accounting for padding 20 on each side of the screen
39
39
  const MAX_TOOLTIP_WIDTH = maxWidth ?? mWidth;
@@ -51,8 +51,8 @@ const ToolTip = ({ children, enabled = true, initialToolTipText, maxWidth, onPre
51
51
  // Calculate the direction of flow of the tooltip. So a tooltip near the right edge of the screen
52
52
  // should flow to the left so it remains in the viewport, and vice-versa. Without this, tooltip
53
53
  // around the edges can flow off screen
54
- const nearLeftEdge = pageX < mWidth / 4;
55
- const nearRightEdge = pageX > mWidth - mWidth / 4;
54
+ const nearLeftEdge = pageX < mWidth / 4 || flowDirection === "RIGHT";
55
+ const nearRightEdge = pageX > mWidth - mWidth / 4 || flowDirection === "LEFT";
56
56
  const extraStyle = nearLeftEdge ? { left: 0 } : nearRightEdge ? { right: 0 } : undefined;
57
57
  return ((0, jsx_runtime_1.jsxs)(exports.ToolTipContext.Provider, { value: {
58
58
  dismissToolTip,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@artsy/palette-mobile",
3
- "version": "13.0.9",
3
+ "version": "13.0.10",
4
4
  "description": "Artsy's design system for React Native",
5
5
  "scripts": {
6
6
  "android": "react-native run-android",