@artsy/palette-mobile 24.9.0 → 24.11.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.
@@ -28,6 +28,7 @@ export interface ButtonProps extends BoxProps {
28
28
  /** Used only for tests and stories */
29
29
  testOnly_state?: DisplayState;
30
30
  textVariant?: TextVariant;
31
+ followText?: string;
31
32
  }
32
33
  declare enum DisplayState {
33
34
  Enabled = "enabled",
@@ -56,6 +56,7 @@ var Button = function (_a) {
56
56
  var children = _a.children, disabled = _a.disabled, haptic = _a.haptic, icon = _a.icon, _b = _a.iconPosition, iconPosition = _b === void 0 ? "left" : _b, loading = _a.loading, longestText = _a.longestText, onPress = _a.onPress, _c = _a.size, size = _c === void 0 ? "large" : _c, _d = _a.variant, variant = _d === void 0 ? "fillDark" : _d, testOnly_state = _a.testOnly_state, testID = _a.testID, textVariant = _a.textVariant, hitSlop = _a.hitSlop, rest = __rest(_a, ["children", "disabled", "haptic", "icon", "iconPosition", "loading", "longestText", "onPress", "size", "variant", "testOnly_state", "testID", "textVariant", "hitSlop"]);
57
57
  var textVariantBySize = size === "small" ? "xs" : "sm";
58
58
  var textStyle = { fontSize: (0, helpers_1.useTextStyleForPalette)(textVariant !== null && textVariant !== void 0 ? textVariant : textVariantBySize).fontSize };
59
+ var space = (0, hooks_1.useSpace)();
59
60
  var _e = (0, react_1.useState)(DisplayState.Enabled), innerDisplayState = _e[0], setInnerDisplayState = _e[1];
60
61
  var _f = (0, react_1.useState)({
61
62
  width: 0,
@@ -69,7 +70,7 @@ var Button = function (_a) {
69
70
  var getSize = function () {
70
71
  switch (size) {
71
72
  case "small":
72
- return { height: 30 * react_native_1.PixelRatio.getFontScale(), mx: "15px" };
73
+ return { height: 30 * react_native_1.PixelRatio.getFontScale(), mx: "10px" };
73
74
  case "large":
74
75
  return { height: 50 * react_native_1.PixelRatio.getFontScale(), mx: "30px" };
75
76
  }
@@ -115,6 +116,9 @@ var Button = function (_a) {
115
116
  backgroundColor: springProps.backgroundColor,
116
117
  borderColor: springProps.borderColor,
117
118
  height: containerSize.height,
119
+ // This is needed to make sure that button doesn't push content around its content changes to longestText
120
+ // Here, we are factoring in the padding from the container
121
+ minWidth: longestTextMeasurements.width + space(2),
118
122
  }, children: (0, jsx_runtime_1.jsxs)(Flex_1.Flex, { mx: containerSize.mx, children: [(0, jsx_runtime_1.jsxs)(Flex_1.Flex, { height: "100%", flexDirection: "row", alignItems: "center", justifyContent: "center",
119
123
  // Do not show the content when the button is loading
120
124
  style: { opacity: displayState === DisplayState.Loading ? 0 : 1 }, children: [iconPosition === "left-start" && !!icon ? ((0, jsx_runtime_1.jsxs)(Box_1.Box, { position: "absolute", left: 0, children: [icon, (0, jsx_runtime_1.jsx)(Spacer_1.Spacer, { x: 0.5 })] })) : null, iconPosition === "left" && !!icon ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [icon, (0, jsx_runtime_1.jsx)(Spacer_1.Spacer, { x: 0.5 })] })) : null, !(0, isTestEnvironment_1.isTestEnvironment)() && longestText && longestTextMeasurements.width === 0 && ((0, jsx_runtime_1.jsx)(MeasuredView_1.MeasuredView, { setMeasuredState: setLongestTextMeasurements, children: (0, jsx_runtime_1.jsx)(Text_1.Text, { color: "red", style: textStyle, children: longestText ? longestText : children }) })), (0, jsx_runtime_1.jsx)(AnimatedText, { style: [
@@ -4,5 +4,5 @@ type FollowButtonProps = Omit<ButtonProps, "variant" | "size" | "longestText" |
4
4
  followCount?: number;
5
5
  longestText?: string;
6
6
  };
7
- export declare const FollowButton: ({ isFollowed, followCount, longestText, loading, ...restProps }: FollowButtonProps) => import("react/jsx-runtime").JSX.Element;
7
+ export declare const FollowButton: ({ isFollowed, followCount, longestText, loading, followText: followTextProp, ...restProps }: FollowButtonProps) => import("react/jsx-runtime").JSX.Element;
8
8
  export {};
@@ -25,12 +25,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
25
25
  exports.FollowButton = void 0;
26
26
  var jsx_runtime_1 = require("react/jsx-runtime");
27
27
  var native_1 = require("@artsy/icons/native");
28
+ var react_1 = require("react");
28
29
  var constants_1 = require("../../constants");
29
30
  var formatLargeNumber_1 = require("../../utils/formatLargeNumber");
30
31
  var Button_1 = require("../Button");
31
32
  var FollowButton = function (_a) {
32
- var isFollowed = _a.isFollowed, followCount = _a.followCount, longestText = _a.longestText, loading = _a.loading, restProps = __rest(_a, ["isFollowed", "followCount", "longestText", "loading"]);
33
- var followText = isFollowed ? "Following" : "Follow";
33
+ var isFollowed = _a.isFollowed, followCount = _a.followCount, longestText = _a.longestText, loading = _a.loading, followTextProp = _a.followText, restProps = __rest(_a, ["isFollowed", "followCount", "longestText", "loading", "followText"]);
34
+ var followText = (0, react_1.useMemo)(function () {
35
+ if (followTextProp) {
36
+ return followTextProp;
37
+ }
38
+ return isFollowed ? "Following" : "Follow";
39
+ }, [followTextProp, isFollowed]);
34
40
  var followCountText = !!followCount && followCount > 1 ? " " + (0, formatLargeNumber_1.formatLargeNumber)(followCount, 1) : "";
35
41
  var text = followText + followCountText;
36
42
  return ((0, jsx_runtime_1.jsx)(Button_1.Button, __assign({ variant: isFollowed ? "outline" : "outlineGray", size: "small", longestText: longestText ? longestText : "Following", icon: isFollowed &&
@@ -7,6 +7,11 @@ export interface ImageProps extends CustomFastImageProps {
7
7
  aspectRatio?: number;
8
8
  /** BlurHash code */
9
9
  blurhash?: string | null | undefined;
10
+ /**
11
+ * Decode the blurhash placeholder on a background thread instead of the main thread.
12
+ * Defaults to true.
13
+ */
14
+ blurhashDecodeAsync?: boolean;
10
15
  /** Gemini resize_to param */
11
16
  geminiResizeMode?: GeminiResizeMode;
12
17
  /** Resize on the fly using Gemini. Defaults to true */
@@ -27,6 +32,8 @@ type ImageSkeletonProps = {
27
32
  height: number;
28
33
  };
29
34
  blurhash?: string | null | undefined;
35
+ /** See `blurhashDecodeAsync` on `ImageProps`. Defaults to true. */
36
+ blurhashDecodeAsync?: boolean;
30
37
  style?: StyleProp<ViewStyle>;
31
38
  };
32
39
  export declare const ImageSkeleton: React.FC<ImageSkeletonProps>;
@@ -36,8 +36,8 @@ var useScreenDimensions_1 = require("../../utils/hooks/useScreenDimensions");
36
36
  var Flex_1 = require("../Flex");
37
37
  var Skeleton_1 = require("../Skeleton");
38
38
  exports.Image = (0, react_1.memo)(function (_a) {
39
- var aspectRatio = _a.aspectRatio, width = _a.width, height = _a.height, _b = _a.performResize, performResize = _b === void 0 ? true : _b, src = _a.src, style = _a.style, resizeMode = _a.resizeMode, geminiResizeMode = _a.geminiResizeMode, _c = _a.showLoadingState, showLoadingState = _c === void 0 ? false : _c, blurhash = _a.blurhash, flexProps = __rest(_a, ["aspectRatio", "width", "height", "performResize", "src", "style", "resizeMode", "geminiResizeMode", "showLoadingState", "blurhash"]);
40
- var _d = (0, react_1.useState)(true), isLoading = _d[0], setIsLoading = _d[1];
39
+ var aspectRatio = _a.aspectRatio, width = _a.width, height = _a.height, _b = _a.performResize, performResize = _b === void 0 ? true : _b, src = _a.src, style = _a.style, resizeMode = _a.resizeMode, geminiResizeMode = _a.geminiResizeMode, _c = _a.showLoadingState, showLoadingState = _c === void 0 ? false : _c, blurhash = _a.blurhash, _d = _a.blurhashDecodeAsync, blurhashDecodeAsync = _d === void 0 ? true : _d, flexProps = __rest(_a, ["aspectRatio", "width", "height", "performResize", "src", "style", "resizeMode", "geminiResizeMode", "showLoadingState", "blurhash", "blurhashDecodeAsync"]);
40
+ var _e = (0, react_1.useState)(true), isLoading = _e[0], setIsLoading = _e[1];
41
41
  var dimensions = useImageDimensions({ aspectRatio: aspectRatio, width: width, height: height });
42
42
  var color = (0, hooks_1.useColor)();
43
43
  if (showLoadingState) {
@@ -53,7 +53,7 @@ exports.Image = (0, react_1.memo)(function (_a) {
53
53
  ], resizeMode: resizeMode, onLoadEnd: function () { return setIsLoading(false); }, source: {
54
54
  priority: react_native_fast_image_1.default.priority.normal,
55
55
  uri: (0, getImageURL_1.getImageURL)({ src: src, dimensions: dimensions, geminiResizeMode: geminiResizeMode, performResize: performResize }),
56
- } }), isLoading && ((0, jsx_runtime_1.jsx)(Flex_1.Flex, { style: [dimensions, { position: "absolute" }], children: (0, jsx_runtime_1.jsx)(exports.ImageSkeleton, { dimensions: dimensions, blurhash: blurhash, style: { position: "absolute" } }) }))] })));
56
+ } }), isLoading && ((0, jsx_runtime_1.jsx)(Flex_1.Flex, { style: [dimensions, { position: "absolute" }], children: (0, jsx_runtime_1.jsx)(exports.ImageSkeleton, { dimensions: dimensions, blurhash: blurhash, blurhashDecodeAsync: blurhashDecodeAsync, style: { position: "absolute" } }) }))] })));
57
57
  });
58
58
  var useImageDimensions = function (props) {
59
59
  var _a, _b;
@@ -77,9 +77,9 @@ var useImageDimensions = function (props) {
77
77
  return dimensions;
78
78
  };
79
79
  var ImageSkeleton = function (_a) {
80
- var dimensions = _a.dimensions, blurhash = _a.blurhash, style = _a.style;
80
+ var dimensions = _a.dimensions, blurhash = _a.blurhash, _b = _a.blurhashDecodeAsync, blurhashDecodeAsync = _b === void 0 ? true : _b, style = _a.style;
81
81
  if (!!blurhash) {
82
- return ((0, jsx_runtime_1.jsx)(Flex_1.Flex, __assign({ backgroundColor: "mono10" }, dimensions, { style: style, children: (0, jsx_runtime_1.jsx)(react_native_blurhash_1.Blurhash, { blurhash: blurhash, style: { flex: 1 }, decodeWidth: 16, decodeHeight: 16, decodeAsync: true }) })));
82
+ return ((0, jsx_runtime_1.jsx)(Flex_1.Flex, __assign({ backgroundColor: "mono10" }, dimensions, { style: style, children: (0, jsx_runtime_1.jsx)(react_native_blurhash_1.Blurhash, { blurhash: blurhash, style: { flex: 1 }, decodeWidth: 16, decodeHeight: 16, decodeAsync: blurhashDecodeAsync }) })));
83
83
  }
84
84
  return ((0, jsx_runtime_1.jsx)(Flex_1.Flex, { style: style, children: (0, jsx_runtime_1.jsx)(Skeleton_1.Skeleton, { children: (0, jsx_runtime_1.jsx)(Skeleton_1.SkeletonBox, __assign({}, dimensions)) }) }));
85
85
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@artsy/palette-mobile",
3
- "version": "24.9.0",
3
+ "version": "24.11.0",
4
4
  "description": "Artsy's design system for React Native",
5
5
  "workspaces": [
6
6
  "Example"