@artsy/palette-mobile 22.1.0 → 22.2.0--canary.425.5130.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/dist/elements/Image/Image.js +5 -3
- package/dist/elements/Screen/Header.d.ts +1 -0
- package/dist/elements/Screen/Header.js +2 -2
- package/dist/elements/Skeleton/Skeleton.js +1 -1
- package/dist/elements/Tabs/TabMasonry.d.ts +3 -3
- package/dist/elements/Tabs/TabMasonry.js +1 -1
- package/dist/elements/Tabs/Tabs.stories.d.ts +7 -1
- package/dist/elements/Tabs/Tabs.stories.js +17 -2
- package/dist/storybook/decorators.js +1 -1
- package/package.json +4 -3
|
@@ -3,7 +3,8 @@ import FastImage from "@d11/react-native-fast-image";
|
|
|
3
3
|
import { memo, useState } from "react";
|
|
4
4
|
// @ts-expect-error
|
|
5
5
|
import { Blurhash } from "react-native-blurhash";
|
|
6
|
-
import Animated, {
|
|
6
|
+
import Animated, { useAnimatedStyle, useSharedValue, withSpring } from "react-native-reanimated";
|
|
7
|
+
import { scheduleOnRN } from "react-native-worklets";
|
|
7
8
|
import { getImageURL } from "./helpers/getImageURL";
|
|
8
9
|
import { DEFAULT_ANIMATION_DURATION } from "../../constants";
|
|
9
10
|
import { useColor } from "../../utils/hooks";
|
|
@@ -17,7 +18,7 @@ export const Image = memo(({ aspectRatio, width, height, performResize = true, s
|
|
|
17
18
|
const color = useColor();
|
|
18
19
|
const onLoadEnd = () => {
|
|
19
20
|
opacity.value = withSpring(0, { duration: DEFAULT_ANIMATION_DURATION }, () => {
|
|
20
|
-
|
|
21
|
+
scheduleOnRN(setIsLoading, false);
|
|
21
22
|
});
|
|
22
23
|
};
|
|
23
24
|
const skeletonStyle = useAnimatedStyle(() => {
|
|
@@ -26,7 +27,8 @@ export const Image = memo(({ aspectRatio, width, height, performResize = true, s
|
|
|
26
27
|
};
|
|
27
28
|
});
|
|
28
29
|
if (showLoadingState) {
|
|
29
|
-
|
|
30
|
+
// Keep logic as small as possible here to save on performance
|
|
31
|
+
return _jsx(Flex, { backgroundColor: "mono10", ...dimensions, style: { position: "absolute" } });
|
|
30
32
|
}
|
|
31
33
|
return (_jsxs(Flex, { position: "relative", ...flexProps, style: { ...dimensions }, children: [_jsx(FastImage, { style: [
|
|
32
34
|
dimensions,
|
|
@@ -11,13 +11,13 @@ import { Touchable } from "../Touchable";
|
|
|
11
11
|
export const AnimatedHeader = (props) => {
|
|
12
12
|
return _jsx(Header, { animated: true, ...props });
|
|
13
13
|
};
|
|
14
|
-
export const Header = ({ animated = false, hideLeftElements, hideRightElements, hideTitle, leftElements, onBack, rightElements, title, titleProps = {}, }) => {
|
|
14
|
+
export const Header = ({ animated = false, hideLeftElements, hideRightElements, hideTitle, leftElements, onBack, rightElements, title, titleProps = {}, zIndex = ZINDEX.header, }) => {
|
|
15
15
|
const { width } = useScreenDimensions();
|
|
16
16
|
const space = useSpace();
|
|
17
17
|
// Assumes small left and right elements, it protects from overflowing
|
|
18
18
|
// but doesn't cover edge cases where right or left are bigger
|
|
19
19
|
const centerMaxWidth = width - space(4) - DEFAULT_ICON_SIZE * 2;
|
|
20
|
-
return (_jsxs(Flex, { height: NAVBAR_HEIGHT, flexDirection: "row", px: 2, zIndex:
|
|
20
|
+
return (_jsxs(Flex, { height: NAVBAR_HEIGHT, flexDirection: "row", px: 2, zIndex: zIndex, backgroundColor: "background", alignItems: "center", children: [_jsx(Flex, { flex: 1, children: _jsx(Left, { leftElements: leftElements, onBack: onBack, hideLeftElements: hideLeftElements }) }), _jsx(Flex, { maxWidth: centerMaxWidth, ...titleProps, children: _jsx(Center, { animated: animated, title: title, hideTitle: hideTitle }) }), _jsx(Flex, { flex: 1, alignItems: "flex-end", children: _jsx(Right, { rightElements: rightElements, hideRightElements: hideRightElements }) })] }));
|
|
21
21
|
};
|
|
22
22
|
const Right = ({ hideRightElements, rightElements }) => {
|
|
23
23
|
return _jsx(_Fragment, { children: !hideRightElements && rightElements });
|
|
@@ -29,7 +29,7 @@ export const Skeleton = ({ children }) => {
|
|
|
29
29
|
};
|
|
30
30
|
export const SkeletonText = ({ children, ...rest }) => {
|
|
31
31
|
const color = useColor();
|
|
32
|
-
return (_jsx(Flex, { alignSelf: "flex-start", children: _jsx(Text, { ...rest, bg: color("mono10"), color: "
|
|
32
|
+
return (_jsx(Flex, { alignSelf: "flex-start", children: _jsx(Text, { ...rest, bg: color("mono10"), color: "rgb(251, 0, 0, 0)", children: children }) }));
|
|
33
33
|
};
|
|
34
34
|
export const SkeletonBox = ({ children, ...rest }) => {
|
|
35
35
|
const color = useColor();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FlashListProps, FlashListRef } from "@shopify/flash-list";
|
|
2
2
|
import { Ref } from "react";
|
|
3
|
-
export declare function TabMasonry<T>(props:
|
|
4
|
-
innerRef?: Ref<
|
|
3
|
+
export declare function TabMasonry<T>(props: FlashListProps<T> & {
|
|
4
|
+
innerRef?: Ref<FlashListRef<T>> | null;
|
|
5
5
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -6,7 +6,7 @@ export function TabMasonry(props) {
|
|
|
6
6
|
useListenForTabContentScroll();
|
|
7
7
|
const space = useSpace();
|
|
8
8
|
const contentContainerStyle = (props.contentContainerStyle ?? {});
|
|
9
|
-
return (_jsx(Tabs.
|
|
9
|
+
return (_jsx(Tabs.FlashList, { masonry: true, contentContainerStyle: {
|
|
10
10
|
paddingHorizontal: space(2),
|
|
11
11
|
...contentContainerStyle,
|
|
12
12
|
}, ...props, ref: props.innerRef }));
|
|
@@ -15,7 +15,13 @@ export declare const TabsWithAnimatedHeader: {
|
|
|
15
15
|
name: string;
|
|
16
16
|
};
|
|
17
17
|
};
|
|
18
|
-
export declare const
|
|
18
|
+
export declare const TabsWithHeader: {
|
|
19
|
+
(): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
story: {
|
|
21
|
+
name: string;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export declare const MasonryTabsWithHeader: {
|
|
19
25
|
(): import("react/jsx-runtime").JSX.Element;
|
|
20
26
|
story: {
|
|
21
27
|
name: string;
|
|
@@ -15,7 +15,22 @@ export const TabsWithAnimatedHeader = () => (_jsxs(Screen, { children: [_jsx(Scr
|
|
|
15
15
|
TabsWithAnimatedHeader.story = {
|
|
16
16
|
name: "Tabs with AnimatedHeader",
|
|
17
17
|
};
|
|
18
|
-
export const
|
|
19
|
-
|
|
18
|
+
export const TabsWithHeader = () => {
|
|
19
|
+
return (_jsxs(Tabs.TabsWithHeader, { title: "Artist Header", showLargeHeaderText: false, BelowTitleHeaderComponent: () => (_jsxs(Flex, { pointerEvents: "none", p: 2, children: [_jsx(Text, { children: "Info" }), _jsx(Text, { children: "More Info" })] })), children: [_jsx(Tabs.Tab, { name: "tab1", label: "Tab 1", children: _jsx(Tabs.ScrollView, { children: _jsx(Text, { children: "Some long text ".repeat(150) }) }) }), _jsx(Tabs.Tab, { name: "tab2", label: "Tab 2", children: _jsx(Text, { children: "Some long text ".repeat(150) }) })] }));
|
|
20
|
+
};
|
|
21
|
+
TabsWithHeader.story = {
|
|
20
22
|
name: "Tabs with header",
|
|
21
23
|
};
|
|
24
|
+
export const MasonryTabsWithHeader = () => {
|
|
25
|
+
return (_jsxs(Tabs.TabsWithHeader, { title: "Tabs with Masonry", children: [_jsx(Tabs.Tab, { name: "tab1", label: "Tab 1", children: _jsx(Tabs.FlatList, { data: Array.from({ length: 20 }), contentContainerStyle: {
|
|
26
|
+
paddingHorizontal: 0,
|
|
27
|
+
}, renderItem: () => _jsx(Flex, { backgroundColor: randomHexColor(), height: 80, width: "100%" }) }) }), _jsx(Tabs.Tab, { name: "tab2", label: "Tab 2", children: _jsx(Tabs.FlatList, { contentContainerStyle: {
|
|
28
|
+
paddingHorizontal: 0,
|
|
29
|
+
}, data: Array.from({ length: 20 }), renderItem: () => _jsx(Flex, { backgroundColor: randomHexColor(), height: 80, width: "100%" }) }) })] }));
|
|
30
|
+
};
|
|
31
|
+
const randomHexColor = () => {
|
|
32
|
+
return `#${Math.floor(Math.random() * 16777215).toString(16)}`;
|
|
33
|
+
};
|
|
34
|
+
MasonryTabsWithHeader.story = {
|
|
35
|
+
name: "Masonry Tabs with header",
|
|
36
|
+
};
|
|
@@ -41,5 +41,5 @@ export const useDarkModeSwitcher = (story) => {
|
|
|
41
41
|
// We are keeping the status bar white on darkmode on ios because background isn't a supported prop on iOS
|
|
42
42
|
, {
|
|
43
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, {
|
|
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, { flex: 1, justifyContent: "center", alignItems: "center", children: story() })] })] }) }) }));
|
|
45
45
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@artsy/palette-mobile",
|
|
3
|
-
"version": "22.
|
|
3
|
+
"version": "22.2.0--canary.425.5130.0",
|
|
4
4
|
"description": "Artsy's design system for React Native",
|
|
5
5
|
"workspaces": [
|
|
6
6
|
"Example"
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@artsy/palette-tokens": "7.0.0",
|
|
46
46
|
"@d11/react-native-fast-image": "8.12.0",
|
|
47
47
|
"@react-spring/native": "^10.0.3",
|
|
48
|
-
"@shopify/flash-list": "
|
|
48
|
+
"@shopify/flash-list": "2.2.0",
|
|
49
49
|
"@styled-system/theme-get": "^5.1.2",
|
|
50
50
|
"events": "^3.3.0",
|
|
51
51
|
"lodash": "^4.17.21",
|
|
@@ -124,9 +124,10 @@
|
|
|
124
124
|
"react-native": "0.81.5",
|
|
125
125
|
"react-native-haptic-feedback": "1.14.0",
|
|
126
126
|
"react-native-linear-gradient": "2.6.2",
|
|
127
|
-
"react-native-reanimated": "
|
|
127
|
+
"react-native-reanimated": "4.1.5",
|
|
128
128
|
"react-native-safe-area-context": "5.6.0",
|
|
129
129
|
"react-native-svg": "15.12.1",
|
|
130
|
+
"react-native-worklets": "0.6.1",
|
|
130
131
|
"react-test-renderer": "19.1.0",
|
|
131
132
|
"rimraf": "4.1.2",
|
|
132
133
|
"styled-components": "6.1.19",
|