@artsy/palette-mobile 13.2.31 → 13.2.32

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.
Files changed (29) hide show
  1. package/dist/elements/Button/Button.d.ts +13 -9
  2. package/dist/elements/Button/Button.js +308 -100
  3. package/dist/elements/Button/Button.stories.d.ts +1 -7
  4. package/dist/elements/Button/Button.stories.js +8 -29
  5. package/dist/elements/Button/FollowButton.js +1 -2
  6. package/dist/elements/Button/LinkButton.d.ts +3 -0
  7. package/dist/elements/Button/LinkButton.js +8 -0
  8. package/dist/elements/Button/colors.d.ts +1 -2
  9. package/dist/elements/Button/colors.js +9 -57
  10. package/dist/elements/Button/index.d.ts +1 -0
  11. package/dist/elements/Button/index.js +1 -0
  12. package/dist/elements/ButtonNew/Button.d.ts +34 -0
  13. package/dist/elements/ButtonNew/Button.js +132 -0
  14. package/dist/elements/ButtonNew/Button.stories.d.ts +18 -0
  15. package/dist/elements/ButtonNew/Button.stories.js +66 -0
  16. package/dist/elements/ButtonNew/CTAButton.d.ts +3 -0
  17. package/dist/elements/ButtonNew/CTAButton.js +7 -0
  18. package/dist/elements/ButtonNew/FollowButton.d.ts +9 -0
  19. package/dist/elements/ButtonNew/FollowButton.js +12 -0
  20. package/dist/elements/ButtonNew/LinkButton.d.ts +3 -0
  21. package/dist/elements/ButtonNew/LinkButton.js +8 -0
  22. package/dist/elements/ButtonNew/colors.d.ts +9 -0
  23. package/dist/elements/ButtonNew/colors.js +78 -0
  24. package/dist/elements/ButtonNew/index.d.ts +4 -0
  25. package/dist/elements/ButtonNew/index.js +20 -0
  26. package/dist/elements/Input/helpers.d.ts +1 -1
  27. package/package.json +1 -1
  28. /package/dist/elements/{Button → ButtonNew}/Button.tests.d.ts +0 -0
  29. /package/dist/elements/{Button → ButtonNew}/Button.tests.js +0 -0
@@ -1,16 +1,13 @@
1
1
  /// <reference types="react" />
2
+ import { TextVariant } from "@artsy/palette-tokens/dist/typography/v3";
2
3
  import { PressableProps } from "react-native";
3
4
  import { HapticFeedbackTypes } from "react-native-haptic-feedback";
4
5
  import { BoxProps } from "../Box";
5
- type ButtonSize = "small" | "large";
6
- type ButtonVariant = "fillDark" | "fillLight" | "fillGray" | "fillSuccess" | "outline" | "outlineGray" | "outlineLight" | "text";
7
6
  export interface ButtonProps extends BoxProps {
8
7
  children: React.ReactNode;
9
- size?: ButtonSize;
10
- variant?: ButtonVariant;
8
+ size?: "small" | "large";
9
+ variant?: "fillDark" | "fillLight" | "fillGray" | "fillSuccess" | "outline" | "outlineGray" | "outlineLight" | "text";
11
10
  onPress?: PressableProps["onPress"];
12
- onPressIn?: PressableProps["onPressIn"];
13
- onPressOut?: PressableProps["onPressOut"];
14
11
  icon?: React.ReactNode;
15
12
  iconPosition?: "left" | "left-start" | "right";
16
13
  /**
@@ -30,7 +27,14 @@ export interface ButtonProps extends BoxProps {
30
27
  /** Pass the longest text to the button for the button to keep longest text width */
31
28
  longestText?: string;
32
29
  /** Used only for tests and stories */
33
- testOnly_pressed?: PressableProps["testOnly_pressed"];
30
+ testOnly_state?: DisplayState;
31
+ textVariant?: TextVariant;
34
32
  }
35
- export declare const Button: ({ children, disabled: disabledProp, haptic, icon, iconPosition, loading: loadingProp, block, longestText, onPress, onPressIn, onPressOut, size, variant, testOnly_pressed, testID, hitSlop, ...restProps }: ButtonProps) => JSX.Element;
36
- export {};
33
+ declare enum DisplayState {
34
+ Enabled = "enabled",
35
+ Disabled = "disabled",
36
+ Loading = "loading",
37
+ Pressed = "pressed"
38
+ }
39
+ export declare const Button: React.FC<ButtonProps>;
40
+ export { DisplayState as _test_DisplayState };
@@ -1,134 +1,342 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
4
  };
28
5
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.Button = void 0;
6
+ exports._test_DisplayState = exports.Button = void 0;
30
7
  const jsx_runtime_1 = require("react/jsx-runtime");
31
8
  const react_1 = require("react");
32
9
  const react_native_1 = require("react-native");
33
10
  const react_native_haptic_feedback_1 = __importDefault(require("react-native-haptic-feedback"));
34
- const react_native_reanimated_1 = __importStar(require("react-native-reanimated"));
35
- const colors_1 = require("./colors");
36
- const MeasuredView_1 = require("../../elements/MeasuredView");
11
+ const react_spring_1 = require("react-spring");
12
+ // @ts-ignore
13
+ const renderprops_native_1 = require("react-spring/renderprops-native");
14
+ const native_1 = __importDefault(require("styled-components/native"));
15
+ const hooks_1 = require("../../utils/hooks");
37
16
  const Box_1 = require("../Box");
38
- const Flex_1 = require("../Flex");
17
+ const Flex_1 = require("../Flex/Flex");
18
+ const MeasuredView_1 = require("../MeasuredView");
39
19
  const Spacer_1 = require("../Spacer");
40
20
  const Spinner_1 = require("../Spinner");
