@artsy/palette-mobile 24.10.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.
|
@@ -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: "
|
|
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 =
|
|
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 &&
|