@artsy/palette-mobile 13.0.30 → 13.0.32
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.
|
@@ -3,22 +3,33 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.StickySubHeader = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const moti_1 = require("moti");
|
|
6
|
+
const react_1 = require("react");
|
|
6
7
|
const ScreenScrollContext_1 = require("./ScreenScrollContext");
|
|
7
8
|
const constants_1 = require("./constants");
|
|
9
|
+
const hooks_1 = require("../../utils/hooks");
|
|
8
10
|
const Flex_1 = require("../Flex");
|
|
9
11
|
const Separator_1 = require("../Separator");
|
|
10
12
|
const Text_1 = require("../Text");
|
|
11
|
-
const STICKY_BAR_HEIGHT =
|
|
12
|
-
const StickySubHeader = ({ title, children }) => {
|
|
13
|
+
const STICKY_BAR_HEIGHT = 52;
|
|
14
|
+
const StickySubHeader = ({ title, subTitle, children }) => {
|
|
13
15
|
const { currentScrollY, scrollYOffset = 0 } = (0, ScreenScrollContext_1.useScreenScrollContext)();
|
|
16
|
+
const space = (0, hooks_1.useSpace)();
|
|
17
|
+
const [stickyBarHeight, setStickyHeaderHeight] = (0, react_1.useState)(null);
|
|
14
18
|
const visible = currentScrollY >= constants_1.NAVBAR_HEIGHT + scrollYOffset ? false : true;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
const handleLayout = (event) => {
|
|
20
|
+
setStickyHeaderHeight(event.nativeEvent.layout.height);
|
|
21
|
+
};
|
|
22
|
+
// The styles are kept in a variable to make sure they're always in sync with the hidden text component
|
|
23
|
+
const styles = {
|
|
24
|
+
paddingVertical: space(1),
|
|
25
|
+
paddingHorizontal: space(2),
|
|
26
|
+
};
|
|
27
|
+
return ((0, jsx_runtime_1.jsxs)(Flex_1.Flex, { children: [stickyBarHeight === null && ((0, jsx_runtime_1.jsxs)(Flex_1.Flex, { onLayout: (event) => handleLayout(event), position: "absolute", backgroundColor: "white100", zIndex: -1000, style: styles, children: [(0, jsx_runtime_1.jsx)(Text_1.Text, { variant: "lg-display", color: "white100", children: title }), !!subTitle && ((0, jsx_runtime_1.jsx)(Text_1.Text, { variant: "xs", mt: 0.5, color: "white100", children: subTitle }))] })), (0, jsx_runtime_1.jsx)(moti_1.MotiView, { animate: {
|
|
28
|
+
height: visible ? stickyBarHeight || undefined : 0,
|
|
29
|
+
transform: [{ translateY: visible ? 0 : -(stickyBarHeight || STICKY_BAR_HEIGHT) }],
|
|
30
|
+
}, style: styles, transition: {
|
|
20
31
|
type: "timing",
|
|
21
|
-
duration:
|
|
22
|
-
}, children: (0, jsx_runtime_1.jsx)(Text_1.Text, { variant: "lg-display",
|
|
32
|
+
duration: 100,
|
|
33
|
+
}, children: (0, jsx_runtime_1.jsxs)(Flex_1.Flex, { style: { height: stickyBarHeight }, children: [(0, jsx_runtime_1.jsx)(Text_1.Text, { variant: "lg-display", children: title }), subTitle && ((0, jsx_runtime_1.jsx)(Text_1.Text, { variant: "xs", mt: 0.5, children: subTitle }))] }) }), children, (0, jsx_runtime_1.jsx)(Separator_1.Separator, { borderColor: "black10" })] }));
|
|
23
34
|
};
|
|
24
35
|
exports.StickySubHeader = StickySubHeader;
|
|
@@ -18,5 +18,8 @@ export declare const Screen: import("react").FC<import("./ScreenBase").ScreenBas
|
|
|
18
18
|
}>;
|
|
19
19
|
ScrollView: import("react").FC<import("react-native").ScrollViewProps>;
|
|
20
20
|
StickySubHeader: import("react").FC<import("./StickySubHeader").StickySubHeaderProps>;
|
|
21
|
+
useListenForScreenScroll: () => {
|
|
22
|
+
scrollHandler: (event: import("react-native").NativeSyntheticEvent<import("react-native").NativeScrollEvent>) => void;
|
|
23
|
+
};
|
|
21
24
|
useScreenScrollContext: () => import("./ScreenScrollContext").ScreenScrollContextProps;
|
|
22
25
|
};
|
|
@@ -27,6 +27,7 @@ const ScreenFlatList_1 = require("./ScreenFlatList");
|
|
|
27
27
|
const ScreenScrollContext_1 = require("./ScreenScrollContext");
|
|
28
28
|
const ScreenScrollView_1 = require("./ScreenScrollView");
|
|
29
29
|
const StickySubHeader_1 = require("./StickySubHeader");
|
|
30
|
+
const useListenForScreenScroll_1 = require("./hooks/useListenForScreenScroll");
|
|
30
31
|
__exportStar(require("./constants"), exports);
|
|
31
32
|
exports.Screen = Object.assign(ScreenBase_1.ScreenBase, {
|
|
32
33
|
AnimatedHeader: Header_1.AnimatedHeader,
|
|
@@ -42,5 +43,6 @@ exports.Screen = Object.assign(ScreenBase_1.ScreenBase, {
|
|
|
42
43
|
ScrollView: ScreenScrollView_1.ScreenScrollView,
|
|
43
44
|
StickySubHeader: StickySubHeader_1.StickySubHeader,
|
|
44
45
|
// Hooks
|
|
46
|
+
useListenForScreenScroll: useListenForScreenScroll_1.useListenForScreenScroll,
|
|
45
47
|
useScreenScrollContext: ScreenScrollContext_1.useScreenScrollContext,
|
|
46
48
|
});
|