@artsy/palette-mobile 20.1.0--canary.404.4785.0 → 20.2.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 +9 -1
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +5 -0
- package/dist/elements/Image/Image.js +18 -9
- package/dist/storybook/decorators.js +6 -8
- package/dist/utils/space.stories.js +1 -1
- package/package.json +22 -15
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
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
## How to contribute
|
|
@@ -75,6 +75,14 @@ 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
|
+
|
|
78
86
|
## Developing Features using Local Versions of Palette
|
|
79
87
|
|
|
80
88
|
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.
|
package/dist/constants.d.ts
CHANGED
|
@@ -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,28 +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
|
-
import { memo,
|
|
4
|
-
import {
|
|
3
|
+
import { memo, useState } from "react";
|
|
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 }) => {
|
|
13
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
12
14
|
const dimensions = useImageDimensions({ aspectRatio, width, height });
|
|
15
|
+
const opacity = useAnimatedValue(1);
|
|
13
16
|
const color = useColor();
|
|
14
|
-
const opacity = useRef(new Animated.Value(0)).current;
|
|
15
17
|
const onLoadEnd = () => {
|
|
16
18
|
Animated.timing(opacity, {
|
|
17
|
-
toValue:
|
|
18
|
-
duration:
|
|
19
|
+
toValue: 0,
|
|
20
|
+
duration: DEFAULT_ANIMATION_DURATION,
|
|
19
21
|
useNativeDriver: true,
|
|
20
|
-
}).start()
|
|
22
|
+
}).start(() => {
|
|
23
|
+
setIsLoading(false);
|
|
24
|
+
});
|
|
21
25
|
};
|
|
22
26
|
if (showLoadingState) {
|
|
23
27
|
return (_jsx(ImageSkeleton, { dimensions: dimensions, blurhash: blurhash, style: { position: "absolute" } }));
|
|
24
28
|
}
|
|
25
|
-
return (_jsxs(Flex, { position: "relative", ...flexProps, style: { ...dimensions }, children: [_jsx(
|
|
29
|
+
return (_jsxs(Flex, { position: "relative", ...flexProps, style: { ...dimensions }, children: [_jsx(FastImage, { style: [
|
|
26
30
|
dimensions,
|
|
27
31
|
style,
|
|
28
32
|
// If we have a blurhash, we don't want to show a background color
|
|
@@ -31,7 +35,12 @@ export const Image = memo(({ aspectRatio, width, height, performResize = true, s
|
|
|
31
35
|
], resizeMode: resizeMode, onLoadEnd: onLoadEnd, source: {
|
|
32
36
|
priority: FastImage.priority.normal,
|
|
33
37
|
uri: getImageURL({ src, dimensions, geminiResizeMode, performResize }),
|
|
34
|
-
} })
|
|
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" } }) }))] }));
|
|
35
44
|
});
|
|
36
45
|
const useImageDimensions = (props) => {
|
|
37
46
|
const screenDimensions = useScreenDimensions();
|
|
@@ -55,7 +64,7 @@ const useImageDimensions = (props) => {
|
|
|
55
64
|
};
|
|
56
65
|
export const ImageSkeleton = ({ dimensions, blurhash, style }) => {
|
|
57
66
|
if (!!blurhash) {
|
|
58
|
-
return (_jsx(Flex, {
|
|
67
|
+
return (_jsx(Flex, { ...dimensions, style: style, children: _jsx(Blurhash, { blurhash: blurhash, style: { flex: 1 }, decodeWidth: 16, decodeHeight: 16, decodeAsync: true }) }));
|
|
59
68
|
}
|
|
60
69
|
return (_jsx(Flex, { style: style, children: _jsx(Skeleton, { children: _jsx(SkeletonBox, { ...dimensions }) }) }));
|
|
61
70
|
};
|
|
@@ -1,12 +1,14 @@
|
|
|
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
|
|
4
|
+
import { Appearance } from "react-native";
|
|
5
5
|
import { SafeAreaProvider } from "react-native-safe-area-context";
|
|
6
6
|
import { Theme } from "../Theme";
|
|
7
|
-
import { Flex
|
|
7
|
+
import { Flex } from "../elements/Flex";
|
|
8
|
+
import { Pill } from "../elements/Pill";
|
|
9
|
+
import { Text } from "../elements/Text";
|
|
8
10
|
import { ScreenDimensionsProvider } from "../utils/hooks";
|
|
9
|
-
export const withTheme = (story) =>
|
|
11
|
+
export const withTheme = (story) => (_jsxs(Theme, { theme: "v3light", children: [_jsx(Text, { color: "red", children: "aaww" }), story()] }));
|
|
10
12
|
const DARK_MODE_STORAGE_KEY = "dark-mode-mode";
|
|
11
13
|
export const useDarkModeSwitcher = (story) => {
|
|
12
14
|
const [mode, setModeState] = useState("system");
|
|
@@ -37,9 +39,5 @@ export const useDarkModeSwitcher = (story) => {
|
|
|
37
39
|
};
|
|
38
40
|
const isDarkMode = mode === "dark" || (mode === "system" && systemMode === "dark");
|
|
39
41
|
const theme = isDarkMode ? "v3dark" : "v3light";
|
|
40
|
-
return (_jsx(ScreenDimensionsProvider, { children: _jsx(SafeAreaProvider, { children:
|
|
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() })] })] }) }) }));
|
|
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() })] }) }) }) }));
|
|
45
43
|
};
|
|
@@ -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 { List } from "../storybook/helpers";
|
|
5
4
|
import { Box, Text } from "../elements";
|
|
5
|
+
import { List } from "../storybook/helpers";
|
|
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,36 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@artsy/palette-mobile",
|
|
3
|
-
"version": "20.
|
|
3
|
+
"version": "20.2.0",
|
|
4
4
|
"description": "Artsy's design system for React Native",
|
|
5
|
-
"workspaces": [
|
|
6
|
-
"Example"
|
|
7
|
-
],
|
|
8
5
|
"scripts": {
|
|
9
|
-
"android": "
|
|
10
|
-
"android:prebuild": "yarn workspace palette-mobile-example android:prebuild",
|
|
6
|
+
"android": "expo run:android --port 8082",
|
|
11
7
|
"beta:ios": "bundle e fastlane ios beta",
|
|
12
8
|
"bundle-install": "bundle install",
|
|
13
9
|
"clean": "rimraf dist",
|
|
14
10
|
"compile": "tsc",
|
|
15
11
|
"install:all": "yarn install && yarn postinstall && yarn bundle-install",
|
|
16
|
-
"ios": "
|
|
17
|
-
"ios:prebuild": "yarn workspace palette-mobile-example ios:prebuild",
|
|
12
|
+
"ios": "expo run:ios --port 8082",
|
|
18
13
|
"lint:all": "yarn lint .",
|
|
19
14
|
"lint": "eslint --cache --cache-location '.cache/eslint/' --ext .ts,.tsx --fix",
|
|
20
15
|
"local-palette-dev": "./scripts/sync-after-change",
|
|
21
|
-
"open-xcode": "open
|
|
16
|
+
"open-xcode": "open ios/PaletteMobile.xcworkspace",
|
|
22
17
|
"postinstall": "yarn patch-package",
|
|
23
|
-
"prebuild": "
|
|
18
|
+
"prebuild": "npx expo prebuild",
|
|
24
19
|
"prepare": "patch-package && husky install",
|
|
25
20
|
"prepublishOnly": "yarn clean && yarn compile",
|
|
26
|
-
"prestart": "
|
|
21
|
+
"prestart": "sb-rn-get-stories",
|
|
27
22
|
"prettier-write": "prettier --write --ignore-unknown",
|
|
28
23
|
"release:canary": "auto canary",
|
|
29
24
|
"release": "auto shipit",
|
|
30
25
|
"setup:artsy": "./scripts/download-fonts",
|
|
31
|
-
"start:reset-cache": "
|
|
32
|
-
"start": "
|
|
33
|
-
"storybook-watcher": "
|
|
26
|
+
"start:reset-cache": "npx expo start -c --port 8082",
|
|
27
|
+
"start": "npx expo start --port 8082",
|
|
28
|
+
"storybook-watcher": "sb-rn-watcher",
|
|
34
29
|
"test": "jest --maxWorkers=2",
|
|
35
30
|
"type-check": "tsc --noEmit"
|
|
36
31
|
},
|
|
@@ -81,7 +76,14 @@
|
|
|
81
76
|
"@babel/preset-react": "7.18.6",
|
|
82
77
|
"@babel/preset-typescript": "7.18.6",
|
|
83
78
|
"@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",
|
|
84
83
|
"@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",
|
|
85
87
|
"@testing-library/react-native": "13.2.0",
|
|
86
88
|
"@types/events": "^3.0.0",
|
|
87
89
|
"@types/jest": "29.4.0",
|
|
@@ -106,6 +108,8 @@
|
|
|
106
108
|
"eslint-plugin-react-native-a11y": "^3.5.1",
|
|
107
109
|
"eslint-plugin-storybook": "0.6.10",
|
|
108
110
|
"eslint-plugin-testing-library": "6.4.0",
|
|
111
|
+
"expo": "^53.0.0",
|
|
112
|
+
"expo-dev-client": "~5.2.4",
|
|
109
113
|
"husky": "^8.0.3",
|
|
110
114
|
"jest": "~29.7.0",
|
|
111
115
|
"jest-environment-jsdom": "29.4.2",
|
|
@@ -118,7 +122,10 @@
|
|
|
118
122
|
"prettier": "^2.8.8",
|
|
119
123
|
"pull-lock": "1.0.0",
|
|
120
124
|
"react": "19.0.0",
|
|
125
|
+
"react-dom": "19.0.0",
|
|
121
126
|
"react-native": "0.79.6",
|
|
127
|
+
"react-native-device-info": "14.0.4",
|
|
128
|
+
"react-native-gesture-handler": "~2.22.1",
|
|
122
129
|
"react-native-haptic-feedback": "1.14.0",
|
|
123
130
|
"react-native-linear-gradient": "2.6.2",
|
|
124
131
|
"react-native-reanimated": "3.17.5",
|
|
@@ -150,7 +157,7 @@
|
|
|
150
157
|
"author": "Pavlos Vinieratos <pvinis@gmail.com>",
|
|
151
158
|
"license": "MIT",
|
|
152
159
|
"pull-lock": {
|
|
153
|
-
"
|
|
160
|
+
"ios/Podfile.lock": "echo \"🚨 New Podfile.lock detected!, you might need to run yarn install:all\" 🚨",
|
|
154
161
|
"yarn.lock": "yarn install"
|
|
155
162
|
},
|
|
156
163
|
"lint-staged": {
|