@artsy/palette-mobile 20.1.0 → 20.3.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/README.md CHANGED
@@ -36,7 +36,7 @@ yarn add @artsy/palette-mobile
36
36
  - Install native peer deps
37
37
 
38
38
  ```sh
39
- yarn add react-native-haptic-feedback react-native-linear-gradient react-native-reanimated react-native-svg
39
+ yarn add react-native-haptic-feedback react-native-linear-gradient react-native-reanimated react-native-svg react-native-safe-area-context
40
40
  ```
41
41
 
42
42
  ## How to contribute
@@ -75,14 +75,6 @@ or
75
75
  yarn android
76
76
  ```
77
77
 
78
- ⚠️ Temporary workaround until we move Expo into an example directory:
79
-
80
- For local development, remove the line from package.json:
81
-
82
- `"main": "dist/index.js"`
83
-
84
- Make sure to add it back before committing.
85
-
86
78
  ## Developing Features using Local Versions of Palette
87
79
 
88
80
  When developing new components in Palette, it's often useful to test those components in consuming apps (such as Eigen). However, due to the poor support for symlinks in React Native, this can be difficult. Enter [yalc](https://github.com/wclr/yalc). Yalc is a mini package manager that one can publish to and install from, which makes it easy to test code in realtime from outside of your app.
@@ -13,3 +13,5 @@ export declare const DEFAULT_ICON_SIZE: number;
13
13
  */
14
14
  export declare let DEFAULT_ACTIVE_OPACITY: number;
15
15
  export declare const setGlobalActiveOpacity: (opacity: number) => void;
16
+ export declare const isNewArchitectureEnabled: boolean;
17
+ export declare const DEFAULT_ANIMATION_DURATION = 200;
package/dist/constants.js CHANGED
@@ -12,3 +12,8 @@ export let DEFAULT_ACTIVE_OPACITY = 0.8;
12
12
  export const setGlobalActiveOpacity = (opacity) => {
13
13
  DEFAULT_ACTIVE_OPACITY = opacity;
14
14
  };
15
+ // Check if the global `nativeFabric` object exists.
16
+ // Its presence indicates that Fabric is running.
17
+ // nativeFabricUIManager is only available in the new architecture and isn't typed yet
18
+ export const isNewArchitectureEnabled = !!global?.nativeFabricUIManager;
19
+ export const DEFAULT_ANIMATION_DURATION = 200;
@@ -1,24 +1,32 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import FastImage from "@d11/react-native-fast-image";
3
3
  import { memo, useState } from "react";
4
- import { View } from "react-native";
4
+ import { Animated, useAnimatedValue } from "react-native";
5
5
  import { Blurhash } from "react-native-blurhash";
6
6
  import { getImageURL } from "./helpers/getImageURL";
7
+ import { DEFAULT_ANIMATION_DURATION, isNewArchitectureEnabled } from "../../constants";
7
8
  import { useColor } from "../../utils/hooks";
8
9
  import { useScreenDimensions } from "../../utils/hooks/useScreenDimensions";
9
10
  import { Flex } from "../Flex";
10
11
  import { Skeleton, SkeletonBox } from "../Skeleton";
11
12
  export const Image = memo(({ aspectRatio, width, height, performResize = true, src, style, resizeMode, geminiResizeMode, showLoadingState = false, blurhash, ...flexProps }) => {
12
- const [isLoading, setIsLoading] = useState(false);
13
+ const [isLoading, setIsLoading] = useState(true);
13
14
  const dimensions = useImageDimensions({ aspectRatio, width, height });
15
+ const opacity = useAnimatedValue(1);
14
16
  const color = useColor();
15
17
  const onLoadEnd = () => {
16
- setIsLoading(false);
18
+ Animated.timing(opacity, {
19
+ toValue: 0,
20
+ duration: DEFAULT_ANIMATION_DURATION,
21
+ useNativeDriver: true,
22
+ }).start(() => {
23
+ setIsLoading(false);
24
+ });
17
25
  };
18
26
  if (showLoadingState) {
19
27
  return (_jsx(ImageSkeleton, { dimensions: dimensions, blurhash: blurhash, style: { position: "absolute" } }));
20
28
  }
21
- return (_jsxs(Flex, { position: "relative", ...flexProps, style: { ...dimensions }, children: [isLoading && (_jsx(View, { style: [dimensions, { position: "absolute" }], children: _jsx(ImageSkeleton, { dimensions: dimensions, blurhash: blurhash, style: { position: "absolute" } }) })), _jsx(FastImage, { style: [
29
+ return (_jsxs(Flex, { position: "relative", ...flexProps, style: { ...dimensions }, children: [_jsx(FastImage, { style: [
22
30
  dimensions,
23
31
  style,
24
32
  // If we have a blurhash, we don't want to show a background color
@@ -27,7 +35,12 @@ export const Image = memo(({ aspectRatio, width, height, performResize = true, s
27
35
  ], resizeMode: resizeMode, onLoadEnd: onLoadEnd, source: {
28
36
  priority: FastImage.priority.normal,
29
37
  uri: getImageURL({ src, dimensions, geminiResizeMode, performResize }),
30
- } })] }));
38
+ } }), isLoading && (_jsx(Animated.View, { style: [
39
+ dimensions,
40
+ // We are disabling the opacity animation in the new architecture because it is still slow
41
+ // We will bring this back once we are on RN81+ aka a version with this fix
42
+ { position: "absolute", opacity: isNewArchitectureEnabled ? 0 : opacity },
43
+ ], children: _jsx(ImageSkeleton, { dimensions: dimensions, blurhash: blurhash, style: { position: "absolute" } }) }))] }));
31
44
  });
32
45
  const useImageDimensions = (props) => {
33
46
  const screenDimensions = useScreenDimensions();
@@ -51,7 +64,7 @@ const useImageDimensions = (props) => {
51
64
  };
52
65
  export const ImageSkeleton = ({ dimensions, blurhash, style }) => {
53
66
  if (!!blurhash) {
54
- return (_jsx(Flex, { backgroundColor: "mono10", ...dimensions, style: style, children: _jsx(Blurhash, { blurhash: blurhash, style: { flex: 1 }, decodeWidth: 16, decodeHeight: 16, decodeAsync: true }) }));
67
+ return (_jsx(Flex, { ...dimensions, style: style, children: _jsx(Blurhash, { blurhash: blurhash, style: { flex: 1 }, decodeWidth: 16, decodeHeight: 16, decodeAsync: true }) }));
55
68
  }
56
69
  return (_jsx(Flex, { style: style, children: _jsx(Skeleton, { children: _jsx(SkeletonBox, { ...dimensions }) }) }));
57
70
  };
@@ -1,14 +1,12 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import AsyncStorage from "@react-native-async-storage/async-storage";
3
3
  import { useEffect, useState } from "react";
4
- import { Appearance } from "react-native";
4
+ import { Appearance, Platform, StatusBar } from "react-native";
5
5
  import { SafeAreaProvider } from "react-native-safe-area-context";
6
6
  import { Theme } from "../Theme";
7
- import { Flex } from "../elements/Flex";
8
- import { Pill } from "../elements/Pill";
9
- import { Text } from "../elements/Text";
7
+ import { Flex, Pill, Text } from "../elements";
10
8
  import { ScreenDimensionsProvider } from "../utils/hooks";
11
- export const withTheme = (story) => (_jsxs(Theme, { theme: "v3light", children: [_jsx(Text, { color: "red", children: "aaww" }), story()] }));
9
+ export const withTheme = (story) => _jsx(Theme, { theme: "v3light", children: story() });
12
10
  const DARK_MODE_STORAGE_KEY = "dark-mode-mode";
13
11
  export const useDarkModeSwitcher = (story) => {
14
12
  const [mode, setModeState] = useState("system");
@@ -39,5 +37,9 @@ export const useDarkModeSwitcher = (story) => {
39
37
  };
40
38
  const isDarkMode = mode === "dark" || (mode === "system" && systemMode === "dark");
41
39
  const theme = isDarkMode ? "v3dark" : "v3light";
42
- return (_jsx(ScreenDimensionsProvider, { children: _jsx(SafeAreaProvider, { children: _jsx(Theme, { theme: theme, children: _jsxs(Flex, { flex: 1, backgroundColor: "background", children: [_jsxs(Flex, { flexDirection: "row", justifyContent: "space-around", py: 1, backgroundColor: "mono5", children: [_jsx(Text, { color: "mono100", children: "Dark mode" }), _jsxs(Flex, { flexDirection: "row", gap: 1, children: [_jsx(Pill, { variant: "default", selected: mode === "light", onPress: () => setMode("light"), children: "Light" }), _jsx(Pill, { variant: "default", selected: mode === "dark", onPress: () => setMode("dark"), children: "Dark" }), _jsx(Pill, { variant: "default", selected: mode === "system", onPress: () => setMode("system"), children: "System" })] })] }), _jsx(Flex, { p: 2, children: story() })] }) }) }) }));
40
+ return (_jsx(ScreenDimensionsProvider, { children: _jsx(SafeAreaProvider, { children: _jsxs(Theme, { theme: theme, children: [_jsx(StatusBar
41
+ // We are keeping the status bar white on darkmode on ios because background isn't a supported prop on iOS
42
+ , {
43
+ // We are keeping the status bar white on darkmode on ios because background isn't a supported prop on iOS
44
+ barStyle: isDarkMode && Platform.OS === "android" ? "light-content" : "dark-content", backgroundColor: isDarkMode && Platform.OS === "android" ? "black" : "white", translucent: true }), _jsxs(Flex, { flex: 1, backgroundColor: "background", children: [_jsxs(Flex, { flexDirection: "row", justifyContent: "space-around", py: 1, backgroundColor: "mono5", children: [_jsx(Text, { color: "mono100", children: "Dark mode" }), _jsxs(Flex, { flexDirection: "row", gap: 1, children: [_jsx(Pill, { variant: "default", selected: mode === "light", onPress: () => setMode("light"), children: "Light" }), _jsx(Pill, { variant: "default", selected: mode === "dark", onPress: () => setMode("dark"), children: "Dark" }), _jsx(Pill, { variant: "default", selected: mode === "system", onPress: () => setMode("system"), children: "System" })] })] }), _jsx(Flex, { p: 2, children: story() })] })] }) }) }));
43
45
  };
@@ -1,8 +1,8 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useSpace } from "./hooks";
3
3
  import { bullet } from "./text";
4
- import { Box, Text } from "../elements";
5
4
  import { List } from "../storybook/helpers";
5
+ import { Box, Text } from "../elements";
6
6
  const SpaceLine = ({ space: theSpace }) => {
7
7
  const space = useSpace();
8
8
  return (_jsxs(Box, { children: [_jsx(Box, { width: space(theSpace), borderBottomWidth: 1, borderColor: "black", marginBottom: "4px" }), _jsx(Text, { color: "black", children: `${theSpace} ${bullet} ${space(theSpace)}px` })] }));
package/package.json CHANGED
@@ -1,31 +1,36 @@
1
1
  {
2
2
  "name": "@artsy/palette-mobile",
3
- "version": "20.1.0",
3
+ "version": "20.3.0",
4
4
  "description": "Artsy's design system for React Native",
5
+ "workspaces": [
6
+ "Example"
7
+ ],
5
8
  "scripts": {
6
- "android": "expo run:android --port 8082",
9
+ "android": "yarn workspace palette-mobile-example android",
10
+ "android:prebuild": "yarn workspace palette-mobile-example android:prebuild",
7
11
  "beta:ios": "bundle e fastlane ios beta",
8
12
  "bundle-install": "bundle install",
9
13
  "clean": "rimraf dist",
10
14
  "compile": "tsc",
11
15
  "install:all": "yarn install && yarn postinstall && yarn bundle-install",
12
- "ios": "expo run:ios --port 8082",
16
+ "ios": "yarn workspace palette-mobile-example ios",
17
+ "ios:prebuild": "yarn workspace palette-mobile-example ios:prebuild",
13
18
  "lint:all": "yarn lint .",
14
19
  "lint": "eslint --cache --cache-location '.cache/eslint/' --ext .ts,.tsx --fix",
15
20
  "local-palette-dev": "./scripts/sync-after-change",
16
- "open-xcode": "open ios/PaletteMobile.xcworkspace",
21
+ "open-xcode": "open Example/ios/PaletteMobile.xcworkspace",
17
22
  "postinstall": "yarn patch-package",
18
- "prebuild": "npx expo prebuild",
23
+ "prebuild": "yarn workspace palette-mobile-example prebuild",
19
24
  "prepare": "patch-package && husky install",
20
25
  "prepublishOnly": "yarn clean && yarn compile",
21
- "prestart": "sb-rn-get-stories",
26
+ "prestart": "yarn workspace palette-mobile-example prestart",
22
27
  "prettier-write": "prettier --write --ignore-unknown",
23
28
  "release:canary": "auto canary",
24
29
  "release": "auto shipit",
25
30
  "setup:artsy": "./scripts/download-fonts",
26
- "start:reset-cache": "npx expo start -c --port 8082",
27
- "start": "npx expo start --port 8082",
28
- "storybook-watcher": "sb-rn-watcher",
31
+ "start:reset-cache": "yarn workspace palette-mobile-example start:reset-cache",
32
+ "start": "yarn workspace palette-mobile-example start",
33
+ "storybook-watcher": "yarn workspace palette-mobile-example storybook-watcher",
29
34
  "test": "jest --maxWorkers=2",
30
35
  "type-check": "tsc --noEmit"
31
36
  },
@@ -76,14 +81,7 @@
76
81
  "@babel/preset-react": "7.18.6",
77
82
  "@babel/preset-typescript": "7.18.6",
78
83
  "@babel/runtime": "^7.25.0",
79
- "@gorhom/bottom-sheet": "^4.6.4",
80
- "@react-native-async-storage/async-storage": "2.2.0",
81
- "@react-native-community/datetimepicker": "8.0.1",
82
- "@react-native-community/slider": "4.5.2",
83
84
  "@react-native/eslint-config": "0.76.9",
84
- "@storybook/addon-ondevice-actions": "^8.3.5",
85
- "@storybook/addon-ondevice-controls": "^8.3.5",
86
- "@storybook/react-native": "^8.6.2",
87
85
  "@testing-library/react-native": "13.2.0",
88
86
  "@types/events": "^3.0.0",
89
87
  "@types/jest": "29.4.0",
@@ -108,8 +106,6 @@
108
106
  "eslint-plugin-react-native-a11y": "^3.5.1",
109
107
  "eslint-plugin-storybook": "0.6.10",
110
108
  "eslint-plugin-testing-library": "6.4.0",
111
- "expo": "^53.0.0",
112
- "expo-dev-client": "~5.2.4",
113
109
  "husky": "^8.0.3",
114
110
  "jest": "~29.7.0",
115
111
  "jest-environment-jsdom": "29.4.2",
@@ -122,10 +118,7 @@
122
118
  "prettier": "^2.8.8",
123
119
  "pull-lock": "1.0.0",
124
120
  "react": "19.0.0",
125
- "react-dom": "19.0.0",
126
121
  "react-native": "0.79.6",
127
- "react-native-device-info": "14.0.4",
128
- "react-native-gesture-handler": "~2.22.1",
129
122
  "react-native-haptic-feedback": "1.14.0",
130
123
  "react-native-linear-gradient": "2.6.2",
131
124
  "react-native-reanimated": "3.17.5",
@@ -157,7 +150,7 @@
157
150
  "author": "Pavlos Vinieratos <pvinis@gmail.com>",
158
151
  "license": "MIT",
159
152
  "pull-lock": {
160
- "ios/Podfile.lock": "echo \"🚨 New Podfile.lock detected!, you might need to run yarn install:all\" 🚨",
153
+ "Example/ios/Podfile.lock": "echo \"🚨 New Podfile.lock detected!, you might need to run yarn install:all\" 🚨",
161
154
  "yarn.lock": "yarn install"
162
155
  },
163
156
  "lint-staged": {