@artsy/palette-mobile 19.13.0 → 19.15.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.
|
@@ -3,13 +3,13 @@ import { useEffect, useState } from "react";
|
|
|
3
3
|
import { Pressable } from "react-native";
|
|
4
4
|
import Haptic from "react-native-haptic-feedback";
|
|
5
5
|
import Animated, { interpolateColor, useAnimatedReaction, useAnimatedStyle, useDerivedValue, useSharedValue, withTiming, } from "react-native-reanimated";
|
|
6
|
+
import { useColorsForVariantAndState } from "./colors";
|
|
6
7
|
import { MeasuredView } from "../../elements/MeasuredView";
|
|
7
8
|
import { Box } from "../Box";
|
|
8
9
|
import { Flex } from "../Flex";
|
|
9
10
|
import { Spacer } from "../Spacer";
|
|
10
11
|
import { Spinner } from "../Spinner";
|
|
11
12
|
import { Text, useTextStyleForPalette } from "../Text";
|
|
12
|
-
import { useColorsForVariantAndState } from "./colors";
|
|
13
13
|
const ANIMATION_DURATION = 150;
|
|
14
14
|
export const Button = ({ children, disabled: disabledProp, haptic, icon, iconPosition = "left", loading: loadingProp, block, longestText, onPress, size = "large", variant = "fillDark", testOnly_pressed, testID, hitSlop, ...restProps }) => {
|
|
15
15
|
const [disabled, setDisabled, disabledV] = useStateWithProp(!!disabledProp);
|
|
@@ -1,7 +1,5 @@
|
|
|
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
|
-
import { useAtom } from "jotai";
|
|
4
|
-
import { atomWithStorage, createJSONStorage } from "jotai/utils";
|
|
5
3
|
import { useEffect, useState } from "react";
|
|
6
4
|
import { Appearance } from "react-native";
|
|
7
5
|
import { SafeAreaProvider } from "react-native-safe-area-context";
|
|
@@ -10,20 +8,34 @@ import { Flex } from "../elements/Flex";
|
|
|
10
8
|
import { LinkText, Text } from "../elements/Text";
|
|
11
9
|
import { ScreenDimensionsProvider } from "../utils/hooks";
|
|
12
10
|
export const withTheme = (story) => (_jsxs(Theme, { theme: "v3light", children: [_jsx(Text, { color: "red", children: "aaww" }), story()] }));
|
|
13
|
-
const
|
|
14
|
-
const atomWithAsyncStorage = (key, initialValue) => atomWithStorage(key, initialValue, {
|
|
15
|
-
...atomStorage,
|
|
16
|
-
}, {
|
|
17
|
-
getOnInit: false,
|
|
18
|
-
});
|
|
19
|
-
const modeAtom = atomWithAsyncStorage("dark-mode-mode", "system");
|
|
11
|
+
const DARK_MODE_STORAGE_KEY = "dark-mode-mode";
|
|
20
12
|
export const useDarkModeSwitcher = (story) => {
|
|
21
|
-
const [mode,
|
|
13
|
+
const [mode, setModeState] = useState("system");
|
|
22
14
|
const [systemMode, setSystemMode] = useState(Appearance.getColorScheme() ?? "light");
|
|
15
|
+
// Load initial value from AsyncStorage on mount
|
|
23
16
|
useEffect(() => {
|
|
24
|
-
|
|
17
|
+
AsyncStorage.getItem(DARK_MODE_STORAGE_KEY)
|
|
18
|
+
.then((value) => {
|
|
19
|
+
if (value && (value === "light" || value === "dark" || value === "system")) {
|
|
20
|
+
setModeState(value);
|
|
21
|
+
}
|
|
22
|
+
})
|
|
23
|
+
.catch((error) => {
|
|
24
|
+
console.error("Failed to load dark mode preference:", error);
|
|
25
|
+
});
|
|
26
|
+
}, []);
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
const subscription = Appearance.addChangeListener(({ colorScheme }) => {
|
|
29
|
+
setSystemMode(colorScheme ?? "light");
|
|
30
|
+
});
|
|
25
31
|
return () => subscription.remove();
|
|
26
32
|
}, []);
|
|
33
|
+
const setMode = (newMode) => {
|
|
34
|
+
setModeState(newMode);
|
|
35
|
+
AsyncStorage.setItem(DARK_MODE_STORAGE_KEY, newMode).catch((error) => {
|
|
36
|
+
console.error("Failed to save dark mode preference:", error);
|
|
37
|
+
});
|
|
38
|
+
};
|
|
27
39
|
const isDarkMode = mode === "dark" || (mode === "system" && systemMode === "dark");
|
|
28
40
|
const theme = isDarkMode ? "v3dark" : "v3light";
|
|
29
41
|
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", children: [_jsxs(Text, { color: "orange", children: ["Dark mode: ", mode, " ", mode === "system" && "(" + systemMode + ")"] }), _jsx(LinkText, { color: "orange", onPress: () => setMode("light"), children: "light" }), _jsx(LinkText, { color: "orange", onPress: () => setMode("dark"), children: "dark" }), _jsx(LinkText, { color: "orange", onPress: () => setMode("system"), children: "system" })] }), story()] }) }) }) }));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@artsy/palette-mobile",
|
|
3
|
-
"version": "19.
|
|
3
|
+
"version": "19.15.0",
|
|
4
4
|
"description": "Artsy's design system for React Native",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"android": "expo run:android --port 8082",
|
|
@@ -77,9 +77,10 @@
|
|
|
77
77
|
"@babel/preset-react": "7.18.6",
|
|
78
78
|
"@babel/preset-typescript": "7.18.6",
|
|
79
79
|
"@babel/runtime": "^7.25.0",
|
|
80
|
+
"@gorhom/bottom-sheet": "^4.6.4",
|
|
80
81
|
"@react-native-async-storage/async-storage": "2.2.0",
|
|
81
82
|
"@react-native/eslint-config": "0.76.9",
|
|
82
|
-
"@storybook/react-native": "
|
|
83
|
+
"@storybook/react-native": "^8.6.2",
|
|
83
84
|
"@testing-library/react-native": "13.2.0",
|
|
84
85
|
"@types/events": "^3.0.0",
|
|
85
86
|
"@types/jest": "29.4.0",
|
|
@@ -114,7 +115,6 @@
|
|
|
114
115
|
"jest-environment-jsdom": "29.4.2",
|
|
115
116
|
"jest-extended": "3.2.3",
|
|
116
117
|
"jest-watch-typeahead": "2.2.2",
|
|
117
|
-
"jotai": "^2.15.0",
|
|
118
118
|
"lint-staged": "13.1.2",
|
|
119
119
|
"nodemon": "^2.0.20",
|
|
120
120
|
"patch-package": "^8.0.0",
|
|
@@ -125,6 +125,7 @@
|
|
|
125
125
|
"react-dom": "19.0.0",
|
|
126
126
|
"react-native": "0.79.6",
|
|
127
127
|
"react-native-device-info": "14.0.4",
|
|
128
|
+
"react-native-gesture-handler": "~2.22.1",
|
|
128
129
|
"react-native-haptic-feedback": "1.14.0",
|
|
129
130
|
"react-native-linear-gradient": "2.6.2",
|
|
130
131
|
"react-native-reanimated": "3.17.5",
|
|
@@ -144,7 +145,6 @@
|
|
|
144
145
|
"files": [
|
|
145
146
|
"dist"
|
|
146
147
|
],
|
|
147
|
-
"main": "dist/index.js",
|
|
148
148
|
"types": "dist/index.d.ts",
|
|
149
149
|
"publishConfig": {
|
|
150
150
|
"access": "public"
|