@pagopa/io-app-design-system 5.11.13-0 → 5.11.14
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/lib/commonjs/components/banner/BannerErrorState.js +3 -2
- package/lib/commonjs/components/banner/BannerErrorState.js.map +1 -1
- package/lib/commonjs/components/buttons/__test__/button.test.js +13 -9
- package/lib/commonjs/components/buttons/__test__/button.test.js.map +1 -1
- package/lib/commonjs/components/buttons/index.js +0 -33
- package/lib/commonjs/components/buttons/index.js.map +1 -1
- package/lib/commonjs/components/listitems/ListItemHeader.js +2 -1
- package/lib/commonjs/components/listitems/ListItemHeader.js.map +1 -1
- package/lib/commonjs/components/listitems/ListItemInfo.js +2 -1
- package/lib/commonjs/components/listitems/ListItemInfo.js.map +1 -1
- package/lib/commonjs/components/modules/ModuleCheckout.js +2 -1
- package/lib/commonjs/components/modules/ModuleCheckout.js.map +1 -1
- package/lib/commonjs/components/otpInput/BoxedInput.js +6 -2
- package/lib/commonjs/components/otpInput/BoxedInput.js.map +1 -1
- package/lib/commonjs/components/otpInput/OTPInput.js +3 -1
- package/lib/commonjs/components/otpInput/OTPInput.js.map +1 -1
- package/lib/commonjs/components/pictograms/Pictogram.js +2 -0
- package/lib/commonjs/components/pictograms/Pictogram.js.map +1 -1
- package/lib/commonjs/components/pictograms/svg/PictogramPinSecurity.js +64 -0
- package/lib/commonjs/components/pictograms/svg/PictogramPinSecurity.js.map +1 -0
- package/lib/commonjs/components/pictograms/svg/originals/PictogramPinSecurity.svg +1 -0
- package/lib/commonjs/components/toast/ToastProvider.js +1 -5
- package/lib/commonjs/components/toast/ToastProvider.js.map +1 -1
- package/lib/module/components/banner/BannerErrorState.js +3 -2
- package/lib/module/components/banner/BannerErrorState.js.map +1 -1
- package/lib/module/components/buttons/__test__/button.test.js +13 -9
- package/lib/module/components/buttons/__test__/button.test.js.map +1 -1
- package/lib/module/components/buttons/index.js +0 -3
- package/lib/module/components/buttons/index.js.map +1 -1
- package/lib/module/components/listitems/ListItemHeader.js +3 -2
- package/lib/module/components/listitems/ListItemHeader.js.map +1 -1
- package/lib/module/components/listitems/ListItemInfo.js +3 -2
- package/lib/module/components/listitems/ListItemInfo.js.map +1 -1
- package/lib/module/components/modules/ModuleCheckout.js +3 -2
- package/lib/module/components/modules/ModuleCheckout.js.map +1 -1
- package/lib/module/components/otpInput/BoxedInput.js +6 -2
- package/lib/module/components/otpInput/BoxedInput.js.map +1 -1
- package/lib/module/components/otpInput/OTPInput.js +3 -1
- package/lib/module/components/otpInput/OTPInput.js.map +1 -1
- package/lib/module/components/pictograms/Pictogram.js +2 -0
- package/lib/module/components/pictograms/Pictogram.js.map +1 -1
- package/lib/module/components/pictograms/svg/PictogramPinSecurity.js +59 -0
- package/lib/module/components/pictograms/svg/PictogramPinSecurity.js.map +1 -0
- package/lib/module/components/pictograms/svg/originals/PictogramPinSecurity.svg +1 -0
- package/lib/module/components/toast/ToastProvider.js +2 -6
- package/lib/module/components/toast/ToastProvider.js.map +1 -1
- package/lib/typescript/components/banner/BannerErrorState.d.ts.map +1 -1
- package/lib/typescript/components/buttons/index.d.ts +0 -3
- package/lib/typescript/components/buttons/index.d.ts.map +1 -1
- package/lib/typescript/components/listitems/ListItemHeader.d.ts +2 -2
- package/lib/typescript/components/listitems/ListItemHeader.d.ts.map +1 -1
- package/lib/typescript/components/listitems/ListItemInfo.d.ts +2 -2
- package/lib/typescript/components/listitems/ListItemInfo.d.ts.map +1 -1
- package/lib/typescript/components/otpInput/BoxedInput.d.ts.map +1 -1
- package/lib/typescript/components/otpInput/OTPInput.d.ts.map +1 -1
- package/lib/typescript/components/pictograms/Pictogram.d.ts +1 -0
- package/lib/typescript/components/pictograms/Pictogram.d.ts.map +1 -1
- package/lib/typescript/components/pictograms/svg/PictogramPinSecurity.d.ts +5 -0
- package/lib/typescript/components/pictograms/svg/PictogramPinSecurity.d.ts.map +1 -0
- package/lib/typescript/components/toast/ToastProvider.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/banner/BannerErrorState.tsx +7 -2
- package/src/components/buttons/__test__/button.test.tsx +15 -13
- package/src/components/buttons/index.tsx +0 -3
- package/src/components/listitems/ListItemHeader.tsx +3 -3
- package/src/components/listitems/ListItemInfo.tsx +4 -3
- package/src/components/modules/ModuleCheckout.tsx +2 -2
- package/src/components/otpInput/BoxedInput.tsx +7 -2
- package/src/components/otpInput/OTPInput.tsx +7 -1
- package/src/components/pictograms/Pictogram.tsx +2 -0
- package/src/components/pictograms/svg/PictogramPinSecurity.tsx +44 -0
- package/src/components/pictograms/svg/originals/PictogramPinSecurity.svg +1 -0
- package/src/components/toast/ToastProvider.tsx +1 -13
- package/lib/commonjs/components/buttons/ButtonLink.js +0 -157
- package/lib/commonjs/components/buttons/ButtonLink.js.map +0 -1
- package/lib/commonjs/components/buttons/ButtonOutline.js +0 -173
- package/lib/commonjs/components/buttons/ButtonOutline.js.map +0 -1
- package/lib/commonjs/components/buttons/ButtonSolid.js +0 -194
- package/lib/commonjs/components/buttons/ButtonSolid.js.map +0 -1
- package/lib/module/components/buttons/ButtonLink.js +0 -152
- package/lib/module/components/buttons/ButtonLink.js.map +0 -1
- package/lib/module/components/buttons/ButtonOutline.js +0 -168
- package/lib/module/components/buttons/ButtonOutline.js.map +0 -1
- package/lib/module/components/buttons/ButtonSolid.js +0 -188
- package/lib/module/components/buttons/ButtonSolid.js.map +0 -1
- package/lib/typescript/components/buttons/ButtonLink.d.ts +0 -36
- package/lib/typescript/components/buttons/ButtonLink.d.ts.map +0 -1
- package/lib/typescript/components/buttons/ButtonOutline.d.ts +0 -26
- package/lib/typescript/components/buttons/ButtonOutline.d.ts.map +0 -1
- package/lib/typescript/components/buttons/ButtonSolid.d.ts +0 -52
- package/lib/typescript/components/buttons/ButtonSolid.d.ts.map +0 -1
- package/src/components/buttons/ButtonLink.tsx +0 -222
- package/src/components/buttons/ButtonOutline.tsx +0 -261
- package/src/components/buttons/ButtonSolid.tsx +0 -285
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import React, { ComponentProps } from "react";
|
|
2
|
-
import { GestureResponderEvent, Pressable, View } from "react-native";
|
|
3
|
-
import { WithTestID } from "../../utils/types";
|
|
4
|
-
import { IOIcons } from "../icons";
|
|
5
|
-
export type ButtonSolidColor = "primary" | "danger" | "contrast";
|
|
6
|
-
export type ButtonSolidProps = WithTestID<{
|
|
7
|
-
/**
|
|
8
|
-
* @default primary
|
|
9
|
-
*/
|
|
10
|
-
color?: ButtonSolidColor;
|
|
11
|
-
label: string;
|
|
12
|
-
/**
|
|
13
|
-
* @default false
|
|
14
|
-
*/
|
|
15
|
-
fullWidth?: boolean;
|
|
16
|
-
/**
|
|
17
|
-
* @default false
|
|
18
|
-
*/
|
|
19
|
-
loading?: boolean;
|
|
20
|
-
icon?: IOIcons;
|
|
21
|
-
/**
|
|
22
|
-
* @default start
|
|
23
|
-
*/
|
|
24
|
-
iconPosition?: "start" | "end";
|
|
25
|
-
onPress: (event: GestureResponderEvent) => void;
|
|
26
|
-
} & Pick<ComponentProps<typeof Pressable>, "disabled" | "accessibilityLabel" | "accessibilityHint">>;
|
|
27
|
-
/**
|
|
28
|
-
* @deprecated Use `Button` with variant `solid` instead
|
|
29
|
-
*/
|
|
30
|
-
export declare const ButtonSolid: React.ForwardRefExoticComponent<{
|
|
31
|
-
/**
|
|
32
|
-
* @default primary
|
|
33
|
-
*/
|
|
34
|
-
color?: ButtonSolidColor;
|
|
35
|
-
label: string;
|
|
36
|
-
/**
|
|
37
|
-
* @default false
|
|
38
|
-
*/
|
|
39
|
-
fullWidth?: boolean;
|
|
40
|
-
/**
|
|
41
|
-
* @default false
|
|
42
|
-
*/
|
|
43
|
-
loading?: boolean;
|
|
44
|
-
icon?: IOIcons;
|
|
45
|
-
/**
|
|
46
|
-
* @default start
|
|
47
|
-
*/
|
|
48
|
-
iconPosition?: "start" | "end";
|
|
49
|
-
onPress: (event: GestureResponderEvent) => void;
|
|
50
|
-
} & Pick<import("react-native").PressableProps & React.RefAttributes<View>, "accessibilityLabel" | "accessibilityHint" | "disabled"> & import("../../utils/types").TestID & React.RefAttributes<View>>;
|
|
51
|
-
export default ButtonSolid;
|
|
52
|
-
//# sourceMappingURL=ButtonSolid.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonSolid.d.ts","sourceRoot":"","sources":["../../../../src/components/buttons/ButtonSolid.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EACZ,cAAc,EAKf,MAAM,OAAO,CAAC;AACf,OAAO,EAEL,qBAAqB,EACrB,SAAS,EACT,IAAI,EACL,MAAM,cAAc,CAAC;AAgBtB,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAmB,OAAO,EAAQ,MAAM,UAAU,CAAC;AAI1D,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,QAAQ,GAAG,UAAU,CAAC;AAoBjE,MAAM,MAAM,gBAAgB,GAAG,UAAU,CACvC;IACE;;OAEG;IACH,KAAK,CAAC,EAAE,gBAAgB,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;IAC/B,OAAO,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,IAAI,CAAC;CACjD,GAAG,IAAI,CACN,cAAc,CAAC,OAAO,SAAS,CAAC,EAChC,UAAU,GAAG,oBAAoB,GAAG,mBAAmB,CACxD,CACF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW;IA5BpB;;OAEG;YACK,gBAAgB;WACjB,MAAM;IACb;;OAEG;gBACS,OAAO;IACnB;;OAEG;cACO,OAAO;WACV,OAAO;IACd;;OAEG;mBACY,OAAO,GAAG,KAAK;aACrB,CAAC,KAAK,EAAE,qBAAqB,KAAK,IAAI;sMAiNlD,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef } from "react";
|
|
2
|
-
import {
|
|
3
|
-
AccessibilityRole,
|
|
4
|
-
GestureResponderEvent,
|
|
5
|
-
Pressable,
|
|
6
|
-
TextStyle,
|
|
7
|
-
View
|
|
8
|
-
} from "react-native";
|
|
9
|
-
import Animated, {
|
|
10
|
-
interpolateColor,
|
|
11
|
-
useAnimatedProps,
|
|
12
|
-
useAnimatedStyle,
|
|
13
|
-
useReducedMotion
|
|
14
|
-
} from "react-native-reanimated";
|
|
15
|
-
import { useIONewTypeface, useIOTheme } from "../../context";
|
|
16
|
-
import {
|
|
17
|
-
IOButtonStyles,
|
|
18
|
-
IOColors,
|
|
19
|
-
IOSpacingScale,
|
|
20
|
-
hexToRgba
|
|
21
|
-
} from "../../core";
|
|
22
|
-
import { useScaleAnimation } from "../../hooks";
|
|
23
|
-
import { WithTestID } from "../../utils/types";
|
|
24
|
-
import {
|
|
25
|
-
AnimatedIcon,
|
|
26
|
-
AnimatedIconWithColorTransition,
|
|
27
|
-
IOIconSizeScale,
|
|
28
|
-
IOIcons
|
|
29
|
-
} from "../icons";
|
|
30
|
-
import {
|
|
31
|
-
IOText,
|
|
32
|
-
buttonTextFontSize,
|
|
33
|
-
buttonTextLineHeight
|
|
34
|
-
} from "../typography";
|
|
35
|
-
|
|
36
|
-
export type ColorButtonLink = "primary" | "contrast";
|
|
37
|
-
|
|
38
|
-
export type ButtonLinkProps = WithTestID<{
|
|
39
|
-
color?: ColorButtonLink;
|
|
40
|
-
label: string;
|
|
41
|
-
disabled?: boolean;
|
|
42
|
-
// Icons
|
|
43
|
-
icon?: IOIcons;
|
|
44
|
-
iconPosition?: "start" | "end";
|
|
45
|
-
// Accessibility
|
|
46
|
-
accessibilityLabel?: string;
|
|
47
|
-
accessibilityRole?: Extract<AccessibilityRole, "button" | "link">;
|
|
48
|
-
accessibilityHint?: string;
|
|
49
|
-
numberOfLines?: number;
|
|
50
|
-
textAlign?: TextStyle["textAlign"];
|
|
51
|
-
// Events
|
|
52
|
-
onPress: (event: GestureResponderEvent) => void;
|
|
53
|
-
}>;
|
|
54
|
-
|
|
55
|
-
type ColorStates = {
|
|
56
|
-
foreground: {
|
|
57
|
-
default: string;
|
|
58
|
-
pressed: string;
|
|
59
|
-
disabled: string;
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const DISABLED_OPACITY = 0.5;
|
|
64
|
-
const ICON_MARGIN = 8;
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* @deprecated Use `Button` with variant `link` instead
|
|
68
|
-
*/
|
|
69
|
-
export const ButtonLink = forwardRef<View, ButtonLinkProps>(
|
|
70
|
-
(
|
|
71
|
-
{
|
|
72
|
-
color = "primary",
|
|
73
|
-
label,
|
|
74
|
-
disabled = false,
|
|
75
|
-
icon,
|
|
76
|
-
iconPosition = "start",
|
|
77
|
-
onPress,
|
|
78
|
-
accessibilityLabel,
|
|
79
|
-
accessibilityRole = "button",
|
|
80
|
-
accessibilityHint,
|
|
81
|
-
numberOfLines = 1,
|
|
82
|
-
textAlign = "auto",
|
|
83
|
-
testID
|
|
84
|
-
},
|
|
85
|
-
ref
|
|
86
|
-
) => {
|
|
87
|
-
const theme = useIOTheme();
|
|
88
|
-
const { newTypefaceEnabled } = useIONewTypeface();
|
|
89
|
-
const { progress, onPressIn, onPressOut, scaleAnimatedStyle } =
|
|
90
|
-
useScaleAnimation();
|
|
91
|
-
const reducedMotion = useReducedMotion();
|
|
92
|
-
|
|
93
|
-
const mapColorStates: Record<
|
|
94
|
-
NonNullable<ButtonLinkProps["color"]>,
|
|
95
|
-
ColorStates
|
|
96
|
-
> = {
|
|
97
|
-
// Primary button
|
|
98
|
-
primary: {
|
|
99
|
-
foreground: {
|
|
100
|
-
default: IOColors[theme["interactiveElem-default"]],
|
|
101
|
-
pressed: IOColors[theme["interactiveElem-pressed"]],
|
|
102
|
-
disabled: hexToRgba(IOColors[theme["interactiveElem-default"]], 0.85)
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
contrast: {
|
|
106
|
-
foreground: {
|
|
107
|
-
default: IOColors.white,
|
|
108
|
-
pressed: hexToRgba(IOColors.white, 0.85),
|
|
109
|
-
disabled: hexToRgba(IOColors.white, 0.5)
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
const AnimatedIOText = Animated.createAnimatedComponent(IOText);
|
|
115
|
-
|
|
116
|
-
const pressedColorLabelAnimationStyle = useAnimatedStyle(() => {
|
|
117
|
-
// Link color states to the pressed states
|
|
118
|
-
|
|
119
|
-
const labelColor = interpolateColor(
|
|
120
|
-
progress.value,
|
|
121
|
-
[0, 1],
|
|
122
|
-
[
|
|
123
|
-
mapColorStates[color].foreground.default,
|
|
124
|
-
mapColorStates[color].foreground.pressed
|
|
125
|
-
]
|
|
126
|
-
);
|
|
127
|
-
|
|
128
|
-
return {
|
|
129
|
-
color: labelColor
|
|
130
|
-
};
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
// Animate the <Icon> color prop
|
|
134
|
-
const pressedColorIconAnimationStyle = useAnimatedProps(() => {
|
|
135
|
-
const iconColor = interpolateColor(
|
|
136
|
-
progress.value,
|
|
137
|
-
[0, 1],
|
|
138
|
-
[
|
|
139
|
-
mapColorStates[color].foreground.default,
|
|
140
|
-
mapColorStates[color].foreground.pressed
|
|
141
|
-
]
|
|
142
|
-
);
|
|
143
|
-
|
|
144
|
-
return { color: iconColor };
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
// Icon size
|
|
148
|
-
const iconSize: IOIconSizeScale = 24;
|
|
149
|
-
const iconMargin: IOSpacingScale = 8;
|
|
150
|
-
|
|
151
|
-
return (
|
|
152
|
-
<Pressable
|
|
153
|
-
ref={ref}
|
|
154
|
-
accessibilityLabel={accessibilityLabel || label}
|
|
155
|
-
accessibilityHint={accessibilityHint}
|
|
156
|
-
accessibilityRole={accessibilityRole}
|
|
157
|
-
accessibilityState={{ disabled }}
|
|
158
|
-
testID={testID}
|
|
159
|
-
onPress={onPress}
|
|
160
|
-
onPressIn={onPressIn}
|
|
161
|
-
onPressOut={onPressOut}
|
|
162
|
-
onTouchEnd={onPressOut}
|
|
163
|
-
accessible={true}
|
|
164
|
-
disabled={disabled}
|
|
165
|
-
hitSlop={{ top: 14, right: 24, bottom: 14, left: 24 }}
|
|
166
|
-
style={{ alignSelf: "flex-start" }}
|
|
167
|
-
>
|
|
168
|
-
<Animated.View
|
|
169
|
-
style={[
|
|
170
|
-
IOButtonStyles.buttonLink,
|
|
171
|
-
iconPosition === "end" && { flexDirection: "row-reverse" },
|
|
172
|
-
{ columnGap: iconMargin },
|
|
173
|
-
disabled ? { opacity: DISABLED_OPACITY } : {},
|
|
174
|
-
{ columnGap: ICON_MARGIN },
|
|
175
|
-
/* Prevent Reanimated from overriding background colors
|
|
176
|
-
if button is disabled */
|
|
177
|
-
!disabled && !reducedMotion && scaleAnimatedStyle
|
|
178
|
-
]}
|
|
179
|
-
>
|
|
180
|
-
{icon &&
|
|
181
|
-
(!disabled ? (
|
|
182
|
-
<AnimatedIconWithColorTransition
|
|
183
|
-
allowFontScaling
|
|
184
|
-
name={icon}
|
|
185
|
-
animatedProps={pressedColorIconAnimationStyle}
|
|
186
|
-
color={mapColorStates[color]?.foreground?.default}
|
|
187
|
-
size={iconSize}
|
|
188
|
-
/>
|
|
189
|
-
) : (
|
|
190
|
-
<AnimatedIcon
|
|
191
|
-
allowFontScaling
|
|
192
|
-
name={icon}
|
|
193
|
-
color={mapColorStates[color]?.foreground?.disabled}
|
|
194
|
-
size={iconSize}
|
|
195
|
-
/>
|
|
196
|
-
))}
|
|
197
|
-
<AnimatedIOText
|
|
198
|
-
accessible={false}
|
|
199
|
-
accessibilityElementsHidden
|
|
200
|
-
importantForAccessibility="no-hide-descendants"
|
|
201
|
-
font={newTypefaceEnabled ? "Titillio" : "TitilliumSansPro"}
|
|
202
|
-
weight={"Semibold"}
|
|
203
|
-
size={buttonTextFontSize}
|
|
204
|
-
lineHeight={buttonTextLineHeight}
|
|
205
|
-
style={[
|
|
206
|
-
disabled
|
|
207
|
-
? { color: mapColorStates[color]?.foreground?.disabled }
|
|
208
|
-
: { ...pressedColorLabelAnimationStyle },
|
|
209
|
-
{ textAlign }
|
|
210
|
-
]}
|
|
211
|
-
numberOfLines={numberOfLines}
|
|
212
|
-
ellipsizeMode="tail"
|
|
213
|
-
>
|
|
214
|
-
{label}
|
|
215
|
-
</AnimatedIOText>
|
|
216
|
-
</Animated.View>
|
|
217
|
-
</Pressable>
|
|
218
|
-
);
|
|
219
|
-
}
|
|
220
|
-
);
|
|
221
|
-
|
|
222
|
-
export default ButtonLink;
|
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
import React, { ComponentProps, forwardRef } from "react";
|
|
2
|
-
import {
|
|
3
|
-
GestureResponderEvent,
|
|
4
|
-
Pressable,
|
|
5
|
-
StyleSheet,
|
|
6
|
-
View
|
|
7
|
-
} from "react-native";
|
|
8
|
-
import Animated, {
|
|
9
|
-
interpolateColor,
|
|
10
|
-
useAnimatedProps,
|
|
11
|
-
useAnimatedStyle,
|
|
12
|
-
useReducedMotion
|
|
13
|
-
} from "react-native-reanimated";
|
|
14
|
-
import { useIONewTypeface, useIOTheme } from "../../context";
|
|
15
|
-
import { IOButtonStyles, IOColors, hexToRgba } from "../../core/";
|
|
16
|
-
import { useScaleAnimation } from "../../hooks";
|
|
17
|
-
import { WithTestID } from "../../utils/types";
|
|
18
|
-
import {
|
|
19
|
-
AnimatedIcon,
|
|
20
|
-
AnimatedIconWithColorTransition,
|
|
21
|
-
IOIconSizeScale,
|
|
22
|
-
IOIcons
|
|
23
|
-
} from "../icons";
|
|
24
|
-
import { IOText, buttonTextFontSize } from "../typography";
|
|
25
|
-
|
|
26
|
-
type ColorButtonOutline = "primary" | "contrast";
|
|
27
|
-
export type ButtonOutline = WithTestID<
|
|
28
|
-
{
|
|
29
|
-
color?: ColorButtonOutline;
|
|
30
|
-
label: string;
|
|
31
|
-
fullWidth?: boolean;
|
|
32
|
-
// Icons
|
|
33
|
-
icon?: IOIcons;
|
|
34
|
-
iconPosition?: "start" | "end";
|
|
35
|
-
// Events
|
|
36
|
-
onPress: (event: GestureResponderEvent) => void;
|
|
37
|
-
} & Pick<
|
|
38
|
-
ComponentProps<typeof Pressable>,
|
|
39
|
-
"disabled" | "accessibilityLabel" | "accessibilityHint"
|
|
40
|
-
>
|
|
41
|
-
>;
|
|
42
|
-
|
|
43
|
-
type ColorStates = {
|
|
44
|
-
background: {
|
|
45
|
-
default: string;
|
|
46
|
-
pressed: string;
|
|
47
|
-
disabled: string;
|
|
48
|
-
};
|
|
49
|
-
foreground: {
|
|
50
|
-
default: string;
|
|
51
|
-
pressed: string;
|
|
52
|
-
disabled: string;
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
// Icon size
|
|
57
|
-
const iconSize: IOIconSizeScale = 20;
|
|
58
|
-
|
|
59
|
-
const DISABLED_OPACITY = 0.5;
|
|
60
|
-
const ICON_MARGIN = 8;
|
|
61
|
-
|
|
62
|
-
const IOButtonStylesLocal = StyleSheet.create({
|
|
63
|
-
buttonWithBorder: {
|
|
64
|
-
borderWidth: 2
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* @deprecated Use `Button` with variant `outline` instead
|
|
70
|
-
*/
|
|
71
|
-
export const ButtonOutline = forwardRef<View, ButtonOutline>(
|
|
72
|
-
(
|
|
73
|
-
{
|
|
74
|
-
color = "primary",
|
|
75
|
-
label,
|
|
76
|
-
fullWidth = false,
|
|
77
|
-
disabled = false,
|
|
78
|
-
icon,
|
|
79
|
-
iconPosition = "start",
|
|
80
|
-
onPress,
|
|
81
|
-
accessibilityLabel,
|
|
82
|
-
accessibilityHint,
|
|
83
|
-
testID
|
|
84
|
-
},
|
|
85
|
-
ref
|
|
86
|
-
) => {
|
|
87
|
-
const theme = useIOTheme();
|
|
88
|
-
const { newTypefaceEnabled } = useIONewTypeface();
|
|
89
|
-
const { progress, onPressIn, onPressOut, scaleAnimatedStyle } =
|
|
90
|
-
useScaleAnimation();
|
|
91
|
-
const reducedMotion = useReducedMotion();
|
|
92
|
-
|
|
93
|
-
const AnimatedIOText = Animated.createAnimatedComponent(IOText);
|
|
94
|
-
|
|
95
|
-
const mapColorStates: Record<
|
|
96
|
-
NonNullable<ButtonOutline["color"]>,
|
|
97
|
-
ColorStates
|
|
98
|
-
> = {
|
|
99
|
-
// Primary button
|
|
100
|
-
primary: {
|
|
101
|
-
background: {
|
|
102
|
-
default: hexToRgba(IOColors[theme["interactiveElem-pressed"]], 0),
|
|
103
|
-
pressed: hexToRgba(IOColors[theme["interactiveElem-pressed"]], 0.1),
|
|
104
|
-
disabled: "transparent"
|
|
105
|
-
},
|
|
106
|
-
foreground: {
|
|
107
|
-
default: IOColors[theme["interactiveElem-default"]],
|
|
108
|
-
pressed: IOColors[theme["interactiveElem-pressed"]],
|
|
109
|
-
disabled: IOColors[theme["interactiveOutline-disabled"]]
|
|
110
|
-
}
|
|
111
|
-
},
|
|
112
|
-
// Contrast button
|
|
113
|
-
contrast: {
|
|
114
|
-
background: {
|
|
115
|
-
default: hexToRgba(IOColors["blueIO-600"], 0),
|
|
116
|
-
pressed: hexToRgba(IOColors["blueIO-600"], 0.5),
|
|
117
|
-
disabled: "transparent"
|
|
118
|
-
},
|
|
119
|
-
foreground: {
|
|
120
|
-
default: IOColors.white,
|
|
121
|
-
pressed: IOColors.white,
|
|
122
|
-
disabled: IOColors["blueIO-200"]
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
// Interpolate animation values from `isPressed` values
|
|
128
|
-
const pressedAnimationStyle = useAnimatedStyle(() => {
|
|
129
|
-
// Link color states to the pressed states
|
|
130
|
-
const backgroundColor = interpolateColor(
|
|
131
|
-
progress.value,
|
|
132
|
-
[0, 1],
|
|
133
|
-
[
|
|
134
|
-
mapColorStates[color].background.default,
|
|
135
|
-
mapColorStates[color].background.pressed
|
|
136
|
-
]
|
|
137
|
-
);
|
|
138
|
-
|
|
139
|
-
const borderColor = interpolateColor(
|
|
140
|
-
progress.value,
|
|
141
|
-
[0, 1],
|
|
142
|
-
[
|
|
143
|
-
mapColorStates[color].foreground.default,
|
|
144
|
-
mapColorStates[color].foreground.pressed
|
|
145
|
-
]
|
|
146
|
-
);
|
|
147
|
-
|
|
148
|
-
return {
|
|
149
|
-
borderColor,
|
|
150
|
-
backgroundColor
|
|
151
|
-
};
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
const pressedColorLabelAnimationStyle = useAnimatedStyle(() => ({
|
|
155
|
-
color: interpolateColor(
|
|
156
|
-
progress.value,
|
|
157
|
-
[0, 1],
|
|
158
|
-
[
|
|
159
|
-
mapColorStates[color].foreground.default,
|
|
160
|
-
mapColorStates[color].foreground.pressed
|
|
161
|
-
]
|
|
162
|
-
)
|
|
163
|
-
}));
|
|
164
|
-
|
|
165
|
-
// Animate the <Icon> color prop
|
|
166
|
-
const pressedColorIconAnimationStyle = useAnimatedProps(() => ({
|
|
167
|
-
color: interpolateColor(
|
|
168
|
-
progress.value,
|
|
169
|
-
[0, 1],
|
|
170
|
-
[
|
|
171
|
-
mapColorStates[color].foreground.default,
|
|
172
|
-
mapColorStates[color].foreground.pressed
|
|
173
|
-
]
|
|
174
|
-
)
|
|
175
|
-
}));
|
|
176
|
-
|
|
177
|
-
return (
|
|
178
|
-
<Pressable
|
|
179
|
-
ref={ref}
|
|
180
|
-
accessible={true}
|
|
181
|
-
accessibilityLabel={accessibilityLabel || label}
|
|
182
|
-
accessibilityHint={accessibilityHint}
|
|
183
|
-
accessibilityRole={"button"}
|
|
184
|
-
accessibilityState={{ disabled: disabled || false }}
|
|
185
|
-
onPress={onPress}
|
|
186
|
-
onPressIn={onPressIn}
|
|
187
|
-
onPressOut={onPressOut}
|
|
188
|
-
disabled={disabled}
|
|
189
|
-
style={
|
|
190
|
-
fullWidth
|
|
191
|
-
? { flexShrink: 0, alignSelf: "stretch" }
|
|
192
|
-
: { flexShrink: 1, alignSelf: "auto" }
|
|
193
|
-
}
|
|
194
|
-
testID={testID}
|
|
195
|
-
>
|
|
196
|
-
<Animated.View
|
|
197
|
-
style={[
|
|
198
|
-
IOButtonStyles.button,
|
|
199
|
-
IOButtonStyles.buttonSizeDefault,
|
|
200
|
-
IOButtonStylesLocal.buttonWithBorder,
|
|
201
|
-
fullWidth && { paddingHorizontal: 16 },
|
|
202
|
-
{ columnGap: ICON_MARGIN },
|
|
203
|
-
iconPosition === "end" && { flexDirection: "row-reverse" },
|
|
204
|
-
disabled
|
|
205
|
-
? {
|
|
206
|
-
backgroundColor: mapColorStates[color]?.background?.disabled,
|
|
207
|
-
borderColor: mapColorStates[color]?.foreground?.disabled,
|
|
208
|
-
opacity: DISABLED_OPACITY
|
|
209
|
-
}
|
|
210
|
-
: {
|
|
211
|
-
backgroundColor: mapColorStates[color]?.background?.default,
|
|
212
|
-
borderColor: mapColorStates[color]?.foreground.default
|
|
213
|
-
},
|
|
214
|
-
/* Prevent Reanimated from overriding background colors
|
|
215
|
-
if button is disabled */
|
|
216
|
-
!reducedMotion && !disabled && scaleAnimatedStyle,
|
|
217
|
-
!disabled && pressedAnimationStyle
|
|
218
|
-
]}
|
|
219
|
-
>
|
|
220
|
-
{icon &&
|
|
221
|
-
(!disabled ? (
|
|
222
|
-
<AnimatedIconWithColorTransition
|
|
223
|
-
allowFontScaling
|
|
224
|
-
name={icon}
|
|
225
|
-
animatedProps={pressedColorIconAnimationStyle}
|
|
226
|
-
color={mapColorStates[color]?.foreground?.default}
|
|
227
|
-
size={iconSize}
|
|
228
|
-
/>
|
|
229
|
-
) : (
|
|
230
|
-
<AnimatedIcon
|
|
231
|
-
allowFontScaling
|
|
232
|
-
name={icon}
|
|
233
|
-
color={mapColorStates[color]?.foreground?.disabled}
|
|
234
|
-
size={iconSize}
|
|
235
|
-
/>
|
|
236
|
-
))}
|
|
237
|
-
<AnimatedIOText
|
|
238
|
-
font={newTypefaceEnabled ? "Titillio" : "TitilliumSansPro"}
|
|
239
|
-
weight={"Semibold"}
|
|
240
|
-
size={buttonTextFontSize}
|
|
241
|
-
accessible={false}
|
|
242
|
-
accessibilityElementsHidden
|
|
243
|
-
importantForAccessibility="no-hide-descendants"
|
|
244
|
-
numberOfLines={1}
|
|
245
|
-
ellipsizeMode="tail"
|
|
246
|
-
style={[
|
|
247
|
-
{ alignSelf: "center" },
|
|
248
|
-
disabled
|
|
249
|
-
? { color: mapColorStates[color]?.foreground?.disabled }
|
|
250
|
-
: { ...pressedColorLabelAnimationStyle }
|
|
251
|
-
]}
|
|
252
|
-
>
|
|
253
|
-
{label}
|
|
254
|
-
</AnimatedIOText>
|
|
255
|
-
</Animated.View>
|
|
256
|
-
</Pressable>
|
|
257
|
-
);
|
|
258
|
-
}
|
|
259
|
-
);
|
|
260
|
-
|
|
261
|
-
export default ButtonOutline;
|