41
- const Text_1 = require("../Text");
42
- const ANIMATION_DURATION = 150;
43
- const Button = ({ children, disabled: disabledProp, haptic, icon, iconPosition = "left", loading: loadingProp, block, longestText, onPress, onPressIn, onPressOut, size = "large", variant = "fillDark", testOnly_pressed, testID, hitSlop, ...restProps }) => {
44
- const [disabled] = useStateWithProp(!!disabledProp);
45
- const [loading] = useStateWithProp(!!loadingProp);
46
- const [_, setPressed, pressedV] = useStateWithProp(!!testOnly_pressed);
47
- const pressAnimationProgress = (0, react_native_reanimated_1.useSharedValue)(0);
48
- (0, react_native_reanimated_1.useAnimatedReaction)(() => {
49
- return pressedV.value;
50
- }, (pressedVal) => {
51
- return (pressAnimationProgress.value = (0, react_native_reanimated_1.withTiming)(pressedVal, {
52
- duration: ANIMATION_DURATION,
53
- }));
54
- });
55
- const textStyle = (0, Text_1.useTextStyleForPalette)(size === "small" ? "xs" : "sm");
21
+ const Text_1 = require("../Text/Text");
22
+ const helpers_1 = require("../Text/helpers");
23
+ var DisplayState;
24
+ (function (DisplayState) {
25
+ DisplayState["Enabled"] = "enabled";
26
+ DisplayState["Disabled"] = "disabled";
27
+ DisplayState["Loading"] = "loading";
28
+ DisplayState["Pressed"] = "pressed";
29
+ })(DisplayState || (DisplayState = {}));
30
+ exports._test_DisplayState = DisplayState;
31
+ const Button = ({ children, disabled, haptic, icon, iconPosition = "left", loading, longestText, onPress, size = "large", variant = "fillDark", testOnly_state, testID, textVariant, hitSlop, ...rest }) => {
32
+ const textVariantBySize = size === "small" ? "xs" : "sm";
33
+ const textStyle = (0, helpers_1.useTextStyleForPalette)(textVariant ?? textVariantBySize);
34
+ const [innerDisplayState, setInnerDisplayState] = (0, react_1.useState)(DisplayState.Enabled);
56
35
  const [longestTextMeasurements, setLongestTextMeasurements] = (0, react_1.useState)({
57
36
  width: 0,
58
37
  height: 0,
59
38
  });
60
- const height = (() => {
39
+ const displayState = testOnly_state ?? // if we use the test prop, use that
40
+ (loading // if we have loading or disabled in props, they are used
41
+ ? DisplayState.Loading
42
+ : disabled
43
+ ? DisplayState.Disabled
44
+ : innerDisplayState); // otherwise use the inner state for pressed or enabled
45
+ const getSize = () => {
61
46
  switch (size) {
62
47
  case "small":
63
- return 30;
48
+ return { height: 30, mx: "15px" };
64
49
  case "large":
65
- return 50;
50
+ return { height: 50, mx: "30px" };
66
51
  }
67
- })();
52
+ };
68
53
  const handlePress = (event) => {
69
54
  if (onPress === undefined || onPress === null) {
70
55
  return;
71
56
  }
72
- if (disabled || loading) {
57
+ if (displayState === DisplayState.Loading || displayState === DisplayState.Disabled) {
73
58
  return;
74
59
  }
60
+ // Did someone tap really fast? Flick the highlighted state
61
+ if (displayState === DisplayState.Enabled) {
62
+ setInnerDisplayState(DisplayState.Pressed);
63
+ setTimeout(() => {
64
+ setInnerDisplayState(DisplayState.Enabled);
65
+ }, 0.3);
66
+ }
67
+ else {
68
+ // Was already selected
69
+ setInnerDisplayState(DisplayState.Enabled);
70
+ }
75
71
  if (haptic !== undefined) {
76
72
  react_native_haptic_feedback_1.default.trigger(haptic === true ? "impactLight" : haptic);
77
73
  }
78
74
  onPress(event);
79
75
  };
80
- const colorsForVariantAndState = (0, colors_1.useColorsForVariantAndState)();
81
- const containerColorsAnim = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
82
- const colors = colorsForVariantAndState[variant];
83
- if (disabled) {
84
- return {
85
- backgroundColor: colors.disabled.bg,
86
- borderColor: colors.disabled.border,
87
- };
88
- }
89
- if (loading) {
90
- return {
91
- backgroundColor: colors.loading.bg,
92
- borderColor: colors.loading.border,
93
- };
94
- }
95
- return {
96
- backgroundColor: (0, react_native_reanimated_1.interpolateColor)(pressAnimationProgress.value, [0, 1], [colors.active.bg, colors.pressed.bg]),
97
- borderColor: (0, react_native_reanimated_1.interpolateColor)(pressAnimationProgress.value, [0, 1], [colors.active.border, colors.pressed.border]),
98
- };
99
- });
100
- const textAnim = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
101
- const colors = colorsForVariantAndState[variant];
102
- if (loading) {
103
- return { color: colors.loading.text };
104
- }
105
- return {
106
- color: (0, react_native_reanimated_1.interpolateColor)(pressAnimationProgress.value, [0, 1], [colors.active.text, colors.pressed.text]),
107
- textDecorationLine: pressAnimationProgress.value > 0 ? "underline" : "none",
108
- };
109
- });
110
- const loaderColor = colorsForVariantAndState[variant].loading.loader;
111
- return ((0, jsx_runtime_1.jsx)(react_native_1.Pressable, { disabled: disabled, onPressIn: (e) => {
112
- onPressIn?.(e);
113
- setPressed(true);
114
- }, onPressOut: (e) => {
115
- onPressOut?.(e);
116
- setPressed(false);
117
- }, onPress: handlePress, testID: testID, testOnly_pressed: testOnly_pressed, hitSlop: hitSlop, children: (0, jsx_runtime_1.jsx)(Flex_1.Flex, { flexDirection: "row", children: (0, jsx_runtime_1.jsx)(Flex_1.Flex, { ...restProps, height: height, width: block ? "100%" : undefined, borderRadius: 50, overflow: "hidden", children: (0, jsx_runtime_1.jsx)(AFlex, { borderWidth: 1, borderRadius: 50, overflow: "hidden", style: containerColorsAnim, children: (0, jsx_runtime_1.jsxs)(Flex_1.Flex, { height: "100%", mx: "25px", flexDirection: "row", alignItems: "center", justifyContent: "center", 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, jsx_runtime_1.jsx)(AText, { style: [{ width: Math.ceil(longestTextMeasurements.width) }, textStyle, textAnim], textAlign: "center", selectable: false, children: children }), (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 }) }), iconPosition === "right" && !!icon && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Spacer_1.Spacer, { x: 0.5 }), icon] })), loading && ((0, jsx_runtime_1.jsx)(Box_1.Box, { position: "absolute", width: "100%", height: "100%", alignItems: "center", justifyContent: "center", children: (0, jsx_runtime_1.jsx)(Spinner_1.Spinner, { size: size, color: loaderColor }) }))] }) }) }) }) }));
76
+ const containerSize = getSize();
77
+ const to = useStyleForVariantAndState(variant, testOnly_state ?? displayState);
78
+ return ((0, jsx_runtime_1.jsx)(renderprops_native_1.Spring, { native: true, to: to, config: react_spring_1.config.stiff, children: (springProps) => ((0, jsx_runtime_1.jsx)(react_native_1.Pressable, { hitSlop: hitSlop, testOnly_pressed: testOnly_state === DisplayState.Pressed, disabled: testOnly_state === DisplayState.Disabled || disabled, onPressIn: () => {
79
+ if (displayState === DisplayState.Loading) {
80
+ return;
81
+ }
82
+ setInnerDisplayState(DisplayState.Pressed);
83
+ }, onPressOut: () => {
84
+ if (displayState === DisplayState.Loading) {
85
+ return;
86
+ }
87
+ setInnerDisplayState(DisplayState.Enabled);
88
+ }, onPress: handlePress, testID: testID, children: (0, jsx_runtime_1.jsx)(Flex_1.Flex, { flexDirection: "row", children: (0, jsx_runtime_1.jsx)(AnimatedContainer, { ...rest, style: {
89
+ backgroundColor: springProps.backgroundColor,
90
+ borderColor: springProps.borderColor,
91
+ height: containerSize.height,
92
+ }, 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", 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, !__TEST__ && longestText && ((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: [
93
+ {
94
+ width: longestText ? Math.ceil(longestTextMeasurements.width) : "auto",
95
+ color: springProps.textColor,
96
+ textDecorationLine: springProps.textDecorationLine,
97
+ },
98
+ textStyle,
99
+ ], textAlign: "center", children: children }), iconPosition === "right" && !!icon && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Spacer_1.Spacer, { x: 0.5 }), icon] }))] }), displayState === DisplayState.Loading && ((0, jsx_runtime_1.jsx)(SpinnerContainer, { children: (0, jsx_runtime_1.jsx)(Spinner_1.Spinner, { size: size, color: to.loaderColor }) }))] }) }) }) })) }));
118
100
  };
119
101
  exports.Button = Button;
