@artsy/palette-mobile 11.2.11 → 11.2.13

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/CHANGELOG.md CHANGED
@@ -1,3 +1,27 @@
1
+ # v11.2.13 (Tue Aug 01 2023)
2
+
3
+ #### 🐛 Bug Fix
4
+
5
+ - feat(Image): enable more styling on the Image element and more [#120](https://github.com/artsy/palette-mobile/pull/120) ([@araujobarret](https://github.com/araujobarret))
6
+
7
+ #### Authors: 1
8
+
9
+ - Carlos Alberto de Araujo Barreto ([@araujobarret](https://github.com/araujobarret))
10
+
11
+ ---
12
+
13
+ # v11.2.12 (Fri Jul 28 2023)
14
+
15
+ #### 🐛 Bug Fix
16
+
17
+ - build(REVERT): bumps palette to reanimated 3 [#131](https://github.com/artsy/palette-mobile/pull/131) ([@gkartalis](https://github.com/gkartalis))
18
+
19
+ #### Authors: 1
20
+
21
+ - George ([@gkartalis](https://github.com/gkartalis))
22
+
23
+ ---
24
+
1
25
  # v11.2.11 (Fri Jul 28 2023)
2
26
 
3
27
  #### 🐛 Bug Fix
@@ -80,6 +80,7 @@ const Button = ({ children, disabled: disabledProp, haptic, icon, iconPosition =
80
80
  };
81
81
  const colorsForVariantAndState = (0, colors_1.useColorsForVariantAndState)();
82
82
  const containerColorsAnim = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
83
+ "worklet";
83
84
  const colors = colorsForVariantAndState[variant];
84
85
  if (disabled) {
85
86
  return {
@@ -93,6 +94,7 @@ const Button = ({ children, disabled: disabledProp, haptic, icon, iconPosition =
93
94
  };
94
95
  });
95
96
  const textAnim = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
97
+ "worklet";
96
98
  const colors = colorsForVariantAndState[variant];
97
99
  if (loading) {
98
100
  return { color: "rgba(0, 0, 0, 0)" };
@@ -123,6 +125,7 @@ const useStateWithProp = (prop) => {
123
125
  setState(!!prop);
124
126
  }, [prop]);
125
127
  const stateV = (0, react_native_reanimated_1.useDerivedValue)(() => {
128
+ "worklet";
126
129
  if (!!state) {
127
130
  return 1;
128
131
  }
@@ -1,6 +1,7 @@
1
1
  /// <reference types="react" />
2
- import { FlexProps } from "../Flex";
3
- export interface ImageProps extends FlexProps {
2
+ import { FastImageProps } from "react-native-fast-image";
3
+ type CustomFastImageProps = Omit<FastImageProps, "onLoadStart" | "onLoadEnd" | "source">;
4
+ export interface ImageProps extends CustomFastImageProps {
4
5
  /** Supplied aspect ratio of image. If none provided, defaults to 1 */
5
6
  aspectRatio?: number;
6
7
  /** Supplied width of image. If none provided, defaults to screen width */
@@ -13,3 +14,4 @@ export interface ImageProps extends FlexProps {
13
14
  src: string;
14
15
  }
15
16
  export declare const Image: React.FC<ImageProps>;
17
+ export {};
@@ -11,12 +11,14 @@ const react_native_1 = require("react-native");
11
11
  const react_native_fast_image_1 = __importDefault(require("react-native-fast-image"));
12
12
  const react_native_reanimated_1 = require("react-native-reanimated");
13
13
  const createGeminiUrl_1 = require("../../utils/createGeminiUrl");
14
+ const hooks_1 = require("../../utils/hooks");
14
15
  const useScreenDimensions_1 = require("../../utils/hooks/useScreenDimensions");
15
16
  const Flex_1 = require("../Flex");
16
17
  const Skeleton_1 = require("../Skeleton");
17
- const Image = ({ aspectRatio, width, height, performResize = true, src, ...flexProps }) => {
18
+ const Image = ({ aspectRatio, width, height, performResize = true, src, style, resizeMode, ...flexProps }) => {
18
19
  const [loading, setLoading] = (0, react_1.useState)(true);
19
20
  const dimensions = useImageDimensions({ aspectRatio, width, height });
21
+ const color = (0, hooks_1.useColor)();
20
22
  let uri = src;
21
23
  if (performResize) {
22
24
  uri = (0, createGeminiUrl_1.createGeminiUrl)({
@@ -25,7 +27,7 @@ const Image = ({ aspectRatio, width, height, performResize = true, src, ...flexP
25
27
  height: react_native_1.PixelRatio.getPixelSizeForLayoutSize(dimensions.height),
26
28
  });
27
29
  }
28
- return ((0, jsx_runtime_1.jsxs)(Flex_1.Flex, { position: "relative", ...flexProps, children: [!!loading && ((0, jsx_runtime_1.jsx)(Flex_1.Flex, { position: "absolute", zIndex: 1, children: (0, jsx_runtime_1.jsx)(Skeleton_1.Skeleton, { children: (0, jsx_runtime_1.jsx)(Skeleton_1.SkeletonBox, { ...dimensions }) }) })), (0, jsx_runtime_1.jsx)(moti_1.MotiView, { animate: { opacity: loading ? 0 : 1 }, transition: { type: "timing", duration: 400, easing: react_native_reanimated_1.Easing.sin }, children: (0, jsx_runtime_1.jsx)(react_native_fast_image_1.default, { style: dimensions, onLoadStart: () => setLoading(true), onLoadEnd: () => setLoading(false), source: {
30
+ return ((0, jsx_runtime_1.jsxs)(Flex_1.Flex, { position: "relative", ...flexProps, children: [!!loading && ((0, jsx_runtime_1.jsx)(Flex_1.Flex, { position: "absolute", zIndex: 1, children: (0, jsx_runtime_1.jsx)(Skeleton_1.Skeleton, { children: (0, jsx_runtime_1.jsx)(Skeleton_1.SkeletonBox, { ...dimensions }) }) })), (0, jsx_runtime_1.jsx)(moti_1.MotiView, { animate: { opacity: loading ? 0 : 1 }, transition: { type: "timing", duration: 400, easing: react_native_reanimated_1.Easing.sin }, children: (0, jsx_runtime_1.jsx)(react_native_fast_image_1.default, { style: [dimensions, style, { backgroundColor: color("black30") }], resizeMode: resizeMode, onLoadStart: () => setLoading(true), onLoadEnd: () => setLoading(false), source: {
29
31
  priority: react_native_fast_image_1.default.priority.normal,
30
32
  uri,
31
33
  } }) })] }));
@@ -40,7 +42,7 @@ const useImageDimensions = (props) => {
40
42
  }
41
43
  else {
42
44
  if (!props.aspectRatio) {
43
- console.error("[CachedImage] Error: `aspectRatio` is required if `height` is not provided.");
45
+ console.error("[Image] Error: `aspectRatio` is required if `height` is not provided.");
44
46
  }
45
47
  const aspectRatio = props.aspectRatio ?? 1;
46
48
  imageHeight = imageWidth / aspectRatio;
@@ -3,8 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const jsx_runtime_1 = require("react/jsx-runtime");
4
4
  const react_native_1 = require("@storybook/react-native");
5
5
  const Image_1 = require("./Image");
6
+ const Flex_1 = require("../Flex");
6
7
  (0, react_native_1.storiesOf)("Image", module)
7
8
  .add("With default fallback screen width", () => ((0, jsx_runtime_1.jsx)(Image_1.Image, { aspectRatio: 0.62, src: "https://d32dm0rphc51dk.cloudfront.net/A983VUIZusVBKy420xP3ow/normalized.jpg" })))
8
9
  .add("With width and height", () => ((0, jsx_runtime_1.jsx)(Image_1.Image, { width: 250, height: 400, src: "https://d32dm0rphc51dk.cloudfront.net/A983VUIZusVBKy420xP3ow/normalized.jpg" })))
9
10
  .add("With aspect ratio", () => ((0, jsx_runtime_1.jsx)(Image_1.Image, { width: 250, aspectRatio: 0.62, src: "https://d32dm0rphc51dk.cloudfront.net/A983VUIZusVBKy420xP3ow/normalized.jpg" })))
10
- .add("Without automatic resizing", () => ((0, jsx_runtime_1.jsx)(Image_1.Image, { aspectRatio: 0.62, performResize: false, src: "https://d32dm0rphc51dk.cloudfront.net/A983VUIZusVBKy420xP3ow/normalized.jpg" })));
11
+ .add("Without automatic resizing", () => ((0, jsx_runtime_1.jsx)(Image_1.Image, { aspectRatio: 0.62, performResize: false, src: "https://d32dm0rphc51dk.cloudfront.net/A983VUIZusVBKy420xP3ow/normalized.jpg" })))
12
+ .add("With percentage width and height", () => {
13
+ return ((0, jsx_runtime_1.jsxs)(Flex_1.Flex, { flexDirection: "row", flex: 1, children: [(0, jsx_runtime_1.jsx)(Flex_1.Flex, { flex: 1, style: { aspectRatio: 0.69 }, children: (0, jsx_runtime_1.jsx)(Image_1.Image, { src: "https://d32dm0rphc51dk.cloudfront.net/A983VUIZusVBKy420xP3ow/normalized.jpg", height: 260, width: 180, style: { width: "100%", height: "100%" } }) }), (0, jsx_runtime_1.jsx)(Flex_1.Flex, { flex: 1, style: { aspectRatio: 1 }, children: (0, jsx_runtime_1.jsx)(Image_1.Image, { src: "https://i.imgur.com/b9IZinu.gif", width: 200, height: 200, style: { width: "100%", height: "100%" } }) }), (0, jsx_runtime_1.jsx)(Flex_1.Flex, { flex: 1, style: { aspectRatio: 1.2 }, children: (0, jsx_runtime_1.jsx)(Image_1.Image, { width: 200, height: 240, src: "https://i.imgur.com/non-existing-image.gif", style: { width: "100%", height: "100%" } }) })] }));
14
+ });
@@ -41,6 +41,7 @@ const Pill = ({ variant = "default", src, selected, disabled, Icon, children, on
41
41
  const stateString = selected ? "selected" : disabled ? "disabled" : "default";
42
42
  const color = TEXT_COLOR[variant][stateString];
43
43
  return ((0, jsx_runtime_1.jsx)(Flex_1.Flex, { ...rest, children: (0, jsx_runtime_1.jsxs)(Container, { variant: variant, selected: selected, disabled: disabled, onPress: onPress, animate: (0, react_1.useMemo)(() => ({ hovered, pressed }) => {
44
+ "worklet";
44
45
  return {
45
46
  opacity: hovered || pressed ? 0.5 : 1,
46
47
  };
@@ -35,6 +35,7 @@ const ProgressBar = ({ animationDuration = 200, backgroundColor = "black30", hei
35
35
  const width = (0, react_native_reanimated_1.useSharedValue)("0%");
36
36
  const progress = clamp(unclampedProgress, 0, 100);
37
37
  const progressAnim = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
38
+ "worklet";
38
39
  return { width: width.value };
39
40
  });
40
41
  const [onCompletionCalled, setOnCompletionCalled] = (0, react_1.useState)(false);
@@ -20,8 +20,10 @@ const useAnimatedHeaderScrolling = (scrollY) => {
20
20
  };
21
21
  }, [listenForScroll]);
22
22
  (0, react_native_reanimated_1.useAnimatedReaction)(() => {
23
+ "worklet";
23
24
  return [scrollY.value, listenForScroll.value];
24
25
  }, ([animatedScrollY, isListeningForScroll], previousScroll) => {
26
+ "worklet";
25
27
  const [prevScrollY] = previousScroll ?? [0, false];
26
28
  // Hacky way to avoid some weird header behavior.
27
29
  // look at HACKS.md for more info.
@@ -11,6 +11,7 @@ const useListenForScreenScroll = () => {
11
11
  const scrollY = (0, useAnimatedHeaderScrolling_1.useAnimatedHeaderScrolling)(animatedScrollY);
12
12
  const scrollHandler = (0, react_native_reanimated_1.useAnimatedScrollHandler)({
13
13
  onScroll: (event) => {
14
+ "worklet";
14
15
  animatedScrollY.value = event.contentOffset.y;
15
16
  },
16
17
  });
@@ -43,6 +43,7 @@ const Skeleton = ({ children }) => {
43
43
  const opacity = (0, react_native_reanimated_1.useSharedValue)(0.5);
44
44
  opacity.value = (0, react_native_reanimated_1.withRepeat)((0, react_native_reanimated_1.withTiming)(1, { duration: 1000, easing: react_native_reanimated_1.Easing.ease }), -1, true);
45
45
  const fadeLoopAnim = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
46
+ "worklet";
46
47
  return { opacity: opacity.value };
47
48
  }, []);
48
49
  return (0, jsx_runtime_1.jsx)(react_native_reanimated_1.default.View, { style: fadeLoopAnim, children: children });
@@ -17,6 +17,7 @@ const SubTabBar = ({ children }) => {
17
17
  const scrollY = (0, react_native_collapsible_tab_view_1.useCurrentTabScrollY)();
18
18
  const space = (0, useSpace_1.useSpace)();
19
19
  const style = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
20
+ "worklet";
20
21
  return {
21
22
  transform: [
22
23
  {
@@ -35,6 +35,7 @@ const ToolTipFlyout = ({ containerStyle, tapToDismiss, height, width, onClose, o
35
35
  const initialBoxDimensions = { height: 0, width: 0 };
36
36
  const boxDimensions = (0, react_native_reanimated_1.useSharedValue)(initialBoxDimensions);
37
37
  const animationStyle = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
38
+ "worklet";
38
39
  return {
39
40
  height: (0, react_native_reanimated_1.withTiming)(boxDimensions.value.height, {
40
41
  duration: 500,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@artsy/palette-mobile",
3
- "version": "11.2.11",
3
+ "version": "11.2.13",
4
4
  "description": "Artsy's design system for React Native",
5
5
  "scripts": {
6
6
  "android": "react-native run-android",
@@ -116,7 +116,7 @@
116
116
  "react-native-flipper": "0.178.1",
117
117
  "react-native-haptic-feedback": "1.14.0",
118
118
  "react-native-linear-gradient": "2.6.2",
119
- "react-native-reanimated": "^3.3.0",
119
+ "react-native-reanimated": "2.14.4",
120
120
  "react-native-safe-area-context": "4.5.0",
121
121
  "react-native-svg": "13.7.0",
122
122
  "react-test-renderer": "18.2.0",