@artsy/palette-mobile 13.2.26 → 13.2.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/elements/Button/Button.d.ts +9 -13
- package/dist/elements/Button/Button.js +94 -308
- package/dist/elements/Button/Button.stories.d.ts +7 -1
- package/dist/elements/Button/Button.stories.js +29 -8
- package/dist/elements/Button/FollowButton.js +1 -1
- package/dist/elements/Button/colors.js +9 -9
- package/dist/elements/Button/index.d.ts +0 -1
- package/dist/elements/Button/index.js +0 -1
- package/dist/elements/Input/helpers.d.ts +1 -1
- package/dist/elements/Screen/hooks/useListenForScreenScroll.d.ts +1 -1
- package/dist/elements/Screen/index.d.ts +1 -1
- package/package.json +2 -2
- package/dist/elements/Button/LinkButton.d.ts +0 -3
- package/dist/elements/Button/LinkButton.js +0 -8
- package/dist/elements/ButtonNew/Button.d.ts +0 -34
- package/dist/elements/ButtonNew/Button.js +0 -132
- package/dist/elements/ButtonNew/Button.stories.d.ts +0 -18
- package/dist/elements/ButtonNew/Button.stories.js +0 -66
- package/dist/elements/ButtonNew/CTAButton.d.ts +0 -3
- package/dist/elements/ButtonNew/CTAButton.js +0 -7
- package/dist/elements/ButtonNew/FollowButton.d.ts +0 -9
- package/dist/elements/ButtonNew/FollowButton.js +0 -12
- package/dist/elements/ButtonNew/LinkButton.d.ts +0 -3
- package/dist/elements/ButtonNew/LinkButton.js +0 -8
- package/dist/elements/ButtonNew/colors.d.ts +0 -9
- package/dist/elements/ButtonNew/colors.js +0 -78
- package/dist/elements/ButtonNew/index.d.ts +0 -4
- package/dist/elements/ButtonNew/index.js +0 -20
- /package/dist/elements/{ButtonNew → Button}/Button.tests.d.ts +0 -0
- /package/dist/elements/{ButtonNew → Button}/Button.tests.js +0 -0
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { TextVariant } from "@artsy/palette-tokens/dist/typography/v3";
|
|
3
2
|
import { PressableProps } from "react-native";
|
|
4
3
|
import { HapticFeedbackTypes } from "react-native-haptic-feedback";
|
|
5
4
|
import { BoxProps } from "../Box";
|
|
5
|
+
type ButtonSize = "small" | "large";
|
|
6
|
+
type ButtonVariant = "fillDark" | "fillLight" | "fillGray" | "fillSuccess" | "outline" | "outlineGray" | "outlineLight" | "text";
|
|
6
7
|
export interface ButtonProps extends BoxProps {
|
|
7
8
|
children: React.ReactNode;
|
|
8
|
-
size?:
|
|
9
|
-
variant?:
|
|
9
|
+
size?: ButtonSize;
|
|
10
|
+
variant?: ButtonVariant;
|
|
10
11
|
onPress?: PressableProps["onPress"];
|
|
12
|
+
onPressIn?: PressableProps["onPressIn"];
|
|
13
|
+
onPressOut?: PressableProps["onPressOut"];
|
|
11
14
|
icon?: React.ReactNode;
|
|
12
15
|
iconPosition?: "left" | "left-start" | "right";
|
|
13
16
|
/**
|
|
@@ -27,14 +30,7 @@ export interface ButtonProps extends BoxProps {
|
|
|
27
30
|
/** Pass the longest text to the button for the button to keep longest text width */
|
|
28
31
|
longestText?: string;
|
|
29
32
|
/** Used only for tests and stories */
|
|
30
|
-
|
|
31
|
-
textVariant?: TextVariant;
|
|
33
|
+
testOnly_pressed?: PressableProps["testOnly_pressed"];
|
|
32
34
|
}
|
|
33
|
-
declare
|
|
34
|
-
|
|
35
|
-
Disabled = "disabled",
|
|
36
|
-
Loading = "loading",
|
|
37
|
-
Pressed = "pressed"
|
|
38
|
-
}
|
|
39
|
-
export declare const Button: React.FC<ButtonProps>;
|
|
40
|
-
export { DisplayState as _test_DisplayState };
|
|
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 {};
|
|
@@ -1,342 +1,128 @@
|
|
|
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
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
5
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
29
|
+
exports.Button = void 0;
|
|
7
30
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
31
|
const react_1 = require("react");
|
|
9
32
|
const react_native_1 = require("react-native");
|
|
10
33
|
const react_native_haptic_feedback_1 = __importDefault(require("react-native-haptic-feedback"));
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
const native_1 = __importDefault(require("styled-components/native"));
|
|
15
|
-
const hooks_1 = require("../../utils/hooks");
|
|
34
|
+
const react_native_reanimated_1 = __importStar(require("react-native-reanimated"));
|
|
35
|
+
const colors_1 = require("./colors");
|
|
36
|
+
const MeasuredView_1 = require("../../elements/MeasuredView");
|
|
16
37
|
const Box_1 = require("../Box");
|
|
17
|
-
const Flex_1 = require("../Flex
|
|
18
|
-
const MeasuredView_1 = require("../MeasuredView");
|
|
38
|
+
const Flex_1 = require("../Flex");
|
|
19
39
|
const Spacer_1 = require("../Spacer");
|
|
20
40
|
const Spinner_1 = require("../Spinner");
|
|
21
|
-
const Text_1 = require("../Text
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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");
|
|
35
56
|
const [longestTextMeasurements, setLongestTextMeasurements] = (0, react_1.useState)({
|
|
36
57
|
width: 0,
|
|
37
58
|
height: 0,
|
|
38
59
|
});
|
|
39
|
-
const
|
|
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 = () => {
|
|
60
|
+
const height = (() => {
|
|
46
61
|
switch (size) {
|
|
47
62
|
case "small":
|
|
48
|
-
return
|
|
63
|
+
return 30;
|
|
49
64
|
case "large":
|
|
50
|
-
return
|
|
65
|
+
return 50;
|
|
51
66
|
}
|
|
52
|
-
};
|
|
67
|
+
})();
|
|
68
|
+
const spinnerColor = variant === "text" ? "blue100" : "white100";
|
|
53
69
|
const handlePress = (event) => {
|
|
54
70
|
if (onPress === undefined || onPress === null) {
|
|
55
71
|
return;
|
|
56
72
|
}
|
|
57
|
-
if (
|
|
73
|
+
if (disabled || loading) {
|
|
58
74
|
return;
|
|
59
75
|
}
|
|
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
|
-
}
|
|
71
76
|
if (haptic !== undefined) {
|
|
72
77
|
react_native_haptic_feedback_1.default.trigger(haptic === true ? "impactLight" : haptic);
|
|
73
78
|
}
|
|
74
79
|
onPress(event);
|
|
75
80
|
};
|
|
76
|
-
const
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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: (e) => {
|
|
106
|
+
onPressIn?.(e);
|
|
107
|
+
setPressed(true);
|
|
108
|
+
}, onPressOut: (e) => {
|
|
109
|
+
onPressOut?.(e);
|
|
110
|
+
setPressed(false);
|
|
111
|
+
}, 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] })) : 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] }) }) }) }) }));
|
|
100
112
|
};
|
|
101
113
|
exports.Button = Button;
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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;
|
|
114
|
+
const AText = react_native_reanimated_1.default.createAnimatedComponent(Text_1.Text);
|
|
115
|
+
const AFlex = react_native_reanimated_1.default.createAnimatedComponent(Flex_1.Flex);
|
|
116
|
+
const useStateWithProp = (prop) => {
|
|
117
|
+
const [state, setState] = (0, react_1.useState)(!!prop);
|
|
118
|
+
(0, react_1.useEffect)(() => {
|
|
119
|
+
setState(!!prop);
|
|
120
|
+
}, [prop]);
|
|
121
|
+
const stateV = (0, react_native_reanimated_1.useDerivedValue)(() => {
|
|
122
|
+
if (!!state) {
|
|
123
|
+
return 1;
|
|
124
|
+
}
|
|
125
|
+
return 0;
|
|
126
|
+
}, [state]);
|
|
127
|
+
return [state, setState, stateV];
|
|
326
128
|
};
|
|
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,10 +2,16 @@
|
|
|
2
2
|
import { ButtonProps } from "./Button";
|
|
3
3
|
declare const _default: {
|
|
4
4
|
title: string;
|
|
5
|
-
component:
|
|
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;
|
|
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,13 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.VariantsLoading = exports.Variants = exports.States = exports.Sizes = void 0;
|
|
3
|
+
exports.SpacingAround = exports.Playground = exports.Miscellaneous = exports.TheCTAButton = exports.TheFollowButton = exports.VariantsDisabled = 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");
|
|
7
8
|
const Button_1 = require("./Button");
|
|
9
|
+
const CTAButton_1 = require("./CTAButton");
|
|
10
|
+
const FollowButton_1 = require("./FollowButton");
|
|
8
11
|
const helpers_1 = require("../../storybook/helpers");
|
|
12
|
+
const svgs_1 = require("../../svgs");
|
|
9
13
|
const Wrap_1 = require("../../utils/Wrap");
|
|
14
|
+
const Box_1 = require("../Box");
|
|
10
15
|
const Flex_1 = require("../Flex");
|
|
16
|
+
const Spacer_1 = require("../Spacer");
|
|
11
17
|
const Text_1 = require("../Text");
|
|
12
18
|
const sizes = ["small", "large"];
|
|
13
19
|
const variants = [
|
|
@@ -28,15 +34,30 @@ const Sizes = () => ((0, jsx_runtime_1.jsx)(helpers_1.DataList, { data: sizes, r
|
|
|
28
34
|
exports.Sizes = Sizes;
|
|
29
35
|
const States = () => {
|
|
30
36
|
const [variant, setVariant] = (0, react_1.useState)("fillDark");
|
|
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" })] }));
|
|
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" })] }));
|
|
32
38
|
};
|
|
33
39
|
exports.States = States;
|
|
34
40
|
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 }) }) }) })) }));
|
|
35
41
|
exports.Variants = Variants;
|
|
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
|
-
} }));
|
|
42
|
+
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 })) }));
|
|
42
43
|
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, { 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,6 +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
|
-
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)(
|
|
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)(Text_1.Text, { variant: "xs", color: "black60", children: " " + (0, formatLargeNumber_1.formatLargeNumber)(followCount, 1) }))] })) }));
|
|
11
11
|
};
|
|
12
12
|
exports.FollowButton = FollowButton;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useColorsForVariantAndState = void 0;
|
|
4
|
-
const
|
|
4
|
+
const hooks_1 = require("../../utils/hooks");
|
|
5
5
|
const useColorsForVariantAndState = () => {
|
|
6
|
-
const color = (0,
|
|
6
|
+
const color = (0, hooks_1.useColor)();
|
|
7
7
|
return {
|
|
8
8
|
fillDark: {
|
|
9
9
|
disabled: { bg: color("black30"), border: color("black30"), text: color("onPrimaryHigh") },
|
|
@@ -31,15 +31,15 @@ const useColorsForVariantAndState = () => {
|
|
|
31
31
|
},
|
|
32
32
|
outline: {
|
|
33
33
|
disabled: {
|
|
34
|
-
bg: color("
|
|
35
|
-
border: color("
|
|
36
|
-
text: color("
|
|
34
|
+
bg: color("white100"),
|
|
35
|
+
border: color("black100"),
|
|
36
|
+
text: color("black100"),
|
|
37
37
|
},
|
|
38
38
|
pressed: { bg: color("blue100"), border: color("blue100"), text: color("white100") },
|
|
39
39
|
active: {
|
|
40
|
-
bg: color("
|
|
41
|
-
border: color("
|
|
42
|
-
text: color("
|
|
40
|
+
bg: color("white100"),
|
|
41
|
+
border: color("black60"),
|
|
42
|
+
text: color("black100"),
|
|
43
43
|
},
|
|
44
44
|
},
|
|
45
45
|
outlineGray: {
|
|
@@ -51,7 +51,7 @@ const useColorsForVariantAndState = () => {
|
|
|
51
51
|
pressed: { bg: color("blue100"), border: color("blue100"), text: color("white100") },
|
|
52
52
|
active: {
|
|
53
53
|
bg: color("white100"),
|
|
54
|
-
border: color("
|
|
54
|
+
border: color("black60"),
|
|
55
55
|
text: color("black100"),
|
|
56
56
|
},
|
|
57
57
|
},
|
|
@@ -16,5 +16,4 @@ 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);
|
|
20
19
|
__exportStar(require("./FollowButton"), 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" | "
|
|
41
|
+
}) => "default" | "disabled" | "error";
|
|
42
42
|
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export declare const useListenForScreenScroll: () => {
|
|
2
|
-
scrollHandler:
|
|
2
|
+
scrollHandler: import("react-native-reanimated").ScrollHandlerProcessed<Record<string, unknown>>;
|
|
3
3
|
};
|
|
@@ -19,7 +19,7 @@ export declare const Screen: import("react").FC<import("./ScreenBase").ScreenBas
|
|
|
19
19
|
ScrollView: import("react").FC<import("react-native/types").ScrollViewProps>;
|
|
20
20
|
StickySubHeader: import("react").FC<import("./StickySubHeader").StickySubHeaderProps>;
|
|
21
21
|
useListenForScreenScroll: () => {
|
|
22
|
-
scrollHandler:
|
|
22
|
+
scrollHandler: import("react-native-reanimated").ScrollHandlerProcessed<Record<string, unknown>>;
|
|
23
23
|
};
|
|
24
24
|
useScreenScrollContext: () => import("./ScreenScrollContext").ScreenScrollContextProps;
|
|
25
25
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@artsy/palette-mobile",
|
|
3
|
-
"version": "13.2.
|
|
3
|
+
"version": "13.2.28",
|
|
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",
|
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
"react-native-flipper": "0.178.1",
|
|
125
125
|
"react-native-haptic-feedback": "1.14.0",
|
|
126
126
|
"react-native-linear-gradient": "2.6.2",
|
|
127
|
-
"react-native-reanimated": "
|
|
127
|
+
"react-native-reanimated": "3.6.3",
|
|
128
128
|
"react-native-safe-area-context": "4.5.0",
|
|
129
129
|
"react-native-svg": "14.1.0",
|
|
130
130
|
"react-test-renderer": "18.2.0",
|
|
@@ -1,8 +0,0 @@
|
|
|
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,34 +0,0 @@
|
|
|
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 {};
|
|
@@ -1,132 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
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;
|
|
@@ -1,66 +0,0 @@
|
|
|
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;
|
|
@@ -1,7 +0,0 @@
|
|
|
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;
|
|
@@ -1,9 +0,0 @@
|
|
|
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 {};
|
|
@@ -1,12 +0,0 @@
|
|
|
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;
|
|
@@ -1,8 +0,0 @@
|
|
|
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,9 +0,0 @@
|
|
|
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 {};
|
|
@@ -1,78 +0,0 @@
|
|
|
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;
|
|
@@ -1,20 +0,0 @@
|
|
|
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);
|
|
File without changes
|
|
File without changes
|