120
- const AText = react_native_reanimated_1.default.createAnimatedComponent(Text_1.Text);
121
- const AFlex = react_native_reanimated_1.default.createAnimatedComponent(Flex_1.Flex);
122
- const useStateWithProp = (prop) => {
123
- const [state, setState] = (0, react_1.useState)(!!prop);
124
- (0, react_1.useEffect)(() => {
125
- setState(!!prop);
126
- }, [prop]);
127
- const stateV = (0, react_native_reanimated_1.useDerivedValue)(() => {
128
- if (!!state) {
129
- return 1;
130
- }
131
- return 0;
132
- }, [state]);
133
- return [state, setState, stateV];
102
+ const useStyleForVariantAndState = (variant, state) => {
103
+ const color = (0, hooks_1.useColor)();
104
+ const retval = {
105
+ textDecorationLine: "none",
106
+ };
107
+ switch (variant) {
108
+ case "fillDark":
109
+ retval.textColor = color("white100");
110
+ switch (state) {
111
+ case DisplayState.Enabled:
112
+ retval.backgroundColor = color("black100");
113
+ retval.borderColor = color("black100");
114
+ break;
115
+ case DisplayState.Disabled:
116
+ retval.backgroundColor = color("black30");
117
+ retval.borderColor = color("black30");
118
+ break;
119
+ case DisplayState.Loading:
120
+ retval.backgroundColor = color("black100");
121
+ retval.borderColor = color("black100");
122
+ retval.textColor = "rgba(0, 0, 0, 0)";
123
+ retval.loaderColor = "white100";
124
+ break;
125
+ case DisplayState.Pressed:
126
+ retval.backgroundColor = color("blue100");
127
+ retval.borderColor = color("blue100");
128
+ retval.textDecorationLine = "underline";
129
+ break;
130
+ default:
131
+ null;
132
+ }
133
+ break;
134
+ case "fillLight":
135
+ switch (state) {
136
+ case DisplayState.Enabled:
137
+ retval.backgroundColor = color("white100");
138
+ retval.borderColor = color("white100");
139
+ retval.textColor = color("black100");
140
+ break;
141
+ case DisplayState.Disabled:
142
+ retval.backgroundColor = color("black30");
143
+ retval.borderColor = color("black30");
144
+ retval.textColor = color("white100");
145
+ break;
146
+ case DisplayState.Loading:
147
+ retval.backgroundColor = color("white100");
148
+ retval.borderColor = color("white100");
149
+ retval.textColor = "rgba(0, 0, 0, 0)";
150
+ retval.loaderColor = "black100";
151
+ break;
152
+ case DisplayState.Pressed:
153
+ retval.backgroundColor = color("blue100");
154
+ retval.borderColor = color("blue100");
155
+ retval.textColor = color("white100");
156
+ retval.textDecorationLine = "underline";
157
+ break;
158
+ default:
159
+ null;
160
+ }
161
+ break;
162
+ case "fillGray":
163
+ switch (state) {
164
+ case DisplayState.Enabled:
165
+ retval.backgroundColor = color("black10");
166
+ retval.borderColor = color("black10");
167
+ retval.textColor = color("black100");
168
+ break;
169
+ case DisplayState.Disabled:
170
+ retval.backgroundColor = color("black30");
171
+ retval.borderColor = color("black30");
172
+ retval.textColor = color("white100");
173
+ break;
174
+ case DisplayState.Loading:
175
+ retval.backgroundColor = color("black10");
176
+ retval.borderColor = color("black10");
177
+ retval.textColor = "rgba(0, 0, 0, 0)";
178
+ retval.loaderColor = "black100";
179
+ break;
180
+ case DisplayState.Pressed:
181
+ retval.backgroundColor = color("blue100");
182
+ retval.borderColor = color("blue100");
183
+ retval.textColor = color("white100");
184
+ retval.textDecorationLine = "underline";
185
+ break;
186
+ default:
187
+ null;
188
+ }
189
+ break;
190
+ case "fillSuccess":
191
+ retval.textColor = color("white100");
192
+ switch (state) {
193
+ case DisplayState.Enabled:
194
+ retval.backgroundColor = color("blue100");
195
+ retval.borderColor = color("blue100");
196
+ break;
197
+ case DisplayState.Disabled:
198
+ retval.backgroundColor = color("blue100");
199
+ retval.borderColor = color("blue100");
200
+ break;
201
+ case DisplayState.Loading:
202
+ retval.backgroundColor = color("blue100");
203
+ retval.borderColor = color("blue100");
204
+ retval.textColor = "rgba(0, 0, 0, 0)";
205
+ retval.loaderColor = "white100";
206
+ break;
207
+ case DisplayState.Pressed:
208
+ retval.backgroundColor = color("blue10");
209
+ retval.borderColor = color("blue10");
210
+ retval.textDecorationLine = "underline";
211
+ break;
212
+ default:
213
+ null;
214
+ }
215
+ break;
216
+ case "outline":
217
+ switch (state) {
218
+ case DisplayState.Enabled:
219
+ retval.backgroundColor = color("white100");
220
+ retval.borderColor = color("black60");
221
+ retval.textColor = color("black100");
222
+ break;
223
+ case DisplayState.Disabled:
224
+ retval.backgroundColor = color("white100");
225
+ retval.borderColor = color("black30");
226
+ retval.textColor = color("black30");
227
+ break;
228
+ case DisplayState.Loading:
229
+ retval.backgroundColor = color("white100");
230
+ retval.borderColor = color("black60");
231
+ retval.textColor = "rgba(0, 0, 0, 0)";
232
+ retval.loaderColor = "black100";
233
+ break;
234
+ case DisplayState.Pressed:
235
+ retval.backgroundColor = color("blue100");
236
+ retval.borderColor = color("blue100");
237
+ retval.textColor = color("white100");
238
+ retval.textDecorationLine = "underline";
239
+ break;
240
+ default:
241
+ null;
242
+ }
243
+ break;
244
+ case "outlineGray":
245
+ switch (state) {
246
+ case DisplayState.Enabled:
247
+ retval.backgroundColor = color("white100");
248
+ retval.borderColor = color("black30");
249
+ retval.textColor = color("black100");
250
+ break;
251
+ case DisplayState.Disabled:
252
+ retval.backgroundColor = color("white100");
253
+ retval.borderColor = color("black30");
254
+ retval.textColor = color("black30");
255
+ break;
256
+ case DisplayState.Loading:
257
+ retval.backgroundColor = color("white100");
258
+ retval.borderColor = color("black30");
259
+ retval.textColor = "rgba(0, 0, 0, 0)";
260
+ retval.loaderColor = "black100";
261
+ break;
262
+ case DisplayState.Pressed:
263
+ retval.backgroundColor = color("blue100");
264
+ retval.borderColor = color("blue100");
265
+ retval.textColor = color("white100");
266
+ retval.textDecorationLine = "underline";
267
+ break;
268
+ default:
269
+ null;
270
+ }
271
+ break;
272
+ case "outlineLight":
273
+ switch (state) {
274
+ case DisplayState.Enabled:
275
+ retval.backgroundColor = "rgba(0, 0, 0, 0)";
276
+ retval.borderColor = color("white100");
277
+ retval.textColor = color("white100");
278
+ break;
279
+ case DisplayState.Disabled:
280
+ retval.backgroundColor = "rgba(0, 0, 0, 0)";
281
+ retval.borderColor = color("black30");
282
+ retval.textColor = color("black30");
283
+ break;
284
+ case DisplayState.Loading:
285
+ retval.backgroundColor = "rgba(0, 0, 0, 0)";
286
+ retval.borderColor = color("white100");
287
+ retval.textColor = "rgba(0, 0, 0, 0)";
288
+ retval.loaderColor = "white100";
289
+ break;
290
+ case DisplayState.Pressed:
291
+ retval.backgroundColor = color("blue100");
292
+ retval.borderColor = color("blue100");
293
+ retval.textColor = "rgba(0, 0, 0, 0)";
294
+ retval.textDecorationLine = "underline";
295
+ break;
296
+ default:
297
+ null;
298
+ }
299
+ break;
300
+ case "text":
301
+ retval.backgroundColor = "rgba(0, 0, 0, 0)";
302
+ retval.borderColor = "rgba(0, 0, 0, 0)";
303
+ switch (state) {
304
+ case DisplayState.Enabled:
305
+ retval.textColor = color("black100");
306
+ break;
307
+ case DisplayState.Disabled:
308
+ retval.textColor = color("black30");
309
+ break;
310
+ case DisplayState.Loading:
311
+ retval.textColor = "rgba(0, 0, 0, 0)";
312
+ retval.loaderColor = "blue100";
313
+ break;
314
+ case DisplayState.Pressed:
315
+ retval.textColor = color("blue100");
316
+ retval.textDecorationLine = "underline";
317
+ break;
318
+ default:
319
+ null;
320
+ }
321
+ break;
322
+ default:
323
+ null;
324
+ }
325
+ return retval;
134
326
  };
327
+ const Container = (0, native_1.default)(Box_1.Box) `
328
+ position: relative;
329
+ border-width: 1px;
330
+ border-radius: 50px;
331
+ width: ${(p) => (p.block ? "100%" : "auto")};
332
+ overflow: hidden;
333
+ `;
334
+ const SpinnerContainer = (0, native_1.default)(Box_1.Box) `
335
+ position: absolute;
336
+ width: 100%;
337
+ height: 100%;
338
+ align-items: center;
339
+ justify-content: center;
340
+ `;
341
+ const AnimatedContainer = (0, renderprops_native_1.animated)(Container);
342
+ const AnimatedText = (0, renderprops_native_1.animated)(Text_1.Text);
@@ -2,16 +2,10 @@
2
2
  import { ButtonProps } from "./Button";
3
3
  declare const _default: {
4
4
  title: string;
5
- component: ({ children, disabled: disabledProp, haptic, icon, iconPosition, loading: loadingProp, block, longestText, onPress, onPressIn, onPressOut, size, variant, testOnly_pressed, testID, hitSlop, ...restProps }: ButtonProps) => JSX.Element;
5
+ component: import("react").FC<ButtonProps>;
6
6
  };
7
7
  export default _default;
8
8
  export declare const Sizes: () => JSX.Element;
9
9
  export declare const States: () => JSX.Element;
10
10
  export declare const Variants: () => JSX.Element;
11
11
  export declare const VariantsLoading: () => JSX.Element;
12
- export declare const VariantsDisabled: () => JSX.Element;
13
- export declare const TheFollowButton: () => JSX.Element;
14
- export declare const TheCTAButton: () => JSX.Element;
15
- export declare const Miscellaneous: () => JSX.Element;
16
- export declare const Playground: () => JSX.Element;
17
- export declare const SpacingAround: () => JSX.Element;
@@ -1,19 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SpacingAround = exports.Playground = exports.Miscellaneous = exports.TheCTAButton = exports.TheFollowButton = exports.VariantsDisabled = exports.VariantsLoading = exports.Variants = exports.States = exports.Sizes = void 0;
3
+ exports.VariantsLoading = exports.Variants = exports.States = exports.Sizes = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const lodash_1 = require("lodash");
6
6
  const react_1 = require("react");
7
- const react_native_1 = require("react-native");
8
7
  const Button_1 = require("./Button");
9
- const CTAButton_1 = require("./CTAButton");
10
- const FollowButton_1 = require("./FollowButton");
11
8
  const helpers_1 = require("../../storybook/helpers");
12
- const svgs_1 = require("../../svgs");
13
9
  const Wrap_1 = require("../../utils/Wrap");
14
- const Box_1 = require("../Box");
15
10
  const Flex_1 = require("../Flex");
16
- const Spacer_1 = require("../Spacer");
17
11
  const Text_1 = require("../Text");
18
12
  const sizes = ["small", "large"];
19
13
  const variants = [
@@ -34,30 +28,15 @@ const Sizes = () => ((0, jsx_runtime_1.jsx)(helpers_1.DataList, { data: sizes, r
34
28
  exports.Sizes = Sizes;
35
29
  const States = () => {
36
30
  const [variant, setVariant] = (0, react_1.useState)("fillDark");
37
- return ((0, jsx_runtime_1.jsxs)(helpers_1.List, { children: [(0, jsx_runtime_1.jsx)(Flex_1.Flex, { flexDirection: "row", flexWrap: "wrap", px: 2, children: variants.map((v) => ((0, jsx_runtime_1.jsx)(Text_1.LinkText, { color: "orange", onPress: () => setVariant(v), mr: "2", children: v }))) }), (0, jsx_runtime_1.jsx)(Button_1.Button, { variant: variant, onPress: () => console.log(`tapped`), longestText: "Regular YEA", children: "Regular" }), (0, jsx_runtime_1.jsx)(Button_1.Button, { variant: variant, onPress: () => console.log(`tapped`), disabled: true, children: "Disabled" }), (0, jsx_runtime_1.jsx)(Button_1.Button, { variant: variant, onPress: () => console.log(`tapped`), loading: true, children: "Loading" }), (0, jsx_runtime_1.jsx)(Button_1.Button, { variant: variant, onPress: () => console.log(`tapped`), testOnly_pressed: true, children: "Pressed" })] }));
31
+ return ((0, jsx_runtime_1.jsxs)(helpers_1.List, { children: [(0, jsx_runtime_1.jsx)(Flex_1.Flex, { flexDirection: "row", flexWrap: "wrap", px: 2, children: variants.map((v) => ((0, jsx_runtime_1.jsx)(Text_1.LinkText, { color: "orange", onPress: () => setVariant(v), mr: "2", children: v }))) }), (0, jsx_runtime_1.jsx)(Button_1.Button, { variant: variant, onPress: () => console.log(`tapped`), longestText: "Regular YEA", children: "Regular" }), (0, jsx_runtime_1.jsx)(Button_1.Button, { variant: variant, onPress: () => console.log(`tapped`), disabled: true, children: "Disabled" }), (0, jsx_runtime_1.jsx)(Button_1.Button, { variant: variant, onPress: () => console.log(`tapped`), loading: true, children: "Loading" })] }));
38
32
  };
39
33
  exports.States = States;
40
34
  const Variants = () => ((0, jsx_runtime_1.jsx)(helpers_1.DataList, { data: variants, renderItem: ({ item: variant }) => ((0, jsx_runtime_1.jsx)(Wrap_1.Wrap, { if: variant === "outlineLight" || variant === "fillLight", children: (0, jsx_runtime_1.jsx)(Flex_1.Flex, { backgroundColor: "pink", p: 1, children: (0, jsx_runtime_1.jsx)(Wrap_1.Wrap.Content, { children: (0, jsx_runtime_1.jsx)(Button_1.Button, { variant: variant, onPress: () => console.log(`tapped ${variant}`), children: variant }) }) }) })) }));
41
35
  exports.Variants = Variants;
42
- const VariantsLoading = () => ((0, jsx_runtime_1.jsx)(helpers_1.DataList, { data: variants, renderItem: ({ item: variant }) => ((0, jsx_runtime_1.jsx)(Wrap_1.Wrap, { if: variant === "outlineLight", children: (0, jsx_runtime_1.jsx)(Flex_1.Flex, { backgroundColor: "black100", p: 1, children: (0, jsx_runtime_1.jsx)(Wrap_1.Wrap.Content, { children: (0, jsx_runtime_1.jsx)(Button_1.Button, { variant: variant, loading: true, onPress: () => console.log(`tapped ${variant}`), children: variant }) }) }) }, `variant_loading_${variant}`)) }));
36
+ const VariantsLoading = () => ((0, jsx_runtime_1.jsx)(helpers_1.DataList, { data: variants, renderItem: ({ item: variant }) => {
37
+ if (variant !== "outlineLight") {
38
+ return ((0, jsx_runtime_1.jsx)(Button_1.Button, { variant: variant, loading: true, onPress: () => console.log(`tapped ${variant}`), children: variant }));
39
+ }
40
+ return ((0, jsx_runtime_1.jsx)(Flex_1.Flex, { backgroundColor: "pink", py: 0.5, children: (0, jsx_runtime_1.jsx)(Button_1.Button, { variant: variant, loading: true, onPress: () => console.log(`tapped ${variant}`), children: variant }) }));
41
+ } }));
43
42
  exports.VariantsLoading = VariantsLoading;
44
- const VariantsDisabled = () => ((0, jsx_runtime_1.jsx)(helpers_1.DataList, { data: variants, renderItem: ({ item: variant }) => ((0, jsx_runtime_1.jsx)(Wrap_1.Wrap, { if: variant === "outlineLight", children: (0, jsx_runtime_1.jsx)(Flex_1.Flex, { backgroundColor: "black100", p: 1, children: (0, jsx_runtime_1.jsx)(Wrap_1.Wrap.Content, { children: (0, jsx_runtime_1.jsx)(Button_1.Button, { variant: variant, disabled: true, onPress: () => console.log(`tapped ${variant}`), children: variant }) }) }) })) }));
45
- exports.VariantsDisabled = VariantsDisabled;
46
- const TheFollowButton = () => {
47
- const [follow, setFollow] = (0, react_1.useState)(true);
48
- return ((0, jsx_runtime_1.jsxs)(helpers_1.List, { children: [(0, jsx_runtime_1.jsx)(FollowButton_1.FollowButton, { loading: true, isFollowed: follow, onPress: () => setFollow((v) => !v) }), (0, jsx_runtime_1.jsx)(FollowButton_1.FollowButton, { isFollowed: follow, onPress: () => setFollow((v) => !v) }), (0, jsx_runtime_1.jsx)(FollowButton_1.FollowButton, { followCount: 4, isFollowed: follow, onPress: () => setFollow((v) => !v) }), (0, jsx_runtime_1.jsx)(FollowButton_1.FollowButton, { followCount: 40, isFollowed: follow, onPress: () => setFollow((v) => !v) }), (0, jsx_runtime_1.jsx)(FollowButton_1.FollowButton, { followCount: 4000, isFollowed: follow, onPress: () => setFollow((v) => !v) }), (0, jsx_runtime_1.jsx)(FollowButton_1.FollowButton, { followCount: 400000, isFollowed: follow, onPress: () => setFollow((v) => !v) }), (0, jsx_runtime_1.jsx)(FollowButton_1.FollowButton, { followCount: 40000000, isFollowed: follow, onPress: () => setFollow((v) => !v) })] }));
49
- };
50
- exports.TheFollowButton = TheFollowButton;
51
- const TheCTAButton = () => ((0, jsx_runtime_1.jsx)(helpers_1.List, { children: (0, jsx_runtime_1.jsx)(CTAButton_1.CTAButton, { onPress: () => console.log("pressed"), children: "cta button" }) }));
52
- exports.TheCTAButton = TheCTAButton;
53
- const Miscellaneous = () => ((0, jsx_runtime_1.jsxs)(helpers_1.List, { children: [(0, jsx_runtime_1.jsx)(Button_1.Button, { loading: true, disabled: true, children: "loading and disabled" }), (0, jsx_runtime_1.jsx)(Button_1.Button, { loading: true, disabled: true, icon: (0, jsx_runtime_1.jsx)(svgs_1.LinkIcon, {}), children: "loading and disabled with icon" }), (0, jsx_runtime_1.jsx)(Button_1.Button, { block: true, children: "block" }), (0, jsx_runtime_1.jsx)(Flex_1.Flex, { backgroundColor: "orange", width: 400, height: 80, alignItems: "center", justifyContent: "center", children: (0, jsx_runtime_1.jsx)(Button_1.Button, { variant: "fillLight", icon: (0, jsx_runtime_1.jsx)(svgs_1.LinkIcon, {}), children: "left icon" }) }), (0, jsx_runtime_1.jsx)(Button_1.Button, { icon: (0, jsx_runtime_1.jsx)(svgs_1.LinkIcon, { fill: "white100" }), iconPosition: "right", children: "right icon" }), (0, jsx_runtime_1.jsx)(Button_1.Button, { size: "small", icon: (0, jsx_runtime_1.jsx)(svgs_1.LinkIcon, { fill: "white100" }), iconPosition: "right", children: "Right Icon Small" }), (0, jsx_runtime_1.jsx)(Button_1.Button, { variant: "fillDark", size: "small", icon: (0, jsx_runtime_1.jsx)(svgs_1.BellIcon, { fill: "white100", width: "16px", height: "16px" }), children: "Create Alert" }), (0, jsx_runtime_1.jsxs)(Box_1.Box, { flexDirection: "row", children: [(0, jsx_runtime_1.jsx)(Box_1.Box, { width: 2, height: "100%", backgroundColor: "green100" }), (0, jsx_runtime_1.jsxs)(Box_1.Box, { children: [(0, jsx_runtime_1.jsx)(Button_1.Button, { size: "small", icon: (0, jsx_runtime_1.jsx)(svgs_1.LinkIcon, { fill: "white100" }), iconPosition: "right", longestText: "this is a very long text", children: "shortest text" }), (0, jsx_runtime_1.jsx)(Spacer_1.Spacer, { y: 1 }), (0, jsx_runtime_1.jsx)(Button_1.Button, { size: "small", icon: (0, jsx_runtime_1.jsx)(svgs_1.LinkIcon, { fill: "white100" }), iconPosition: "right", longestText: "this is a very long text", children: "this is a very long text" })] }), (0, jsx_runtime_1.jsx)(Box_1.Box, { width: 2, height: "100%", backgroundColor: "green100" })] }), (0, jsx_runtime_1.jsx)(Button_1.Button, { icon: (0, jsx_runtime_1.jsx)(svgs_1.LinkIcon, { fill: "white100" }), block: true, iconPosition: "left-start", children: "left-start aligned icon" })] }));
54
- exports.Miscellaneous = Miscellaneous;
55
- const Playground = () => {
56
- const [loading, setLoading] = (0, react_1.useState)(false);
57
- const [disabled, setDisabled] = (0, react_1.useState)(true);
58
- const [block, setBlock] = (0, react_1.useState)(false);
59
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_native_1.Button, { title: "loading", onPress: () => setLoading((v) => !v) }), (0, jsx_runtime_1.jsx)(react_native_1.Button, { title: "disabled", onPress: () => setDisabled((v) => !v) }), (0, jsx_runtime_1.jsx)(react_native_1.Button, { title: "block", onPress: () => setBlock((v) => !v) }), (0, jsx_runtime_1.jsx)(helpers_1.List, { children: (0, jsx_runtime_1.jsxs)(Button_1.Button, { loading: loading, disabled: disabled, block: block, longestText: "loading false, disabled false, block false", children: ["loading ", loading ? "true" : "false", ", disabled ", disabled ? "true" : "false", ", block", " ", block ? "true" : "false"] }) })] }));
60
- };
61
- exports.Playground = Playground;
62
- const SpacingAround = () => ((0, jsx_runtime_1.jsxs)(Box_1.Box, { children: [(0, jsx_runtime_1.jsx)(Button_1.Button, { m: 2, children: "wow 1" }), (0, jsx_runtime_1.jsx)(Button_1.Button, { children: "wow 2" })] }));
63
- exports.SpacingAround = SpacingAround;
@@ -7,7 +7,6 @@ const formatLargeNumber_1 = require("../../utils/formatLargeNumber");
7
7
  const Button_1 = require("../Button");
