@artsy/palette-mobile 13.1.5 → 13.1.7

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Palette Mobile
2
2
 
3
- # @artsy/palette-mobile [![npm version](https://badge.fury.io/js/%40artsy%2Fpalette-mobile.svg)](https://www.npmjs.com/package/@artsy/palette-mobile) [![Release](https://github.com/artsy/palette-mobile/actions/workflows/release.yml/badge.svg?branch=main)](https://github.com/artsy/palette-mobile/actions/workflows/release.yml)[![CircleCI](https://dl.circleci.com/status-badge/img/gh/artsy/palette-mobile/tree/main.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/artsy/palette-mobile/tree/main)
3
+ # @artsy/palette-mobile [![npm version](https://badge.fury.io/js/%40artsy%2Fpalette-mobile.svg)](https://www.npmjs.com/package/@artsy/palette-mobile) [![CircleCI](https://dl.circleci.com/status-badge/img/gh/artsy/palette-mobile/tree/main.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/artsy/palette-mobile/tree/main)
4
4
 
5
5
  Artsy's Design System on Mobile
6
6
 
@@ -7,7 +7,7 @@ const useHasSeenItem = ({ keyExtractor }) => {
7
7
  const [viewedItems, setViewedItems] = (0, react_1.useState)(new Set());
8
8
  const viewabilityConfig = (0, react_1.useRef)({
9
9
  // Percent of of the item that is visible for a partially occluded item to count as "viewable"
10
- itemVisiblePercentThreshold: 80,
10
+ itemVisiblePercentThreshold: 20,
11
11
  minimumViewTime: 300,
12
12
  waitForInteraction: false,
13
13
  }).current;
@@ -1,17 +1,39 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
3
26
  exports.StickySubHeader = void 0;
4
27
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- const moti_1 = require("moti");
6
28
  const react_1 = require("react");
7
- const react_native_reanimated_1 = require("react-native-reanimated");
29
+ const react_native_reanimated_1 = __importStar(require("react-native-reanimated"));
8
30
  const ScreenScrollContext_1 = require("./ScreenScrollContext");
9
31
  const constants_1 = require("./constants");
10
32
  const hooks_1 = require("../../utils/hooks");
11
33
  const Flex_1 = require("../Flex");
12
34
  const Separator_1 = require("../Separator");
13
35
  const Text_1 = require("../Text");
14
- const STICKY_BAR_HEIGHT = 52;
36
+ const STICKY_BAR_HEIGHT = 42;
15
37
  const StickySubHeader = ({ title, subTitle, children }) => {
16
38
  const { currentScrollY, scrollYOffset = 0 } = (0, ScreenScrollContext_1.useScreenScrollContext)();
17
39
  const space = (0, hooks_1.useSpace)();
@@ -20,23 +42,33 @@ const StickySubHeader = ({ title, subTitle, children }) => {
20
42
  if (stickyBarHeight === null) {
21
43
  return true;
22
44
  }
23
- return currentScrollY >= constants_1.NAVBAR_HEIGHT + scrollYOffset;
24
- });
45
+ return currentScrollY < constants_1.NAVBAR_HEIGHT + scrollYOffset;
46
+ }, [currentScrollY, scrollYOffset, stickyBarHeight]);
25
47
  const handleLayout = (event) => {
26
48
  setStickyHeaderHeight(event.nativeEvent.layout.height);
27
49
  };
28
50
  // The styles are kept in a variable to make sure they're always in sync with the hidden text component
29
- const styles = {
51
+ const sharedStyles = {
30
52
  paddingHorizontal: space(2),
31
53
  };
32
- return ((0, jsx_runtime_1.jsxs)(Flex_1.Flex, { children: [stickyBarHeight === null && ((0, jsx_runtime_1.jsx)(Flex_1.Flex, { onLayout: (event) => handleLayout(event), position: "absolute", backgroundColor: "white100", zIndex: -1000, style: styles, children: (0, jsx_runtime_1.jsxs)(Flex_1.Flex, { mb: 1, 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: {
33
- height: visible.value ? stickyBarHeight || undefined : 0,
34
- transform: [{ translateY: visible.value ? 0 : -(stickyBarHeight || STICKY_BAR_HEIGHT) }],
35
- }, style: styles, transition: {
36
- type: "timing",
37
- duration: 100,
38
- }, children: (0, jsx_runtime_1.jsx)(Flex_1.Flex, { style: { height: stickyBarHeight }, mb: 1, children: (0, jsx_runtime_1.jsxs)(moti_1.MotiView, { animate: {
39
- opacity: visible.value ? 1 : 0,
54
+ const animatedStyles = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
55
+ return {
56
+ height: (0, react_native_reanimated_1.withTiming)(visible.value ? stickyBarHeight || STICKY_BAR_HEIGHT : 0, {
57
+ duration: 100,
58
+ }),
59
+ transform: [
60
+ {
61
+ translateY: (0, react_native_reanimated_1.withTiming)(visible.value ? 0 : -(stickyBarHeight || STICKY_BAR_HEIGHT), {
62
+ duration: 100,
63
+ }),
64
+ },
65
+ ],
66
+ };
67
+ });
68
+ return ((0, jsx_runtime_1.jsxs)(Flex_1.Flex, { children: [stickyBarHeight === null && ((0, jsx_runtime_1.jsx)(Flex_1.Flex, { onLayout: (event) => handleLayout(event), position: "absolute", backgroundColor: "white100", zIndex: -1000, style: sharedStyles, children: (0, jsx_runtime_1.jsxs)(Flex_1.Flex, { mb: 1, 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)(react_native_reanimated_1.default.View, { style: [sharedStyles, animatedStyles], children: (0, jsx_runtime_1.jsx)(Flex_1.Flex, { style: { height: stickyBarHeight }, mb: 1, children: (0, jsx_runtime_1.jsxs)(react_native_reanimated_1.default.View, { style: {
69
+ opacity: (0, react_native_reanimated_1.withTiming)(visible.value ? 1 : 0, {
70
+ duration: 100,
71
+ }),
40
72
  }, 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" })] }));
41
73
  };
42
74
  exports.StickySubHeader = StickySubHeader;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@artsy/palette-mobile",
3
- "version": "13.1.5",
3
+ "version": "13.1.7",
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",