@artsy/palette-mobile 13.1.7 → 13.1.8
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.
|
@@ -40,16 +40,22 @@ const AnimatedHeader = (props) => {
|
|
|
40
40
|
};
|
|
41
41
|
exports.AnimatedHeader = AnimatedHeader;
|
|
42
42
|
const Header = ({ animated = false, hideLeftElements, hideRightElements, hideTitle, leftElements, onBack, rightElements, title, titleProps = {}, }) => {
|
|
43
|
-
return ((0, jsx_runtime_1.jsxs)(Flex_1.Flex, { height: constants_1.NAVBAR_HEIGHT, flexDirection: "row", px: 2, py: 1, zIndex: constants_1.ZINDEX.header, backgroundColor: "background", alignItems: "center", width: "100%", children: [
|
|
43
|
+
return ((0, jsx_runtime_1.jsxs)(Flex_1.Flex, { height: constants_1.NAVBAR_HEIGHT, flexDirection: "row", px: 2, py: 1, zIndex: constants_1.ZINDEX.header, backgroundColor: "background", alignItems: "center", width: "100%", children: [(0, jsx_runtime_1.jsx)(Left, { leftElements: leftElements, onBack: onBack, hideLeftElements: hideLeftElements }), (0, jsx_runtime_1.jsx)(Center, { animated: animated, titleProps: titleProps, title: title, hideTitle: hideTitle }), (0, jsx_runtime_1.jsx)(Right, { rightElements: rightElements, hideRightElements: hideRightElements })] }));
|
|
44
44
|
};
|
|
45
45
|
exports.Header = Header;
|
|
46
|
-
const Right = ({ rightElements }) => {
|
|
46
|
+
const Right = ({ hideRightElements, rightElements }) => {
|
|
47
|
+
if (hideRightElements) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
47
50
|
return ((0, jsx_runtime_1.jsxs)(Flex_1.Flex, { width: 50, alignItems: "flex-end", children: [(0, jsx_runtime_1.jsx)(Spacer_1.Spacer, { x: 1 }), rightElements] }));
|
|
48
51
|
};
|
|
49
|
-
const Center = ({ animated, titleProps, title }) => {
|
|
52
|
+
const Center = ({ animated, hideTitle, titleProps, title }) => {
|
|
50
53
|
const { scrollYOffset = 0, currentScrollY = 0 } = (0, ScreenScrollContext_1.useScreenScrollContext)();
|
|
54
|
+
if (hideTitle) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
51
57
|
if (!animated) {
|
|
52
|
-
return ((0, jsx_runtime_1.jsx)(Flex_1.Flex, { flex: 1, flexDirection: "row", children: (0, jsx_runtime_1.jsx)(Flex_1.Flex, { alignItems: "center", width: "100%", ...titleProps, children: (0, jsx_runtime_1.jsx)(Text_1.Text, { variant: "sm-display", numberOfLines: 1, children: title }) }) }));
|
|
58
|
+
return ((0, jsx_runtime_1.jsx)(Flex_1.Flex, { flex: 1, flexDirection: "row", width: "100%", children: (0, jsx_runtime_1.jsx)(Flex_1.Flex, { alignItems: "center", width: "100%", ...titleProps, children: (0, jsx_runtime_1.jsx)(Text_1.Text, { variant: "sm-display", numberOfLines: 1, children: title }) }) }));
|
|
53
59
|
}
|
|
54
60
|
// Show / hide the title to avoid rerenders, which retrigger the animation
|
|
55
61
|
const display = currentScrollY < constants_1.NAVBAR_HEIGHT + scrollYOffset ? "none" : "flex";
|
|
@@ -60,7 +66,10 @@ const Center = ({ animated, titleProps, title }) => {
|
|
|
60
66
|
opacity: display === "flex" ? 1 : 0,
|
|
61
67
|
}, children: (0, jsx_runtime_1.jsx)(Text_1.Text, { variant: "sm-display", numberOfLines: 1, children: title }) }) }) }) }));
|
|
62
68
|
};
|
|
63
|
-
const Left = ({ leftElements, onBack }) => {
|
|
69
|
+
const Left = ({ hideLeftElements, leftElements, onBack }) => {
|
|
70
|
+
if (hideLeftElements) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
64
73
|
return ((0, jsx_runtime_1.jsxs)(Flex_1.Flex, { pr: 1, width: 50, children: [leftElements ? ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: leftElements })) : (
|
|
65
74
|
// If no left elements passed, show back button
|
|
66
75
|
(0, jsx_runtime_1.jsx)(Touchable_1.Touchable, { onPress: onBack, underlayColor: "transparent", hitSlop: constants_2.DEFAULT_HIT_SLOP, children: (0, jsx_runtime_1.jsx)(ArrowLeftIcon_1.ArrowLeftIcon, { fill: "onBackgroundHigh", top: "2px" }) })), (0, jsx_runtime_1.jsx)(Spacer_1.Spacer, { x: 1 })] }));
|