8
8
  const Text_1 = require("../Text");
9
9
  const FollowButton = ({ isFollowed, followCount, longestText, loading, ...restProps }) => {
10
- const label = isFollowed ? "Following" : "Follow";
11
- return ((0, jsx_runtime_1.jsx)(Button_1.Button, { variant: isFollowed ? "outline" : "outlineGray", size: "small", longestText: longestText ? longestText : "Following", icon: isFollowed && !loading && (0, jsx_runtime_1.jsx)(CheckIcon_1.CheckIcon, { fill: "black60", width: "16px", height: "16px" }), loading: loading, ...restProps, children: !!loading ? (`${label} ${followCount && followCount > 1 ? (0, formatLargeNumber_1.formatLargeNumber)(followCount, 1) : ""}`) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Text_1.Text, { variant: "xs", children: label }), !!followCount && followCount > 1 && ((0, jsx_runtime_1.jsx)(Text_1.Text, { variant: "xs", color: "black60", children: " " + (0, formatLargeNumber_1.formatLargeNumber)(followCount, 1) }))] })) }));
10
+ return ((0, jsx_runtime_1.jsx)(Button_1.Button, { variant: isFollowed ? "outline" : "outlineGray", size: "small", longestText: longestText ? longestText : "Following", icon: isFollowed && !loading && (0, jsx_runtime_1.jsx)(CheckIcon_1.CheckIcon, { fill: "black60", width: "16px", height: "16px" }), loading: loading, ...restProps, children: !loading && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Text_1.Text, { variant: "xs", children: isFollowed ? "Following" : "Follow" }), !!followCount && followCount > 1 && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(Text_1.Text, { variant: "xs", color: "black60", children: " " + (0, formatLargeNumber_1.formatLargeNumber)(followCount, 1) }) }))] })) }));
12
11
  };
