@artsy/palette-mobile 17.28.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
|
*/
|
|
@@ -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