@artsy/palette-mobile 17.27.0 → 17.29.0
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/dist/constants.d.ts
CHANGED
package/dist/constants.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { PixelRatio } from "react-native";
|
|
1
2
|
/**
|
|
2
3
|
* Touch area box for UI elements
|
|
3
4
|
*/
|
|
4
5
|
export const DEFAULT_HIT_SLOP = { top: 20, bottom: 20, left: 20, right: 20 };
|
|
6
|
+
export const DEFAULT_ICON_SIZE = 24 * PixelRatio.getFontScale();
|
|
5
7
|
/**
|
|
6
8
|
* Default active opacity for elements that use Palette's <Touchable />
|
|
7
9
|
*/
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import RNPopover from "react-native-popover-view";
|
|
3
|
-
|
|
3
|
+
import { PopoverProps as RNPopoverProps } from "react-native-popover-view/dist/Types";
|
|
4
|
+
interface PopoverProps extends Omit<RNPopoverProps, "placement"> {
|
|
4
5
|
children?: React.ReactElement;
|
|
5
6
|
variant?: PopoverVariant;
|
|
6
7
|
title?: React.ReactElement;
|
|
@@ -13,6 +14,6 @@ interface PopoverProps {
|
|
|
13
14
|
noCloseIcon?: boolean;
|
|
14
15
|
visible?: boolean;
|
|
15
16
|
}
|
|
16
|
-
export declare const Popover: ({ variant, children, visible, onOpenComplete, onPressOutside, onDismiss, onCloseComplete, placement, title, content, noCloseIcon, }: PopoverProps) => JSX.Element;
|
|
17
|
+
export declare const Popover: ({ variant, children, visible, onOpenComplete, onPressOutside, onDismiss, onCloseComplete, placement, title, content, noCloseIcon, ...rest }: PopoverProps) => JSX.Element;
|
|
17
18
|
export type PopoverVariant = "light" | "dark";
|
|
18
19
|
export {};
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Platform, StatusBar } from "react-native";
|
|
3
2
|
import RNPopover from "react-native-popover-view";
|
|
4
3
|
import { Easing } from "react-native-reanimated";
|
|
5
4
|
import { CloseIcon } from "../../svgs";
|
|
6
5
|
import { useColor } from "../../utils/hooks";
|
|
7
6
|
import { Flex } from "../Flex";
|
|
8
7
|
import { Touchable } from "../Touchable";
|
|
9
|
-
export const Popover = ({ variant = "dark", children, visible, onOpenComplete, onPressOutside, onDismiss, onCloseComplete, placement = "top", title, content, noCloseIcon, }) => {
|
|
8
|
+
export const Popover = ({ variant = "dark", children, visible, onOpenComplete, onPressOutside, onDismiss, onCloseComplete, placement = "top", title, content, noCloseIcon, ...rest }) => {
|
|
10
9
|
const color = useColor();
|
|
11
10
|
const DROP_SHADOW = {
|
|
12
11
|
shadowColor: color("mono100"),
|
|
@@ -30,10 +29,8 @@ export const Popover = ({ variant = "dark", children, visible, onOpenComplete, o
|
|
|
30
29
|
},
|
|
31
30
|
};
|
|
32
31
|
const style = POPOVER_VARIANTS[variant];
|
|
33
|
-
return (_jsx(RNPopover, { backgroundStyle: { opacity: 0.5, backgroundColor: color("mono100") }, popoverStyle: [{ backgroundColor: style.backgroundColor }, style.shadow], from: children, isVisible: visible,
|
|
34
|
-
// this is required to make sure that the popover is positioned correctly on android
|
|
35
|
-
verticalOffset: Platform.OS === "android" ? -(StatusBar.currentHeight ?? 0) : 0, onCloseComplete: onCloseComplete, onOpenComplete: onOpenComplete, onRequestClose: onPressOutside, placement: placement, arrowSize: { height: 11, width: 22 }, animationConfig: {
|
|
32
|
+
return (_jsx(RNPopover, { backgroundStyle: { opacity: 0.5, backgroundColor: color("mono100") }, popoverStyle: [{ backgroundColor: style.backgroundColor }, style.shadow], from: children, isVisible: visible, onCloseComplete: onCloseComplete, onOpenComplete: onOpenComplete, onRequestClose: onPressOutside, placement: placement, arrowSize: { height: 11, width: 22 }, animationConfig: {
|
|
36
33
|
duration: 400,
|
|
37
34
|
easing: Easing.out(Easing.exp),
|
|
38
|
-
}, children: _jsxs(Flex, { backgroundColor: POPOVER_VARIANTS[variant].backgroundColor, p: 1, children: [_jsxs(Flex, { flexDirection: "row", justifyContent: "space-between", alignItems: "center", children: [title ? title : _jsx(Flex, {}), !noCloseIcon && (_jsx(Touchable, { onPress: onDismiss, accessibilityRole: "button", "aria-label": "Dismiss popover", children: _jsx(Flex, { ml: 0.5, children: _jsx(CloseIcon, { width: 18, height: 18, fill: style.fill }) }) }))] }), content] }) }));
|
|
35
|
+
}, ...rest, children: _jsxs(Flex, { backgroundColor: POPOVER_VARIANTS[variant].backgroundColor, p: 1, children: [_jsxs(Flex, { flexDirection: "row", justifyContent: "space-between", alignItems: "center", children: [title ? title : _jsx(Flex, {}), !noCloseIcon && (_jsx(Touchable, { onPress: onDismiss, accessibilityRole: "button", "aria-label": "Dismiss popover", children: _jsx(Flex, { ml: 0.5, children: _jsx(CloseIcon, { width: 18, height: 18, fill: style.fill }) }) }))] }), content] }) }));
|
|
39
36
|
};
|
|
@@ -2,8 +2,9 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
2
2
|
import Animated, { Easing, FadeIn, FadeOut, useAnimatedStyle, useDerivedValue, } from "react-native-reanimated";
|
|
3
3
|
import { useScreenScrollContext } from "./ScreenScrollContext";
|
|
4
4
|
import { NAVBAR_HEIGHT, ZINDEX } from "./constants";
|
|
5
|
-
import { DEFAULT_HIT_SLOP } from "../../constants";
|
|
5
|
+
import { DEFAULT_HIT_SLOP, DEFAULT_ICON_SIZE } from "../../constants";
|
|
6
6
|
import { ArrowLeftIcon } from "../../svgs/ArrowLeftIcon";
|
|
7
|
+
import { useScreenDimensions, useSpace } from "../../utils/hooks";
|
|
7
8
|
import { Flex } from "../Flex";
|
|
8
9
|
import { Text } from "../Text";
|
|
9
10
|
import { Touchable } from "../Touchable";
|
|
@@ -11,7 +12,12 @@ export const AnimatedHeader = (props) => {
|
|
|
11
12
|
return _jsx(Header, { animated: true, ...props });
|
|
12
13
|
};
|
|
13
14
|
export const Header = ({ animated = false, hideLeftElements, hideRightElements, hideTitle, leftElements, onBack, rightElements, title, titleProps = {}, }) => {
|
|
14
|
-
|
|
15
|
+
const { width } = useScreenDimensions();
|
|
16
|
+
const space = useSpace();
|
|
17
|
+
// Assumes small left and right elements, it protects from overflowing
|
|
18
|
+
// but doesn't cover edge cases where right or left are bigger
|
|
19
|
+
const centerMaxWidth = width - space(4) - DEFAULT_ICON_SIZE * 2;
|
|
20
|
+
return (_jsxs(Flex, { height: NAVBAR_HEIGHT, flexDirection: "row", px: 2, zIndex: ZINDEX.header, backgroundColor: "background", alignItems: "center", children: [_jsx(Flex, { flex: 1, children: _jsx(Left, { leftElements: leftElements, onBack: onBack, hideLeftElements: hideLeftElements }) }), _jsx(Flex, { maxWidth: centerMaxWidth, ...titleProps, children: _jsx(Center, { animated: animated, title: title, hideTitle: hideTitle }) }), _jsx(Flex, { flex: 1, alignItems: "flex-end", children: _jsx(Right, { rightElements: rightElements, hideRightElements: hideRightElements }) })] }));
|
|
15
21
|
};
|
|
16
22
|
const Right = ({ hideRightElements, rightElements }) => {
|
|
17
23
|
return _jsx(_Fragment, { children: !hideRightElements && rightElements });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@artsy/palette-mobile",
|
|
3
|
-
"version": "17.
|
|
3
|
+
"version": "17.29.0",
|
|
4
4
|
"description": "Artsy's design system for React Native",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"android": "RCT_METRO_PORT=8082 react-native run-android --port 8082 --terminal terminal",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"react-native-blurhash": "^2.1.1",
|
|
46
46
|
"react-native-collapsible-tab-view": "^8.0.1",
|
|
47
47
|
"react-native-pager-view": "6.5.0",
|
|
48
|
-
"react-native-popover-view": "^
|
|
48
|
+
"react-native-popover-view": "^6.1.0",
|
|
49
49
|
"react-spring": "8.0.23",
|
|
50
50
|
"styled-system": "^5.1.5"
|
|
51
51
|
},
|