13
12
  exports.FollowButton = FollowButton;
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { TextProps } from "../Text";
3
+ export declare const LinkButton: (props: TextProps) => JSX.Element;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LinkButton = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const Text_1 = require("../Text");
6
+ const Touchable_1 = require("../Touchable");
7
+ const LinkButton = (props) => ((0, jsx_runtime_1.jsx)(Touchable_1.Touchable, { onPress: props.onPress, children: (0, jsx_runtime_1.jsx)(Text_1.Text, { underline: true, ...props }) }));
8
+ exports.LinkButton = LinkButton;
@@ -1,10 +1,9 @@
1
1
  import { ButtonProps } from "./Button";
2
2
  import { NoUndefined } from "../../utils/types";
3
- type State = "disabled" | "pressed" | "active" | "loading";
3
+ type State = "disabled" | "pressed" | "active";
4
4
  export declare const useColorsForVariantAndState: () => Record<NoUndefined<ButtonProps["variant"]>, Record<State, {
5
5
  bg: string;
6
6
  border: string;
7
7
  text: string;
8
- loader?: string;
9
8
  }>>;
10
9
  export {};
@@ -1,20 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useColorsForVariantAndState = void 0;
4
- const hooks_1 = require("../../utils/hooks");
4
+ const useColor_1 = require("../../utils/hooks/useColor");
5
5
  const useColorsForVariantAndState = () => {
6
- const color = (0, hooks_1.useColor)();
6
+ const color = (0, useColor_1.useColor)();
7
7
  return {
8
8
  fillDark: {
9
9
  disabled: { bg: color("black30"), border: color("black30"), text: color("onPrimaryHigh") },
10
10
  pressed: { bg: color("blue100"), border: color("blue100"), text: color("onPrimaryHigh") },
11
11
  active: { bg: color("primary"), border: color("primary"), text: color("onPrimaryHigh") },
12
- loading: {
13
- bg: color("black100"),
14
- border: color("black100"),
15
- text: "rgba(0, 0, 0, 0)",
16
- loader: "white100",
17
- },
18
12
  },
19
13
  fillLight: {
20
14
  disabled: { bg: color("black30"), border: color("black30"), text: color("onPrimaryHigh") },
@@ -24,52 +18,28 @@ const useColorsForVariantAndState = () => {
24
18
  border: color("white100"),
25
19
  text: color("black100"),
26
20
  },
27
- loading: {
28
- bg: color("white100"),
29
- border: color("white100"),
30
- text: "rgba(0, 0, 0, 0)",
31
- loader: "black100",
32
- },
33
21
  },
34
22
  fillGray: {
35
23
  disabled: { bg: color("black30"), border: color("black30"), text: color("white100") },
36
24
  pressed: { bg: color("blue100"), border: color("blue100"), text: color("white100") },
37
25
  active: { bg: color("black10"), border: color("black10"), text: color("black100") },
38
- loading: {
39
- bg: color("black10"),
40
- border: color("black10"),
41
- text: "rgba(0, 0, 0, 0)",
42
- loader: "black100",
43
- },
44
26
  },
45
27
  fillSuccess: {
46
28
  disabled: { bg: color("blue100"), border: color("blue100"), text: color("white100") },
47
29
  pressed: { bg: color("blue100"), border: color("blue100"), text: color("white100") },
48
30
  active: { bg: color("blue10"), border: color("blue10"), text: color("white100") },
49
- loading: {
50
- bg: color("blue100"),
51
- border: color("blue100"),
52
- text: "rgba(0, 0, 0, 0)",
53
- loader: "white100",
54
- },
55
31
  },
56
32
  outline: {
57
33
  disabled: {
58
- bg: color("white100"),
59
- border: color("black100"),
60
- text: color("black100"),
34
+ bg: color("background"),
35
+ border: color("onBackgroundLow"),
36
+ text: color("onBackgroundLow"),
61
37
  },
62
38
  pressed: { bg: color("blue100"), border: color("blue100"), text: color("white100") },
63
39
  active: {
64
- bg: color("white100"),
65
- border: color("black60"),
66
- text: color("black100"),
67
- },
68
- loading: {
69
- bg: color("white100"),
70
- border: color("black60"),
71
- text: "rgba(0, 0, 0, 0)",
72
- loader: "black100",
40
+ bg: color("background"),
41
+ border: color("onBackgroundMedium"),
42
+ text: color("onBackgroundHigh"),
73
43
  },
74
44
  },
75
45
  outlineGray: {
@@ -80,15 +50,9 @@ const useColorsForVariantAndState = () => {
80
50
  },
81
51
  pressed: { bg: color("blue100"), border: color("blue100"), text: color("white100") },
82
52
  active: {
83
- bg: color("white100"),
84
- border: color("black60"),
85
- text: color("black100"),
86
- },
87
- loading: {
88
53
  bg: color("white100"),
89
54
  border: color("black30"),
90
- text: "rgba(0, 0, 0, 0)",
91
- loader: "black100",
55
+ text: color("black100"),
92
56
  },
93
57
  },
94
58
  outlineLight: {
@@ -103,23 +67,11 @@ const useColorsForVariantAndState = () => {
103
67
  border: color("white100"),
104
68
  text: color("white100"),
105
69
  },
106
- loading: {
107
- bg: "rgba(0,0,0,0)",
108
- border: color("white100"),
109
- text: "rgba(0, 0, 0, 0)",
110
- loader: "white100",
111
- },
112
70
  },
113
71
  text: {
114
72
  disabled: { bg: "rgba(0, 0, 0, 0)", border: "rgba(0, 0, 0, 0)", text: color("black30") },
115
73
  pressed: { bg: color("black10"), border: color("black10"), text: color("blue100") },
116
74
  active: { bg: "rgba(0, 0, 0, 0)", border: "rgba(0, 0, 0, 0)", text: color("black100") },
117
- loading: {
118
- bg: color("white100"),
119
- border: color("white100"),
120
- text: "rgba(0, 0, 0, 0)",
121
- loader: "blue100",
122
- },
123
75
  },
124
76
  };
125
77
  };
@@ -1,3 +1,4 @@
1
1
  export * from "./Button";
2
2
  export * from "./CTAButton";
3
+ export * from "./LinkButton";
3
4
  export * from "./FollowButton";
@@ -16,4 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./Button"), exports);
18
18
  __exportStar(require("./CTAButton"), exports);
19
+ __exportStar(require("./LinkButton"), exports);
19
20
  __exportStar(require("./FollowButton"), exports);
