@pagopa/io-app-design-system 4.0.1 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/components/alert/Alert.js +34 -7
- package/lib/commonjs/components/alert/Alert.js.map +1 -1
- package/lib/commonjs/components/banner/Banner.js +45 -22
- package/lib/commonjs/components/banner/Banner.js.map +1 -1
- package/lib/commonjs/components/banner/__test__/__snapshots__/banner.test.tsx.snap +48 -190
- package/lib/commonjs/components/featureInfo/FeatureInfo.js +27 -26
- package/lib/commonjs/components/featureInfo/FeatureInfo.js.map +1 -1
- package/lib/commonjs/components/layout/index.js +0 -11
- package/lib/commonjs/components/layout/index.js.map +1 -1
- package/lib/commonjs/components/spacer/Spacer.js +1 -1
- package/lib/commonjs/components/spacer/Spacer.js.map +1 -1
- package/lib/commonjs/components/stack/Stack.js +17 -14
- package/lib/commonjs/components/stack/Stack.js.map +1 -1
- package/lib/commonjs/core/IOColors.js.map +1 -1
- package/lib/module/components/alert/Alert.js +36 -9
- package/lib/module/components/alert/Alert.js.map +1 -1
- package/lib/module/components/banner/Banner.js +50 -27
- package/lib/module/components/banner/Banner.js.map +1 -1
- package/lib/module/components/banner/__test__/__snapshots__/banner.test.tsx.snap +48 -190
- package/lib/module/components/featureInfo/FeatureInfo.js +29 -28
- package/lib/module/components/featureInfo/FeatureInfo.js.map +1 -1
- package/lib/module/components/layout/index.js +0 -1
- package/lib/module/components/layout/index.js.map +1 -1
- package/lib/module/components/spacer/Spacer.js +1 -1
- package/lib/module/components/spacer/Spacer.js.map +1 -1
- package/lib/module/components/stack/Stack.js +17 -14
- package/lib/module/components/stack/Stack.js.map +1 -1
- package/lib/module/core/IOColors.js.map +1 -1
- package/lib/typescript/components/alert/Alert.d.ts.map +1 -1
- package/lib/typescript/components/banner/Banner.d.ts.map +1 -1
- package/lib/typescript/components/featureInfo/FeatureInfo.d.ts.map +1 -1
- package/lib/typescript/components/layout/index.d.ts +0 -1
- package/lib/typescript/components/layout/index.d.ts.map +1 -1
- package/lib/typescript/components/spacer/Spacer.d.ts +0 -1
- package/lib/typescript/components/spacer/Spacer.d.ts.map +1 -1
- package/lib/typescript/components/stack/Stack.d.ts +9 -6
- package/lib/typescript/components/stack/Stack.d.ts.map +1 -1
- package/lib/typescript/core/IOColors.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/alert/Alert.tsx +46 -15
- package/src/components/banner/Banner.tsx +64 -29
- package/src/components/banner/__test__/__snapshots__/banner.test.tsx.snap +48 -190
- package/src/components/featureInfo/FeatureInfo.tsx +26 -28
- package/src/components/layout/index.tsx +0 -1
- package/src/components/spacer/Spacer.tsx +2 -4
- package/src/components/stack/Stack.tsx +24 -16
- package/src/core/IOColors.ts +1 -0
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { PropsWithChildren } from "react";
|
|
2
2
|
import { ViewStyle } from "react-native";
|
|
3
3
|
import { IOSpacer } from "../../core";
|
|
4
|
-
type AllowedStyleProps = Pick<ViewStyle, "alignItems" | "flexShrink" | "flexGrow" | "flex" | "flexWrap">;
|
|
5
|
-
type Stack = {
|
|
4
|
+
type AllowedStyleProps = Pick<ViewStyle, "alignItems" | "flexShrink" | "flexGrow" | "flex" | "flexWrap" | "width">;
|
|
5
|
+
type Stack = PropsWithChildren<{
|
|
6
6
|
space?: IOSpacer;
|
|
7
|
-
children: ReactNode;
|
|
8
7
|
style?: AllowedStyleProps;
|
|
8
|
+
}>;
|
|
9
|
+
type BaseStack = Stack & {
|
|
10
|
+
orientation: "vertical" | "horizontal";
|
|
9
11
|
};
|
|
10
12
|
/**
|
|
11
13
|
Horizontal Stack component
|
|
12
14
|
@param {IOSpacer} space
|
|
13
15
|
*/
|
|
14
|
-
|
|
16
|
+
declare const Stack: ({ space, style, orientation, children }: BaseStack) => React.JSX.Element;
|
|
17
|
+
export declare const HStack: ({ children, ...props }: Stack) => React.JSX.Element;
|
|
15
18
|
/**
|
|
16
19
|
Vertical Stack component
|
|
17
20
|
@param {IOSpacer} space
|
|
18
21
|
*/
|
|
19
|
-
export declare const VStack: ({
|
|
22
|
+
export declare const VStack: ({ children, ...props }: Stack) => React.JSX.Element;
|
|
20
23
|
export {};
|
|
21
24
|
//# sourceMappingURL=Stack.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Stack.d.ts","sourceRoot":"","sources":["../../../../src/components/stack/Stack.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"Stack.d.ts","sourceRoot":"","sources":["../../../../src/components/stack/Stack.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,EAAQ,SAAS,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,KAAK,iBAAiB,GAAG,IAAI,CAC3B,SAAS,EACT,YAAY,GAAG,YAAY,GAAG,UAAU,GAAG,MAAM,GAAG,UAAU,GAAG,OAAO,CACzE,CAAC;AAEF,KAAK,KAAK,GAAG,iBAAiB,CAAC;IAC7B,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,KAAK,CAAC,EAAE,iBAAiB,CAAC;CAC3B,CAAC,CAAC;AAEH,KAAK,SAAS,GAAG,KAAK,GAAG;IACvB,WAAW,EAAE,UAAU,GAAG,YAAY,CAAC;CACxC,CAAC;AAEF;;;GAGG;AAEH,QAAA,MAAM,KAAK,4CAKR,SAAS,sBAWX,CAAC;AAEF,eAAO,MAAM,MAAM,2BAA4B,KAAK,sBAInD,CAAC;AAEF;;;GAGG;AAEH,eAAO,MAAM,MAAM,2BAA4B,KAAK,sBAInD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IOColors.d.ts","sourceRoot":"","sources":["../../../src/core/IOColors.ts"],"names":[],"mappings":"AAA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AC,IAAI,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,CAAC,GAAG,QAAQ;CAC5C,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,OAoC1B,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,OAKhC,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,OAmCzB,CAAC;AAEF,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;CAiBrC,CAAC;AAEH,MAAM,MAAM,0BAA0B,GACpC,MAAM,OAAO,0BAA0B,CAAC;AAE1C,eAAO,MAAM,yBAAyB,EAAE,MAAM,CAC5C,WAAW,CAAC,0BAA0B,CAAC,EACvC,cAAc,CAkBf,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG,MAAM,OAAO,yBAAyB,CAAC;AAM/E;;;;GAIG;AAEH,eAAO,MAAM,SAAS,YAAa,UAAU,YAAW,MAAM,WAQ7D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { useCallback, useState } from "react";
|
|
2
2
|
import {
|
|
3
|
+
ColorValue,
|
|
3
4
|
GestureResponderEvent,
|
|
4
5
|
NativeSyntheticEvent,
|
|
5
6
|
PixelRatio,
|
|
@@ -17,13 +18,9 @@ import Animated, {
|
|
|
17
18
|
useSharedValue,
|
|
18
19
|
withSpring
|
|
19
20
|
} from "react-native-reanimated";
|
|
20
|
-
import { IOVisualCostants } from "../../core";
|
|
21
|
+
import { IOVisualCostants, useIOThemeContext } from "../../core";
|
|
21
22
|
import { IOScaleValues, IOSpringValues } from "../../core/IOAnimations";
|
|
22
|
-
import {
|
|
23
|
-
IOColors,
|
|
24
|
-
IOColorsStatusBackground,
|
|
25
|
-
IOColorsStatusForeground
|
|
26
|
-
} from "../../core/IOColors";
|
|
23
|
+
import { IOColors, hexToRgba } from "../../core/IOColors";
|
|
27
24
|
import { IOAlertRadius } from "../../core/IOShapes";
|
|
28
25
|
import { IOAlertSpacing } from "../../core/IOSpacing";
|
|
29
26
|
import { WithTestID } from "../../utils/types";
|
|
@@ -75,38 +72,66 @@ type AlertType = AlertProps & AlertActionProps;
|
|
|
75
72
|
|
|
76
73
|
type VariantStates = {
|
|
77
74
|
icon: IOIcons;
|
|
78
|
-
background:
|
|
79
|
-
foreground:
|
|
75
|
+
background: ColorValue;
|
|
76
|
+
foreground: IOColors;
|
|
80
77
|
};
|
|
81
78
|
|
|
82
79
|
// COMPONENT CONFIGURATION
|
|
83
80
|
|
|
84
|
-
const
|
|
81
|
+
const mapVariantStatesLightMode: Record<
|
|
85
82
|
NonNullable<AlertType["variant"]>,
|
|
86
83
|
VariantStates
|
|
87
84
|
> = {
|
|
88
85
|
error: {
|
|
89
86
|
icon: "errorFilled",
|
|
90
|
-
background: "error-100",
|
|
87
|
+
background: IOColors["error-100"],
|
|
91
88
|
foreground: "error-850"
|
|
92
89
|
},
|
|
93
90
|
warning: {
|
|
94
91
|
icon: "warningFilled",
|
|
95
|
-
background: "warning-100",
|
|
92
|
+
background: IOColors["warning-100"],
|
|
96
93
|
foreground: "warning-850"
|
|
97
94
|
},
|
|
98
95
|
info: {
|
|
99
96
|
icon: "infoFilled",
|
|
100
|
-
background: "info-100",
|
|
97
|
+
background: IOColors["info-100"],
|
|
101
98
|
foreground: "info-850"
|
|
102
99
|
},
|
|
103
100
|
success: {
|
|
104
101
|
icon: "success",
|
|
105
|
-
background: "success-100",
|
|
102
|
+
background: IOColors["success-100"],
|
|
106
103
|
foreground: "success-850"
|
|
107
104
|
}
|
|
108
105
|
};
|
|
109
106
|
|
|
107
|
+
const bgOpacityDarkMode = 0.2;
|
|
108
|
+
|
|
109
|
+
const mapVariantStatesDarkMode: Record<
|
|
110
|
+
NonNullable<AlertType["variant"]>,
|
|
111
|
+
VariantStates
|
|
112
|
+
> = {
|
|
113
|
+
error: {
|
|
114
|
+
icon: "errorFilled",
|
|
115
|
+
background: hexToRgba(IOColors["error-400"], bgOpacityDarkMode),
|
|
116
|
+
foreground: "error-100"
|
|
117
|
+
},
|
|
118
|
+
warning: {
|
|
119
|
+
icon: "warningFilled",
|
|
120
|
+
background: hexToRgba(IOColors["warning-400"], bgOpacityDarkMode),
|
|
121
|
+
foreground: "warning-100"
|
|
122
|
+
},
|
|
123
|
+
info: {
|
|
124
|
+
icon: "infoFilled",
|
|
125
|
+
background: hexToRgba(IOColors["info-400"], bgOpacityDarkMode),
|
|
126
|
+
foreground: "info-100"
|
|
127
|
+
},
|
|
128
|
+
success: {
|
|
129
|
+
icon: "success",
|
|
130
|
+
background: hexToRgba(IOColors["success-400"], bgOpacityDarkMode),
|
|
131
|
+
foreground: "success-100"
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
|
|
110
135
|
export const Alert = React.forwardRef<View, AlertType>(
|
|
111
136
|
(
|
|
112
137
|
{
|
|
@@ -121,6 +146,7 @@ export const Alert = React.forwardRef<View, AlertType>(
|
|
|
121
146
|
}: AlertType,
|
|
122
147
|
viewRef
|
|
123
148
|
): JSX.Element => {
|
|
149
|
+
const { themeType } = useIOThemeContext();
|
|
124
150
|
const isPressed: SharedValue<number> = useSharedValue(0);
|
|
125
151
|
|
|
126
152
|
const [isMultiline, setIsMultiline] = useState(false);
|
|
@@ -164,6 +190,11 @@ export const Alert = React.forwardRef<View, AlertType>(
|
|
|
164
190
|
isPressed.value = 0;
|
|
165
191
|
}, [isPressed]);
|
|
166
192
|
|
|
193
|
+
const mapVariantStates =
|
|
194
|
+
themeType === "light"
|
|
195
|
+
? mapVariantStatesLightMode
|
|
196
|
+
: mapVariantStatesDarkMode;
|
|
197
|
+
|
|
167
198
|
const renderMainBlock = () => (
|
|
168
199
|
<>
|
|
169
200
|
<View
|
|
@@ -226,7 +257,7 @@ export const Alert = React.forwardRef<View, AlertType>(
|
|
|
226
257
|
style={[
|
|
227
258
|
styles.container,
|
|
228
259
|
fullWidth ? styles.spacingFullWidth : styles.spacingDefault,
|
|
229
|
-
{ backgroundColor:
|
|
260
|
+
{ backgroundColor: mapVariantStates[variant].background }
|
|
230
261
|
]}
|
|
231
262
|
testID={testID}
|
|
232
263
|
accessible={false}
|
|
@@ -254,7 +285,7 @@ export const Alert = React.forwardRef<View, AlertType>(
|
|
|
254
285
|
style={[
|
|
255
286
|
styles.container,
|
|
256
287
|
fullWidth ? styles.spacingFullWidth : styles.spacingDefault,
|
|
257
|
-
{ backgroundColor:
|
|
288
|
+
{ backgroundColor: mapVariantStates[variant].background },
|
|
258
289
|
// Disable pressed animation when component is full width
|
|
259
290
|
!fullWidth && pressedAnimationStyle
|
|
260
291
|
]}
|
|
@@ -8,8 +8,9 @@ import {
|
|
|
8
8
|
ViewStyle
|
|
9
9
|
} from "react-native";
|
|
10
10
|
import Animated, {
|
|
11
|
-
|
|
11
|
+
Extrapolation,
|
|
12
12
|
interpolate,
|
|
13
|
+
SharedValue,
|
|
13
14
|
useAnimatedStyle,
|
|
14
15
|
useDerivedValue,
|
|
15
16
|
useSharedValue,
|
|
@@ -22,26 +23,26 @@ import {
|
|
|
22
23
|
IOBannerSmallVSpacing,
|
|
23
24
|
IOScaleValues,
|
|
24
25
|
IOSpringValues,
|
|
25
|
-
IOStyles
|
|
26
|
+
IOStyles,
|
|
27
|
+
useIOExperimentalDesign,
|
|
28
|
+
useIOTheme,
|
|
29
|
+
useIOThemeContext
|
|
26
30
|
} from "../../core";
|
|
27
|
-
import { IOColors } from "../../core/IOColors";
|
|
31
|
+
import { hexToRgba, IOColors } from "../../core/IOColors";
|
|
28
32
|
import { WithTestID } from "../../utils/types";
|
|
29
|
-
import {
|
|
33
|
+
import { IconButton } from "../buttons";
|
|
30
34
|
import {
|
|
31
|
-
IOPictogramSizeScale,
|
|
32
35
|
IOPictogramsBleed,
|
|
36
|
+
IOPictogramSizeScale,
|
|
33
37
|
PictogramBleed
|
|
34
38
|
} from "../pictograms";
|
|
35
39
|
import { VSpacer } from "../spacer";
|
|
36
|
-
import { H6,
|
|
40
|
+
import { BodySmall, buttonTextFontSize, H6, IOText } from "../typography";
|
|
37
41
|
|
|
38
42
|
/* Styles */
|
|
39
|
-
const colorTitle: IOColors = "blueIO-850";
|
|
40
|
-
const colorContent: IOColors = "grey-700";
|
|
41
|
-
const colorCloseButton: IconButton["color"] = "neutral";
|
|
42
43
|
const sizePictogramBig: IOPictogramSizeScale = 80;
|
|
43
44
|
const sizePictogramSmall: IOPictogramSizeScale = 64;
|
|
44
|
-
const closeButtonDistanceFromEdge: number =
|
|
45
|
+
const closeButtonDistanceFromEdge: number = 6;
|
|
45
46
|
const closeButtonOpacity = 0.6;
|
|
46
47
|
const sizeBigPadding = IOBannerBigSpacing;
|
|
47
48
|
const sizeSmallHPadding = IOBannerSmallHSpacing;
|
|
@@ -66,15 +67,6 @@ const styles = StyleSheet.create({
|
|
|
66
67
|
}
|
|
67
68
|
});
|
|
68
69
|
|
|
69
|
-
const dynamicContainerStyles = (
|
|
70
|
-
size: BaseBannerProps["size"],
|
|
71
|
-
color: BaseBannerProps["color"]
|
|
72
|
-
): ViewStyle => ({
|
|
73
|
-
backgroundColor: IOColors[mapBackgroundColor[color]],
|
|
74
|
-
paddingVertical: size === "big" ? sizeBigPadding : sizeSmallVPadding,
|
|
75
|
-
paddingHorizontal: size === "big" ? sizeBigPadding : sizeSmallHPadding
|
|
76
|
-
});
|
|
77
|
-
|
|
78
70
|
/* Component Types */
|
|
79
71
|
|
|
80
72
|
type BaseBannerProps = WithTestID<{
|
|
@@ -136,7 +128,7 @@ export const bannerBackgroundColours: Array<BaseBannerProps["color"]> = [
|
|
|
136
128
|
"turquoise"
|
|
137
129
|
];
|
|
138
130
|
|
|
139
|
-
const
|
|
131
|
+
const mapBackgroundColorLightMode: Record<
|
|
140
132
|
NonNullable<BaseBannerProps["color"]>,
|
|
141
133
|
IOColors
|
|
142
134
|
> = {
|
|
@@ -144,6 +136,14 @@ const mapBackgroundColor: Record<
|
|
|
144
136
|
turquoise: "turquoise-50"
|
|
145
137
|
};
|
|
146
138
|
|
|
139
|
+
const mapBackgroundColorDarkMode: Record<
|
|
140
|
+
NonNullable<BaseBannerProps["color"]>,
|
|
141
|
+
IOColors
|
|
142
|
+
> = {
|
|
143
|
+
neutral: "grey-50",
|
|
144
|
+
turquoise: "turquoise-300"
|
|
145
|
+
};
|
|
146
|
+
|
|
147
147
|
export const Banner = ({
|
|
148
148
|
viewRef,
|
|
149
149
|
size,
|
|
@@ -159,7 +159,27 @@ export const Banner = ({
|
|
|
159
159
|
accessibilityLabel,
|
|
160
160
|
testID
|
|
161
161
|
}: Banner) => {
|
|
162
|
-
const isPressed:
|
|
162
|
+
const isPressed: SharedValue<number> = useSharedValue(0);
|
|
163
|
+
|
|
164
|
+
const { isExperimental } = useIOExperimentalDesign();
|
|
165
|
+
const { themeType } = useIOThemeContext();
|
|
166
|
+
const theme = useIOTheme();
|
|
167
|
+
|
|
168
|
+
// Dynamic colors
|
|
169
|
+
const colorTitle: IOColors = themeType === "dark" ? "grey-50" : "blueIO-850";
|
|
170
|
+
const colorCloseButton: IconButton["color"] =
|
|
171
|
+
themeType === "dark" ? "contrast" : "neutral";
|
|
172
|
+
const colorMainButton =
|
|
173
|
+
themeType === "dark" ? "blueIO-200" : theme["interactiveElem-default"];
|
|
174
|
+
|
|
175
|
+
const dynamicContainerStyles: ViewStyle = {
|
|
176
|
+
backgroundColor:
|
|
177
|
+
themeType === "dark"
|
|
178
|
+
? hexToRgba(IOColors[mapBackgroundColorDarkMode[color]], 0.1)
|
|
179
|
+
: IOColors[mapBackgroundColorLightMode[color]],
|
|
180
|
+
paddingVertical: size === "big" ? sizeBigPadding : sizeSmallVPadding,
|
|
181
|
+
paddingHorizontal: size === "big" ? sizeBigPadding : sizeSmallHPadding
|
|
182
|
+
};
|
|
163
183
|
|
|
164
184
|
// Scaling transformation applied when the button is pressed
|
|
165
185
|
const animationScaleValue = IOScaleValues?.magnifiedButton?.pressedState;
|
|
@@ -178,7 +198,7 @@ export const Banner = ({
|
|
|
178
198
|
progressPressed.value,
|
|
179
199
|
[0, 1],
|
|
180
200
|
[1, animationScaleValue],
|
|
181
|
-
|
|
201
|
+
Extrapolation.CLAMP
|
|
182
202
|
);
|
|
183
203
|
|
|
184
204
|
return {
|
|
@@ -221,7 +241,7 @@ export const Banner = ({
|
|
|
221
241
|
)}
|
|
222
242
|
{content && (
|
|
223
243
|
<>
|
|
224
|
-
<BodySmall color={
|
|
244
|
+
<BodySmall color={theme["textBody-tertiary"]} weight={"Regular"}>
|
|
225
245
|
{content}
|
|
226
246
|
</BodySmall>
|
|
227
247
|
{action && <VSpacer size={8} />}
|
|
@@ -229,20 +249,35 @@ export const Banner = ({
|
|
|
229
249
|
)}
|
|
230
250
|
{action && (
|
|
231
251
|
/* Disable pointer events to avoid
|
|
232
|
-
|
|
252
|
+
pressed state on the button */
|
|
233
253
|
<View
|
|
234
254
|
pointerEvents="none"
|
|
235
|
-
accessibilityElementsHidden
|
|
236
255
|
importantForAccessibility="no-hide-descendants"
|
|
256
|
+
accessible={true}
|
|
257
|
+
accessibilityElementsHidden
|
|
258
|
+
accessibilityLabel={action}
|
|
259
|
+
accessibilityRole="button"
|
|
237
260
|
>
|
|
238
261
|
<VSpacer size={4} />
|
|
239
|
-
<
|
|
262
|
+
<IOText
|
|
263
|
+
font={isExperimental ? "Titillio" : "TitilliumSansPro"}
|
|
264
|
+
weight="Semibold"
|
|
265
|
+
color={colorMainButton}
|
|
266
|
+
size={buttonTextFontSize}
|
|
267
|
+
numberOfLines={1}
|
|
268
|
+
ellipsizeMode="tail"
|
|
269
|
+
// A11y
|
|
270
|
+
accessible={false}
|
|
271
|
+
importantForAccessibility="no-hide-descendants"
|
|
272
|
+
accessibilityElementsHidden={true}
|
|
273
|
+
>
|
|
274
|
+
{action}
|
|
275
|
+
</IOText>
|
|
240
276
|
</View>
|
|
241
277
|
)}
|
|
242
278
|
</View>
|
|
243
279
|
<View style={[styles.bleedPictogram, IOStyles.selfCenter]}>
|
|
244
280
|
<PictogramBleed
|
|
245
|
-
pictogramStyle="dark-content"
|
|
246
281
|
name={pictogramName}
|
|
247
282
|
size={size === "big" ? sizePictogramBig : sizePictogramSmall}
|
|
248
283
|
/>
|
|
@@ -272,7 +307,7 @@ export const Banner = ({
|
|
|
272
307
|
<Animated.View
|
|
273
308
|
style={[
|
|
274
309
|
styles.container,
|
|
275
|
-
dynamicContainerStyles
|
|
310
|
+
dynamicContainerStyles,
|
|
276
311
|
pressedAnimationStyle
|
|
277
312
|
]}
|
|
278
313
|
>
|
|
@@ -285,7 +320,7 @@ export const Banner = ({
|
|
|
285
320
|
<View
|
|
286
321
|
ref={viewRef}
|
|
287
322
|
testID={testID}
|
|
288
|
-
style={[styles.container, dynamicContainerStyles
|
|
323
|
+
style={[styles.container, dynamicContainerStyles]}
|
|
289
324
|
// A11y related props
|
|
290
325
|
accessible={false}
|
|
291
326
|
accessibilityHint={accessibilityHint}
|
|
@@ -101,6 +101,9 @@ exports[`Test Banner Components - Experimental Enabled Banner Snapshot 1`] = `
|
|
|
101
101
|
/>
|
|
102
102
|
<View
|
|
103
103
|
accessibilityElementsHidden={true}
|
|
104
|
+
accessibilityLabel="Action text"
|
|
105
|
+
accessibilityRole="button"
|
|
106
|
+
accessible={true}
|
|
104
107
|
importantForAccessibility="no-hide-descendants"
|
|
105
108
|
pointerEvents="none"
|
|
106
109
|
>
|
|
@@ -111,104 +114,30 @@ exports[`Test Banner Components - Experimental Enabled Banner Snapshot 1`] = `
|
|
|
111
114
|
}
|
|
112
115
|
}
|
|
113
116
|
/>
|
|
114
|
-
<
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
"expanded": undefined,
|
|
123
|
-
"selected": undefined,
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
accessibilityValue={
|
|
127
|
-
{
|
|
128
|
-
"max": undefined,
|
|
129
|
-
"min": undefined,
|
|
130
|
-
"now": undefined,
|
|
131
|
-
"text": undefined,
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
accessible={true}
|
|
135
|
-
collapsable={false}
|
|
136
|
-
focusable={true}
|
|
137
|
-
hitSlop={
|
|
138
|
-
{
|
|
139
|
-
"bottom": 14,
|
|
140
|
-
"left": 24,
|
|
141
|
-
"right": 24,
|
|
142
|
-
"top": 14,
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
onBlur={[Function]}
|
|
146
|
-
onClick={[Function]}
|
|
147
|
-
onFocus={[Function]}
|
|
148
|
-
onResponderGrant={[Function]}
|
|
149
|
-
onResponderMove={[Function]}
|
|
150
|
-
onResponderRelease={[Function]}
|
|
151
|
-
onResponderTerminate={[Function]}
|
|
152
|
-
onResponderTerminationRequest={[Function]}
|
|
153
|
-
onStartShouldSetResponder={[Function]}
|
|
154
|
-
onTouchEnd={[Function]}
|
|
117
|
+
<Text
|
|
118
|
+
accessibilityElementsHidden={true}
|
|
119
|
+
accessible={false}
|
|
120
|
+
allowFontScaling={true}
|
|
121
|
+
ellipsizeMode="tail"
|
|
122
|
+
importantForAccessibility="no-hide-descendants"
|
|
123
|
+
maxFontSizeMultiplier={1.25}
|
|
124
|
+
numberOfLines={1}
|
|
155
125
|
style={
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
126
|
+
[
|
|
127
|
+
{},
|
|
128
|
+
{
|
|
129
|
+
"color": "#0B3EE3",
|
|
130
|
+
"fontFamily": "Titillio",
|
|
131
|
+
"fontSize": 16,
|
|
132
|
+
"fontStyle": "normal",
|
|
133
|
+
"fontWeight": "600",
|
|
134
|
+
"lineHeight": undefined,
|
|
135
|
+
},
|
|
136
|
+
]
|
|
159
137
|
}
|
|
160
138
|
>
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
[
|
|
164
|
-
{
|
|
165
|
-
"alignItems": "center",
|
|
166
|
-
"elevation": 0,
|
|
167
|
-
"flexDirection": "row",
|
|
168
|
-
"justifyContent": "center",
|
|
169
|
-
"textAlignVertical": "center",
|
|
170
|
-
},
|
|
171
|
-
false,
|
|
172
|
-
{},
|
|
173
|
-
{
|
|
174
|
-
"transform": [
|
|
175
|
-
{
|
|
176
|
-
"scale": undefined,
|
|
177
|
-
},
|
|
178
|
-
],
|
|
179
|
-
},
|
|
180
|
-
]
|
|
181
|
-
}
|
|
182
|
-
>
|
|
183
|
-
<Text
|
|
184
|
-
accessibilityElementsHidden={true}
|
|
185
|
-
accessible={false}
|
|
186
|
-
allowFontScaling={true}
|
|
187
|
-
ellipsizeMode="tail"
|
|
188
|
-
importantForAccessibility="no-hide-descendants"
|
|
189
|
-
maxFontSizeMultiplier={1.25}
|
|
190
|
-
numberOfLines={1}
|
|
191
|
-
style={
|
|
192
|
-
[
|
|
193
|
-
{},
|
|
194
|
-
{
|
|
195
|
-
"color": "#0E0F13",
|
|
196
|
-
"fontFamily": "Titillio",
|
|
197
|
-
"fontSize": 16,
|
|
198
|
-
"fontStyle": "normal",
|
|
199
|
-
"fontWeight": "600",
|
|
200
|
-
"lineHeight": undefined,
|
|
201
|
-
},
|
|
202
|
-
{
|
|
203
|
-
"color": undefined,
|
|
204
|
-
},
|
|
205
|
-
]
|
|
206
|
-
}
|
|
207
|
-
>
|
|
208
|
-
Action text
|
|
209
|
-
</Text>
|
|
210
|
-
</View>
|
|
211
|
-
</View>
|
|
139
|
+
Action text
|
|
140
|
+
</Text>
|
|
212
141
|
</View>
|
|
213
142
|
</View>
|
|
214
143
|
<View
|
|
@@ -451,6 +380,9 @@ exports[`Test Banner Components Banner Snapshot 1`] = `
|
|
|
451
380
|
/>
|
|
452
381
|
<View
|
|
453
382
|
accessibilityElementsHidden={true}
|
|
383
|
+
accessibilityLabel="Action text"
|
|
384
|
+
accessibilityRole="button"
|
|
385
|
+
accessible={true}
|
|
454
386
|
importantForAccessibility="no-hide-descendants"
|
|
455
387
|
pointerEvents="none"
|
|
456
388
|
>
|
|
@@ -461,104 +393,30 @@ exports[`Test Banner Components Banner Snapshot 1`] = `
|
|
|
461
393
|
}
|
|
462
394
|
}
|
|
463
395
|
/>
|
|
464
|
-
<
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
"expanded": undefined,
|
|
473
|
-
"selected": undefined,
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
accessibilityValue={
|
|
477
|
-
{
|
|
478
|
-
"max": undefined,
|
|
479
|
-
"min": undefined,
|
|
480
|
-
"now": undefined,
|
|
481
|
-
"text": undefined,
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
accessible={true}
|
|
485
|
-
collapsable={false}
|
|
486
|
-
focusable={true}
|
|
487
|
-
hitSlop={
|
|
488
|
-
{
|
|
489
|
-
"bottom": 14,
|
|
490
|
-
"left": 24,
|
|
491
|
-
"right": 24,
|
|
492
|
-
"top": 14,
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
onBlur={[Function]}
|
|
496
|
-
onClick={[Function]}
|
|
497
|
-
onFocus={[Function]}
|
|
498
|
-
onResponderGrant={[Function]}
|
|
499
|
-
onResponderMove={[Function]}
|
|
500
|
-
onResponderRelease={[Function]}
|
|
501
|
-
onResponderTerminate={[Function]}
|
|
502
|
-
onResponderTerminationRequest={[Function]}
|
|
503
|
-
onStartShouldSetResponder={[Function]}
|
|
504
|
-
onTouchEnd={[Function]}
|
|
396
|
+
<Text
|
|
397
|
+
accessibilityElementsHidden={true}
|
|
398
|
+
accessible={false}
|
|
399
|
+
allowFontScaling={false}
|
|
400
|
+
ellipsizeMode="tail"
|
|
401
|
+
importantForAccessibility="no-hide-descendants"
|
|
402
|
+
maxFontSizeMultiplier={1.25}
|
|
403
|
+
numberOfLines={1}
|
|
505
404
|
style={
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
405
|
+
[
|
|
406
|
+
{},
|
|
407
|
+
{
|
|
408
|
+
"color": "#0B3EE3",
|
|
409
|
+
"fontFamily": "Titillium Sans Pro",
|
|
410
|
+
"fontSize": 16,
|
|
411
|
+
"fontStyle": "normal",
|
|
412
|
+
"fontWeight": "600",
|
|
413
|
+
"lineHeight": undefined,
|
|
414
|
+
},
|
|
415
|
+
]
|
|
509
416
|
}
|
|
510
417
|
>
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
[
|
|
514
|
-
{
|
|
515
|
-
"alignItems": "center",
|
|
516
|
-
"elevation": 0,
|
|
517
|
-
"flexDirection": "row",
|
|
518
|
-
"justifyContent": "center",
|
|
519
|
-
"textAlignVertical": "center",
|
|
520
|
-
},
|
|
521
|
-
false,
|
|
522
|
-
{},
|
|
523
|
-
{
|
|
524
|
-
"transform": [
|
|
525
|
-
{
|
|
526
|
-
"scale": undefined,
|
|
527
|
-
},
|
|
528
|
-
],
|
|
529
|
-
},
|
|
530
|
-
]
|
|
531
|
-
}
|
|
532
|
-
>
|
|
533
|
-
<Text
|
|
534
|
-
accessibilityElementsHidden={true}
|
|
535
|
-
accessible={false}
|
|
536
|
-
allowFontScaling={false}
|
|
537
|
-
ellipsizeMode="tail"
|
|
538
|
-
importantForAccessibility="no-hide-descendants"
|
|
539
|
-
maxFontSizeMultiplier={1.25}
|
|
540
|
-
numberOfLines={1}
|
|
541
|
-
style={
|
|
542
|
-
[
|
|
543
|
-
{},
|
|
544
|
-
{
|
|
545
|
-
"color": "#0E0F13",
|
|
546
|
-
"fontFamily": "Titillium Sans Pro",
|
|
547
|
-
"fontSize": 16,
|
|
548
|
-
"fontStyle": "normal",
|
|
549
|
-
"fontWeight": "600",
|
|
550
|
-
"lineHeight": undefined,
|
|
551
|
-
},
|
|
552
|
-
{
|
|
553
|
-
"color": undefined,
|
|
554
|
-
},
|
|
555
|
-
]
|
|
556
|
-
}
|
|
557
|
-
>
|
|
558
|
-
Action text
|
|
559
|
-
</Text>
|
|
560
|
-
</View>
|
|
561
|
-
</View>
|
|
418
|
+
Action text
|
|
419
|
+
</Text>
|
|
562
420
|
</View>
|
|
563
421
|
</View>
|
|
564
422
|
<View
|