@@ -0,0 +1,34 @@
1
+ /// <reference types="react" />
2
+ import { PressableProps } from "react-native";
3
+ import { HapticFeedbackTypes } from "react-native-haptic-feedback";
4
+ import { BoxProps } from "../Box";
5
+ type ButtonSize = "small" | "large";
6
+ type ButtonVariant = "fillDark" | "fillLight" | "fillGray" | "fillSuccess" | "outline" | "outlineGray" | "outlineLight" | "text";
7
+ export interface ButtonProps extends BoxProps {
8
+ children: React.ReactNode;
9
+ size?: ButtonSize;
10
+ variant?: ButtonVariant;
11
+ onPress?: PressableProps["onPress"];
12
+ icon?: React.ReactNode;
13
+ iconPosition?: "left" | "left-start" | "right";
14
+ /**
15
+ * `haptic` can be used like:
16
+ * <Button haptic />
17
+ * or
18
+ * <Button haptic="impactHeavy" />
19
+ * to add haptic feedback on the button.
20
+ */
21
+ haptic?: HapticFeedbackTypes | true;
22
+ /** Displays a loader in the button */
23
+ loading?: boolean;
24
+ /** Disabled interactions */
25
+ disabled?: boolean;
26
+ /** Makes button full width */
27
+ block?: boolean;
28
+ /** Pass the longest text to the button for the button to keep longest text width */
29
+ longestText?: string;
30
+ /** Used only for tests and stories */
31
+ testOnly_pressed?: PressableProps["testOnly_pressed"];
32
+ }
33
+ export declare const Button: ({ children, disabled: disabledProp, haptic, icon, iconPosition, loading: loadingProp, block, longestText, onPress, size, variant, testOnly_pressed, testID, hitSlop, ...restProps }: ButtonProps) => JSX.Element;
34
+ export {};
@@ -0,0 +1,132 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.Button = void 0;
30
+ const jsx_runtime_1 = require("react/jsx-runtime");
31
+ const react_1 = require("react");
32
+ const react_native_1 = require("react-native");
33
+ const react_native_haptic_feedback_1 = __importDefault(require("react-native-haptic-feedback"));
34
+ const react_native_reanimated_1 = __importStar(require("react-native-reanimated"));
35
+ const colors_1 = require("./colors");
36
+ const MeasuredView_1 = require("../../elements/MeasuredView");
37
+ const Box_1 = require("../Box");
38
+ const Flex_1 = require("../Flex");
39
+ const Spacer_1 = require("../Spacer");
40
+ const Spinner_1 = require("../Spinner");
41
+ const Text_1 = require("../Text");
42
+ const ANIMATION_DURATION = 150;
43
+ const Button = ({ children, disabled: disabledProp, haptic, icon, iconPosition = "left", loading: loadingProp, block, longestText, onPress, size = "large", variant = "fillDark", testOnly_pressed, testID, hitSlop, ...restProps }) => {
44
+ const [disabled, setDisabled, disabledV] = useStateWithProp(!!disabledProp);
45
+ const [loading, setLoading, loadingV] = useStateWithProp(!!loadingProp);
46
+ const [pressed, setPressed, pressedV] = useStateWithProp(!!testOnly_pressed);
47
+ const pressAnimationProgress = (0, react_native_reanimated_1.useSharedValue)(0);
48
+ (0, react_native_reanimated_1.useAnimatedReaction)(() => {
49
+ return pressedV.value;
50
+ }, (pressedVal) => {
51
+ return (pressAnimationProgress.value = (0, react_native_reanimated_1.withTiming)(pressedVal, {
52
+ duration: ANIMATION_DURATION,
53
+ }));
54
+ });
55
+ const textStyle = (0, Text_1.useTextStyleForPalette)(size === "small" ? "xs" : "sm");
56
+ const [longestTextMeasurements, setLongestTextMeasurements] = (0, react_1.useState)({
57
+ width: 0,
58
+ height: 0,
59
+ });
60
+ const height = (() => {
61
+ switch (size) {
62
+ case "small":
63
+ return 30;
64
+ case "large":
65
+ return 50;
66
+ }
67
+ })();
68
+ const spinnerColor = variant === "text" ? "blue100" : "white100";
69
+ const handlePress = (event) => {
70
+ if (onPress === undefined || onPress === null) {
71
+ return;
72
+ }
73
+ if (disabled || loading) {
74
+ return;
75
+ }
76
+ if (haptic !== undefined) {
77
+ react_native_haptic_feedback_1.default.trigger(haptic === true ? "impactLight" : haptic);
78
+ }
79
+ onPress(event);
80
+ };
81
+ const colorsForVariantAndState = (0, colors_1.useColorsForVariantAndState)();
82
+ const containerColorsAnim = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
83
+ const colors = colorsForVariantAndState[variant];
84
+ if (disabled) {
85
+ return {
86
+ backgroundColor: colors.disabled.bg,
87
+ borderColor: colors.disabled.border,
88
+ };
89
+ }
90
+ return {
91
+ backgroundColor: (0, react_native_reanimated_1.interpolateColor)(pressAnimationProgress.value, [0, 1], [colors.active.bg, colors.pressed.bg]),
92
+ borderColor: (0, react_native_reanimated_1.interpolateColor)(pressAnimationProgress.value, [0, 1], [colors.active.border, colors.pressed.border]),
93
+ };
94
+ });
95
+ const textAnim = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
96
+ const colors = colorsForVariantAndState[variant];
97
+ if (loading) {
98
+ return { color: "rgba(0, 0, 0, 0)" };
99
+ }
100
+ return {
101
+ color: (0, react_native_reanimated_1.interpolateColor)(pressAnimationProgress.value, [0, 1], [colors.active.text, colors.pressed.text]),
102
+ textDecorationLine: pressAnimationProgress.value > 0 ? "underline" : "none",
103
+ };
104
+ });
105
+ return ((0, jsx_runtime_1.jsx)(react_native_1.Pressable, { disabled: disabled, onPressIn: () => {
106
+ if (loading) {
107
+ return;
108
+ }
109
+ setPressed(true);
110
+ }, onPressOut: () => {
111
+ if (loading) {
112
+ return;
113
+ }
114
+ setPressed(false);
115
+ }, onPress: handlePress, testID: testID, testOnly_pressed: testOnly_pressed, hitSlop: hitSlop, children: (0, jsx_runtime_1.jsx)(Flex_1.Flex, { flexDirection: "row", children: (0, jsx_runtime_1.jsx)(Flex_1.Flex, { ...restProps, height: height, width: block ? "100%" : undefined, borderRadius: 50, overflow: "hidden", children: (0, jsx_runtime_1.jsx)(AFlex, { borderWidth: 1, borderRadius: 50, overflow: "hidden", style: containerColorsAnim, children: (0, jsx_runtime_1.jsxs)(Flex_1.Flex, { height: "100%", mx: "25px", flexDirection: "row", alignItems: "center", justifyContent: "center", 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, jsx_runtime_1.jsx)(AText, { style: [{ width: Math.ceil(longestTextMeasurements.width) }, textStyle, textAnim], textAlign: "center", children: children }), (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 }) }), iconPosition === "right" && !!icon ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Spacer_1.Spacer, { x: 0.5 }), icon] })) : null, loading ? ((0, jsx_runtime_1.jsx)(Box_1.Box, { position: "absolute", width: "100%", height: "100%", alignItems: "center", justifyContent: "center", children: (0, jsx_runtime_1.jsx)(Spinner_1.Spinner, { size: size, color: spinnerColor }) })) : null] }) }) }) }) }));
116
+ };
117
+ exports.Button = Button;
118
+ const AText = react_native_reanimated_1.default.createAnimatedComponent(Text_1.Text);
119
+ const AFlex = react_native_reanimated_1.default.createAnimatedComponent(Flex_1.Flex);
120
+ const useStateWithProp = (prop) => {
121
+ const [state, setState] = (0, react_1.useState)(!!prop);
122
+ (0, react_1.useEffect)(() => {
123
+ setState(!!prop);
124
+ }, [prop]);
125
+ const stateV = (0, react_native_reanimated_1.useDerivedValue)(() => {
126
+ if (!!state) {
127
+ return 1;
128
+ }
129
+ return 0;
130
+ }, [state]);
131
+ return [state, setState, stateV];
132
+ };
@@ -0,0 +1,18 @@
1
+ /// <reference types="react" />
2
+ import { ButtonProps } from "./Button";
3
+ declare const _default: {
4
+ title: string;
5
+ component: ({ children, disabled: disabledProp, haptic, icon, iconPosition, loading: loadingProp, block, longestText, onPress, size, variant, testOnly_pressed, testID, hitSlop, ...restProps }: ButtonProps) => JSX.Element;
6
+ };
7
+ export default _default;
8
+ export declare const Sizes: () => JSX.Element;
9
+ export declare const States: () => JSX.Element;
10
+ export declare const Variants: () => JSX.Element;
11
+ export declare const VariantsLoading: () => JSX.Element;
12
+ export declare const VariantsDisabled: () => JSX.Element;
13
+ export declare const TheFollowButton: () => JSX.Element;
14
+ export declare const TheCTAButton: () => JSX.Element;
15
+ export declare const TheLinkButton: () => JSX.Element;
16
+ export declare const Miscellaneous: () => JSX.Element;
17
+ export declare const Playground: () => JSX.Element;
18
+ export declare const SpacingAround: () => JSX.Element;
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SpacingAround = exports.Playground = exports.Miscellaneous = exports.TheLinkButton = exports.TheCTAButton = exports.TheFollowButton = exports.VariantsDisabled = exports.VariantsLoading = exports.Variants = exports.States = exports.Sizes = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const lodash_1 = require("lodash");
6
+ const react_1 = require("react");
7
+ const react_native_1 = require("react-native");
8
+ const Button_1 = require("./Button");
9
+ const CTAButton_1 = require("./CTAButton");
10
+ const FollowButton_1 = require("./FollowButton");
11
+ const LinkButton_1 = require("./LinkButton");
12
+ const helpers_1 = require("../../storybook/helpers");
13
+ const svgs_1 = require("../../svgs");
14
+ const Wrap_1 = require("../../utils/Wrap");
15
+ const Box_1 = require("../Box");
16
+ const Flex_1 = require("../Flex");
17
+ const Spacer_1 = require("../Spacer");
18
+ const Text_1 = require("../Text");
19
+ const sizes = ["small", "large"];
20
+ const variants = [
21
+ "fillDark",
22
+ "fillLight",
23
+ "fillGray",
24
+ "fillSuccess",
25
+ "outline",
26
+ "outlineGray",
27
+ "outlineLight",
28
+ "text",
29
+ ];
30
+ exports.default = {
31
+ title: "ButtonNew",
32
+ component: Button_1.Button,
33
+ };
34
+ const Sizes = () => ((0, jsx_runtime_1.jsx)(helpers_1.DataList, { data: sizes, renderItem: ({ item: size }) => ((0, jsx_runtime_1.jsx)(Button_1.Button, { size: size, onPress: () => console.log(`tapped ${size}`), children: (0, lodash_1.capitalize)(size) })) }));
35
+ exports.Sizes = Sizes;
36
+ const States = () => {
37
+ const [variant, setVariant] = (0, react_1.useState)("fillDark");
38
+ return ((0, jsx_runtime_1.jsxs)(helpers_1.List, { children: [(0, jsx_runtime_1.jsx)(Flex_1.Flex, { flexDirection: "row", flexWrap: "wrap", px: 2, children: variants.map((variant) => ((0, jsx_runtime_1.jsx)(Text_1.LinkText, { color: "orange", onPress: () => setVariant(variant), mr: "2", children: variant }))) }), (0, jsx_runtime_1.jsx)(Button_1.Button, { variant: variant, onPress: () => console.log(`tapped`), longestText: "Regular YEA", children: "Regular" }), (0, jsx_runtime_1.jsx)(Button_1.Button, { variant: variant, onPress: () => console.log(`tapped`), disabled: true, children: "Disabled" }), (0, jsx_runtime_1.jsx)(Button_1.Button, { variant: variant, onPress: () => console.log(`tapped`), loading: true, children: "Loading" }), (0, jsx_runtime_1.jsx)(Button_1.Button, { variant: variant, onPress: () => console.log(`tapped`), testOnly_pressed: true, children: "Pressed" })] }));
39
+ };
40
+ exports.States = States;
41
+ const Variants = () => ((0, jsx_runtime_1.jsx)(helpers_1.DataList, { data: variants, renderItem: ({ item: variant }) => ((0, jsx_runtime_1.jsx)(Wrap_1.Wrap, { if: variant === "outlineLight" || variant === "fillLight", children: (0, jsx_runtime_1.jsx)(Flex_1.Flex, { backgroundColor: "pink", p: 1, children: (0, jsx_runtime_1.jsx)(Wrap_1.Wrap.Content, { children: (0, jsx_runtime_1.jsx)(Button_1.Button, { variant: variant, onPress: () => console.log(`tapped ${variant}`), children: variant }) }) }) })) }));
42
+ exports.Variants = Variants;
43
+ const VariantsLoading = () => ((0, jsx_runtime_1.jsx)(helpers_1.DataList, { data: variants, renderItem: ({ item: variant }) => ((0, jsx_runtime_1.jsx)(Button_1.Button, { variant: variant, loading: true, onPress: () => console.log(`tapped ${variant}`), children: variant })) }));
44
+ exports.VariantsLoading = VariantsLoading;
45
+ const VariantsDisabled = () => ((0, jsx_runtime_1.jsx)(helpers_1.DataList, { data: variants, renderItem: ({ item: variant }) => ((0, jsx_runtime_1.jsx)(Wrap_1.Wrap, { if: variant === "outlineLight", children: (0, jsx_runtime_1.jsx)(Flex_1.Flex, { backgroundColor: "black100", p: 1, children: (0, jsx_runtime_1.jsx)(Wrap_1.Wrap.Content, { children: (0, jsx_runtime_1.jsx)(Button_1.Button, { variant: variant, disabled: true, onPress: () => console.log(`tapped ${variant}`), children: variant }) }) }) })) }));
46
+ exports.VariantsDisabled = VariantsDisabled;
47
+ const TheFollowButton = () => {
48
+ const [follow, setFollow] = (0, react_1.useState)(true);
49
+ return ((0, jsx_runtime_1.jsxs)(helpers_1.List, { children: [(0, jsx_runtime_1.jsx)(FollowButton_1.FollowButton, { isFollowed: follow, onPress: () => setFollow((v) => !v) }), (0, jsx_runtime_1.jsx)(FollowButton_1.FollowButton, { followCount: 4, isFollowed: follow, onPress: () => setFollow((v) => !v) }), (0, jsx_runtime_1.jsx)(FollowButton_1.FollowButton, { followCount: 40, isFollowed: follow, onPress: () => setFollow((v) => !v) }), (0, jsx_runtime_1.jsx)(FollowButton_1.FollowButton, { followCount: 4000, isFollowed: follow, onPress: () => setFollow((v) => !v) }), (0, jsx_runtime_1.jsx)(FollowButton_1.FollowButton, { followCount: 400000, isFollowed: follow, onPress: () => setFollow((v) => !v) }), (0, jsx_runtime_1.jsx)(FollowButton_1.FollowButton, { followCount: 40000000, isFollowed: follow, onPress: () => setFollow((v) => !v) }), (0, jsx_runtime_1.jsx)(FollowButton_1.FollowButton, { followCount: 4000000000, isFollowed: follow, onPress: () => setFollow((v) => !v) })] }));
50
+ };
51
+ exports.TheFollowButton = TheFollowButton;
52
+ const TheCTAButton = () => ((0, jsx_runtime_1.jsx)(helpers_1.List, { children: (0, jsx_runtime_1.jsx)(CTAButton_1.CTAButton, { onPress: () => console.log("pressed"), children: "cta button" }) }));
53
+ exports.TheCTAButton = TheCTAButton;
54
+ const TheLinkButton = () => ((0, jsx_runtime_1.jsx)(helpers_1.List, { children: (0, jsx_runtime_1.jsx)(LinkButton_1.LinkButton, { onPress: () => console.log("pressed"), children: "LinkButton" }) }));
55
+ exports.TheLinkButton = TheLinkButton;
56
+ const Miscellaneous = () => ((0, jsx_runtime_1.jsxs)(helpers_1.List, { children: [(0, jsx_runtime_1.jsx)(Button_1.Button, { loading: true, disabled: true, children: "loading and disabled" }), (0, jsx_runtime_1.jsx)(Button_1.Button, { loading: true, disabled: true, icon: (0, jsx_runtime_1.jsx)(svgs_1.LinkIcon, {}), children: "loading and disabled with icon" }), (0, jsx_runtime_1.jsx)(Button_1.Button, { block: true, children: "block" }), (0, jsx_runtime_1.jsx)(Flex_1.Flex, { backgroundColor: "orange", width: 400, height: 80, alignItems: "center", justifyContent: "center", children: (0, jsx_runtime_1.jsx)(Button_1.Button, { variant: "fillLight", icon: (0, jsx_runtime_1.jsx)(svgs_1.LinkIcon, {}), children: "left icon" }) }), (0, jsx_runtime_1.jsx)(Button_1.Button, { icon: (0, jsx_runtime_1.jsx)(svgs_1.LinkIcon, { fill: "white100" }), iconPosition: "right", children: "right icon" }), (0, jsx_runtime_1.jsx)(Button_1.Button, { size: "small", icon: (0, jsx_runtime_1.jsx)(svgs_1.LinkIcon, { fill: "white100" }), iconPosition: "right", children: "Right Icon Small" }), (0, jsx_runtime_1.jsx)(Button_1.Button, { variant: "fillDark", size: "small", icon: (0, jsx_runtime_1.jsx)(svgs_1.BellIcon, { fill: "white100", width: "16px", height: "16px" }), children: "Create Alert" }), (0, jsx_runtime_1.jsxs)(Box_1.Box, { flexDirection: "row", children: [(0, jsx_runtime_1.jsx)(Box_1.Box, { width: 2, height: "100%", backgroundColor: "green100" }), (0, jsx_runtime_1.jsxs)(Box_1.Box, { children: [(0, jsx_runtime_1.jsx)(Button_1.Button, { size: "small", icon: (0, jsx_runtime_1.jsx)(svgs_1.LinkIcon, { fill: "white100" }), iconPosition: "right", longestText: "this is a very long text", children: "shortest text" }), (0, jsx_runtime_1.jsx)(Spacer_1.Spacer, { y: 1 }), (0, jsx_runtime_1.jsx)(Button_1.Button, { size: "small", icon: (0, jsx_runtime_1.jsx)(svgs_1.LinkIcon, { fill: "white100" }), iconPosition: "right", longestText: "this is a very long text", children: "this is a very long text" })] }), (0, jsx_runtime_1.jsx)(Box_1.Box, { width: 2, height: "100%", backgroundColor: "green100" })] }), (0, jsx_runtime_1.jsx)(Button_1.Button, { icon: (0, jsx_runtime_1.jsx)(svgs_1.LinkIcon, { fill: "white100" }), block: true, iconPosition: "left-start", children: "left-start aligned icon" })] }));
57
+ exports.Miscellaneous = Miscellaneous;
58
+ const Playground = () => {
59
+ const [loading, setLoading] = (0, react_1.useState)(false);
60
+ const [disabled, setDisabled] = (0, react_1.useState)(true);
61
+ const [block, setBlock] = (0, react_1.useState)(false);
62
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_native_1.Button, { title: "loading", onPress: () => setLoading((v) => !v) }), (0, jsx_runtime_1.jsx)(react_native_1.Button, { title: "disabled", onPress: () => setDisabled((v) => !v) }), (0, jsx_runtime_1.jsx)(react_native_1.Button, { title: "block", onPress: () => setBlock((v) => !v) }), (0, jsx_runtime_1.jsx)(helpers_1.List, { children: (0, jsx_runtime_1.jsxs)(Button_1.Button, { loading: loading, disabled: disabled, block: block, longestText: "loading false, disabled false, block false", children: ["loading ", loading ? "true" : "false", ", disabled ", disabled ? "true" : "false", ", block", " ", block ? "true" : "false"] }) })] }));
63
+ };
64
+ exports.Playground = Playground;
65
+ const SpacingAround = () => ((0, jsx_runtime_1.jsxs)(Box_1.Box, { children: [(0, jsx_runtime_1.jsx)(Button_1.Button, { m: 2, children: "wow 1" }), (0, jsx_runtime_1.jsx)(Button_1.Button, { children: "wow 2" })] }));
66
+ exports.SpacingAround = SpacingAround;
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { ButtonProps } from "./Button";
3
+ export declare const CTAButton: (props: ButtonProps) => JSX.Element;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CTAButton = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const Button_1 = require("./Button");
6
+ const CTAButton = (props) => (0, jsx_runtime_1.jsx)(Button_1.Button, { block: true, haptic: true, ...props });
7
+ exports.CTAButton = CTAButton;
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ import { ButtonProps } from "../Button";
3
+ type FollowButtonProps = Omit<ButtonProps, "variant" | "size" | "longestText" | "icon" | "children"> & {
4
+ isFollowed: boolean;
5
+ followCount?: number;
6
+ longestText?: string;
7
+ };
8
+ export declare const FollowButton: ({ isFollowed, followCount, longestText, loading, ...restProps }: FollowButtonProps) => JSX.Element;
9
+ export {};
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FollowButton = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const CheckIcon_1 = require("../../svgs/CheckIcon");
6
+ const formatLargeNumber_1 = require("../../utils/formatLargeNumber");
7
+ const Button_1 = require("../Button");
8
+ const Text_1 = require("../Text");
9
+ const FollowButton = ({ isFollowed, followCount, longestText, loading, ...restProps }) => {
10
+ return ((0, jsx_runtime_1.jsx)(Button_1.Button, { variant: isFollowed ? "outline" : "outlineGray", size: "small", longestText: longestText ? longestText : "Following", icon: isFollowed && !loading && (0, jsx_runtime_1.jsx)(CheckIcon_1.CheckIcon, { fill: "black60", width: "16px", height: "16px" }), loading: loading, ...restProps, children: !loading && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Text_1.Text, { variant: "xs", children: isFollowed ? "Following" : "Follow" }), !!followCount && followCount > 1 && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(Text_1.Text, { variant: "xs", color: "black60", children: " " + (0, formatLargeNumber_1.formatLargeNumber)(followCount, 1) }) }))] })) }));
11
+ };
12
+ exports.FollowButton = FollowButton;
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { TextProps } from "../Text";
3
+ export declare const LinkButton: (props: TextProps) => JSX.Element;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LinkButton = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const Text_1 = require("../Text");
6
+ const Touchable_1 = require("../Touchable");
7
+ const LinkButton = (props) => ((0, jsx_runtime_1.jsx)(Touchable_1.Touchable, { onPress: props.onPress, children: (0, jsx_runtime_1.jsx)(Text_1.Text, { underline: true, ...props }) }));
8
+ exports.LinkButton = LinkButton;
@@ -0,0 +1,9 @@
1
+ import { ButtonProps } from "./Button";
2
+ import { NoUndefined } from "../../utils/types";
3
+ type State = "disabled" | "pressed" | "active";
4
+ export declare const useColorsForVariantAndState: () => Record<NoUndefined<ButtonProps["variant"]>, Record<State, {
5
+ bg: string;
6
+ border: string;
7
+ text: string;
8
+ }>>;
9
+ export {};
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useColorsForVariantAndState = void 0;
4
+ const hooks_1 = require("../../utils/hooks");
5
+ const useColorsForVariantAndState = () => {
6
+ const color = (0, hooks_1.useColor)();
7
+ return {
8
+ fillDark: {
9
+ disabled: { bg: color("black30"), border: color("black30"), text: color("onPrimaryHigh") },
10
+ pressed: { bg: color("blue100"), border: color("blue100"), text: color("onPrimaryHigh") },
11
+ active: { bg: color("primary"), border: color("primary"), text: color("onPrimaryHigh") },
12
+ },
13
+ fillLight: {
14
+ disabled: { bg: color("black30"), border: color("black30"), text: color("onPrimaryHigh") },
15
+ pressed: { bg: color("blue100"), border: color("blue100"), text: color("onPrimaryHigh") },
16
+ active: {
17
+ bg: color("white100"),
18
+ border: color("white100"),
19
+ text: color("black100"),
20
+ },
21
+ },
22
+ fillGray: {
23
+ disabled: { bg: color("black30"), border: color("black30"), text: color("white100") },
24
+ pressed: { bg: color("blue100"), border: color("blue100"), text: color("white100") },
25
+ active: { bg: color("black10"), border: color("black10"), text: color("black100") },
26
+ },
27
+ fillSuccess: {
28
+ disabled: { bg: color("blue100"), border: color("blue100"), text: color("white100") },
29
+ pressed: { bg: color("blue100"), border: color("blue100"), text: color("white100") },
30
+ active: { bg: color("blue10"), border: color("blue10"), text: color("white100") },
31
+ },
32
+ outline: {
33
+ disabled: {
34
+ bg: color("background"),
35
+ border: color("onBackgroundLow"),
36
+ text: color("onBackgroundLow"),
37
+ },
38
+ pressed: { bg: color("blue100"), border: color("blue100"), text: color("white100") },
39
+ active: {
40
+ bg: color("background"),
41
+ border: color("onBackgroundMedium"),
42
+ text: color("onBackgroundHigh"),
43
+ },
44
+ },
45
+ outlineGray: {
46
+ disabled: {
47
+ bg: color("white100"),
48
+ border: color("black30"),
49
+ text: color("black30"),
50
+ },
51
+ pressed: { bg: color("blue100"), border: color("blue100"), text: color("white100") },
52
+ active: {
53
+ bg: color("white100"),
54
+ border: color("black30"),
55
+ text: color("black100"),
56
+ },
57
+ },
58
+ outlineLight: {
59
+ disabled: {
60
+ bg: "rgba(0, 0, 0, 0)",
61
+ border: color("black30"),
62
+ text: color("black30"),
63
+ },
64
+ pressed: { bg: color("blue100"), border: color("blue100"), text: color("white100") },
65
+ active: {
66
+ bg: "rgba(0, 0, 0, 0)",
67
+ border: color("white100"),
68
+ text: color("white100"),
69
+ },
70
+ },
71
+ text: {
72
+ disabled: { bg: "rgba(0, 0, 0, 0)", border: "rgba(0, 0, 0, 0)", text: color("black30") },
73
+ pressed: { bg: color("black10"), border: color("black10"), text: color("blue100") },
74
+ active: { bg: "rgba(0, 0, 0, 0)", border: "rgba(0, 0, 0, 0)", text: color("black100") },
75
+ },
76
+ };
77
+ };
78
+ exports.useColorsForVariantAndState = useColorsForVariantAndState;
@@ -0,0 +1,4 @@
1
+ export * from "./Button";
2
+ export * from "./CTAButton";
3
+ export * from "./FollowButton";
4
+ export * from "./LinkButton";
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./Button"), exports);
18
+ __exportStar(require("./CTAButton"), exports);
19
+ __exportStar(require("./FollowButton"), exports);
20
+ __exportStar(require("./LinkButton"), exports);
@@ -38,5 +38,5 @@ export declare const getInputState: ({ isFocused, value, }: {
38
38
  export declare const getInputVariant: ({ disabled, hasError, }: {
39
39
  disabled: boolean;
40
40
  hasError: boolean;
41
- }) => "default" | "disabled" | "error";
41
+ }) => "default" | "error" | "disabled";
42
42
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@artsy/palette-mobile",
3
- "version": "13.2.31",
3
+ "version": "13.2.32",
4
4
  "description": "Artsy's design system for React Native",
5
5
  "scripts": {
6
6
  "android": "RCT_METRO_PORT=8082 react-native run-android --port 8082",