@pagopa/io-app-design-system 5.3.1 → 5.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/lib/commonjs/components/avatar/Avatar.js +5 -3
  2. package/lib/commonjs/components/avatar/Avatar.js.map +1 -1
  3. package/lib/commonjs/components/banner/Banner.js +16 -18
  4. package/lib/commonjs/components/banner/Banner.js.map +1 -1
  5. package/lib/commonjs/components/banner/BannerErrorState.js +132 -0
  6. package/lib/commonjs/components/banner/BannerErrorState.js.map +1 -0
  7. package/lib/commonjs/components/banner/__test__/__snapshots__/banner.test.tsx.snap +12 -32
  8. package/lib/commonjs/components/banner/index.js +11 -0
  9. package/lib/commonjs/components/banner/index.js.map +1 -1
  10. package/lib/module/components/avatar/Avatar.js +3 -3
  11. package/lib/module/components/avatar/Avatar.js.map +1 -1
  12. package/lib/module/components/banner/Banner.js +18 -20
  13. package/lib/module/components/banner/Banner.js.map +1 -1
  14. package/lib/module/components/banner/BannerErrorState.js +124 -0
  15. package/lib/module/components/banner/BannerErrorState.js.map +1 -0
  16. package/lib/module/components/banner/__test__/__snapshots__/banner.test.tsx.snap +12 -32
  17. package/lib/module/components/banner/index.js +1 -0
  18. package/lib/module/components/banner/index.js.map +1 -1
  19. package/lib/typescript/components/avatar/Avatar.d.ts +2 -2
  20. package/lib/typescript/components/avatar/Avatar.d.ts.map +1 -1
  21. package/lib/typescript/components/banner/Banner.d.ts.map +1 -1
  22. package/lib/typescript/components/banner/BannerErrorState.d.ts +27 -0
  23. package/lib/typescript/components/banner/BannerErrorState.d.ts.map +1 -0
  24. package/lib/typescript/components/banner/index.d.ts +1 -0
  25. package/lib/typescript/components/banner/index.d.ts.map +1 -1
  26. package/package.json +1 -1
  27. package/src/components/avatar/Avatar.tsx +6 -18
  28. package/src/components/banner/Banner.tsx +7 -16
  29. package/src/components/banner/BannerErrorState.tsx +163 -0
  30. package/src/components/banner/__test__/__snapshots__/banner.test.tsx.snap +12 -32
  31. package/src/components/banner/index.tsx +1 -0
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+
3
+ import React from "react";
4
+ import { Pressable, StyleSheet, View } from "react-native";
5
+ import Animated, { FadeIn, FadeOut } from "react-native-reanimated";
6
+ import { hexToRgba, IOBannerBigSpacing, IOBannerRadius, IOColors, useIOTheme, useIOThemeContext } from "../../core";
7
+ import { Icon } from "../icons";
8
+ import { useScaleAnimation } from "../../hooks";
9
+ import { VSpacer } from "../spacer";
10
+ import { Body } from "../typography";
11
+ import { ButtonLink } from "../buttons";
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ const styles = StyleSheet.create({
14
+ container: {
15
+ flexDirection: "row",
16
+ alignItems: "center",
17
+ alignContent: "center",
18
+ borderRadius: IOBannerRadius,
19
+ borderCurve: "continuous",
20
+ padding: IOBannerBigSpacing
21
+ }
22
+ });
23
+
24
+ /* Component Types */
25
+
26
+ /**
27
+ ** TODO: Move it to the `io-app-design-system` package
28
+ */
29
+ export const BannerErrorState = ({
30
+ viewRef,
31
+ icon = "warningFilled",
32
+ label,
33
+ actionText,
34
+ onPress,
35
+ accessibilityHint,
36
+ accessibilityLabel,
37
+ testID
38
+ }) => {
39
+ const {
40
+ onPressIn,
41
+ onPressOut,
42
+ scaleAnimatedStyle
43
+ } = useScaleAnimation("medium");
44
+ const theme = useIOTheme();
45
+ const {
46
+ themeType
47
+ } = useIOThemeContext();
48
+
49
+ /* Styles */
50
+ const foregroundColor = theme["textBody-tertiary"];
51
+ const backgroundColor = "grey-50";
52
+ const dynamicContainerStyles = {
53
+ backgroundColor: themeType === "dark" ? hexToRgba(IOColors[backgroundColor], 0.1) : IOColors[backgroundColor]
54
+ };
55
+ const renderMainBlock = () => /*#__PURE__*/_jsxs(View, {
56
+ style: {
57
+ flex: 1,
58
+ alignItems: "center",
59
+ gap: 8
60
+ },
61
+ accessible: true
62
+ // A11y related props
63
+ ,
64
+ accessibilityLabel: accessibilityLabel,
65
+ accessibilityHint: accessibilityHint,
66
+ accessibilityRole: actionText !== undefined ? "button" : undefined,
67
+ children: [icon && /*#__PURE__*/_jsx(Icon, {
68
+ name: icon,
69
+ size: 24,
70
+ color: foregroundColor
71
+ }), label && /*#__PURE__*/_jsx(Body, {
72
+ color: foregroundColor,
73
+ textStyle: {
74
+ textAlign: "center"
75
+ },
76
+ children: label
77
+ }), actionText &&
78
+ /*#__PURE__*/
79
+ /* Disable pointer events to avoid
80
+ pressed state on the button */
81
+ _jsxs(View, {
82
+ pointerEvents: "none",
83
+ accessibilityElementsHidden: true,
84
+ importantForAccessibility: "no-hide-descendants",
85
+ children: [/*#__PURE__*/_jsx(VSpacer, {
86
+ size: 4
87
+ }), /*#__PURE__*/_jsx(ButtonLink, {
88
+ color: "primary",
89
+ onPress: onPress,
90
+ label: actionText
91
+ })]
92
+ })]
93
+ });
94
+ const PressableContent = () => /*#__PURE__*/_jsx(Pressable, {
95
+ ref: viewRef,
96
+ testID: testID,
97
+ onPress: onPress,
98
+ onPressIn: onPressIn,
99
+ onPressOut: onPressOut,
100
+ accessible: false,
101
+ children: /*#__PURE__*/_jsx(Animated.View, {
102
+ style: [styles.container, dynamicContainerStyles, scaleAnimatedStyle],
103
+ children: renderMainBlock()
104
+ })
105
+ });
106
+ const StaticComponent = () => /*#__PURE__*/_jsx(View, {
107
+ ref: viewRef,
108
+ testID: testID,
109
+ style: [styles.container, dynamicContainerStyles]
110
+ // A11y related props
111
+ ,
112
+ accessible: false,
113
+ accessibilityHint: accessibilityHint,
114
+ accessibilityLabel: accessibilityLabel,
115
+ accessibilityRole: "text",
116
+ children: renderMainBlock()
117
+ });
118
+ return /*#__PURE__*/_jsx(Animated.View, {
119
+ entering: FadeIn.duration(150),
120
+ exiting: FadeOut.duration(150),
121
+ children: actionText ? /*#__PURE__*/_jsx(PressableContent, {}) : /*#__PURE__*/_jsx(StaticComponent, {})
122
+ });
123
+ };
124
+ //# sourceMappingURL=BannerErrorState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","Pressable","StyleSheet","View","Animated","FadeIn","FadeOut","hexToRgba","IOBannerBigSpacing","IOBannerRadius","IOColors","useIOTheme","useIOThemeContext","Icon","useScaleAnimation","VSpacer","Body","ButtonLink","jsx","_jsx","jsxs","_jsxs","styles","create","container","flexDirection","alignItems","alignContent","borderRadius","borderCurve","padding","BannerErrorState","viewRef","icon","label","actionText","onPress","accessibilityHint","accessibilityLabel","testID","onPressIn","onPressOut","scaleAnimatedStyle","theme","themeType","foregroundColor","backgroundColor","dynamicContainerStyles","renderMainBlock","style","flex","gap","accessible","accessibilityRole","undefined","children","name","size","color","textStyle","textAlign","pointerEvents","accessibilityElementsHidden","importantForAccessibility","PressableContent","ref","StaticComponent","entering","duration","exiting"],"sourceRoot":"../../../../src","sources":["components/banner/BannerErrorState.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAqB,OAAO;AACxC,SAGEC,SAAS,EACTC,UAAU,EACVC,IAAI,QAEC,cAAc;AACrB,OAAOC,QAAQ,IAAIC,MAAM,EAAEC,OAAO,QAAQ,yBAAyB;AACnE,SACEC,SAAS,EACTC,kBAAkB,EAClBC,cAAc,EACdC,QAAQ,EACRC,UAAU,EACVC,iBAAiB,QACZ,YAAY;AAEnB,SAASC,IAAI,QAAiB,UAAU;AACxC,SAASC,iBAAiB,QAAQ,aAAa;AAC/C,SAASC,OAAO,QAAQ,WAAW;AACnC,SAASC,IAAI,QAAQ,eAAe;AACpC,SAASC,UAAU,QAAQ,YAAY;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAExC,MAAMC,MAAM,GAAGpB,UAAU,CAACqB,MAAM,CAAC;EAC/BC,SAAS,EAAE;IACTC,aAAa,EAAE,KAAK;IACpBC,UAAU,EAAE,QAAQ;IACpBC,YAAY,EAAE,QAAQ;IACtBC,YAAY,EAAEnB,cAAc;IAC5BoB,WAAW,EAAE,YAAY;IACzBC,OAAO,EAAEtB;EACX;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AA,CAACf,QAAQ,CAACD,IAAI;IACZgE,QAAQ,EAAE9D,MAAM,CAAC+D,QAAQ,CAAC,GAAG,CAAE;IAC/BC,OAAO,EAAE/D,OAAO,CAAC8D,QAAQ,CAAC,GAAG,CAAE;IAAAb,QAAA,EAE9BpB,UAAU,gBAAGhB,IAAA,CAAC6C,gBAAgB,IAAE,CAAC,gBAAG7C,IAAA,CAAC+C,eAAe,IAAE;EAAC,CAC3C,CAAC;AAEpB,CAAC","ignoreList":[]}
@@ -61,14 +61,11 @@ exports[`Test Banner Components - Experimental Enabled Banner Snapshot 1`] = `
61
61
  accessibilityRole="button"
62
62
  accessible={true}
63
63
  style={
64
- [
65
- {
66
- "flex": 1,
67
- },
68
- {
69
- "alignSelf": "center",
70
- },
71
- ]
64
+ {
65
+ "alignSelf": "center",
66
+ "flex": 1,
67
+ "gap": 4,
68
+ }
72
69
  }
73
70
  >
74
71
  <Text
@@ -91,13 +88,6 @@ exports[`Test Banner Components - Experimental Enabled Banner Snapshot 1`] = `
91
88
  >
92
89
  Banner title
93
90
  </Text>
94
- <View
95
- style={
96
- {
97
- "height": 4,
98
- }
99
- }
100
- />
101
91
  <View
102
92
  accessibilityElementsHidden={true}
103
93
  accessibilityLabel="Action text"
@@ -137,7 +127,7 @@ exports[`Test Banner Components - Experimental Enabled Banner Snapshot 1`] = `
137
127
  <View
138
128
  style={
139
129
  {
140
- "height": 4,
130
+ "height": 8,
141
131
  }
142
132
  }
143
133
  />
@@ -365,14 +355,11 @@ exports[`Test Banner Components Banner Snapshot 1`] = `
365
355
  accessibilityRole="button"
366
356
  accessible={true}
367
357
  style={
368
- [
369
- {
370
- "flex": 1,
371
- },
372
- {
373
- "alignSelf": "center",
374
- },
375
- ]
358
+ {
359
+ "alignSelf": "center",
360
+ "flex": 1,
361
+ "gap": 4,
362
+ }
376
363
  }
377
364
  >
378
365
  <Text
@@ -395,13 +382,6 @@ exports[`Test Banner Components Banner Snapshot 1`] = `
395
382
  >
396
383
  Banner title
397
384
  </Text>
398
- <View
399
- style={
400
- {
401
- "height": 4,
402
- }
403
- }
404
- />
405
385
  <View
406
386
  accessibilityElementsHidden={true}
407
387
  accessibilityLabel="Action text"
@@ -441,7 +421,7 @@ exports[`Test Banner Components Banner Snapshot 1`] = `
441
421
  <View
442
422
  style={
443
423
  {
444
- "height": 4,
424
+ "height": 8,
445
425
  }
446
426
  }
447
427
  />
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
2
 
3
3
  export * from "./Banner";
4
+ export * from "./BannerErrorState";
4
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sourceRoot":"../../../../src","sources":["components/banner/index.tsx"],"mappings":";;AAAA,cAAc,UAAU","ignoreList":[]}
1
+ {"version":3,"names":[],"sourceRoot":"../../../../src","sources":["components/banner/index.tsx"],"mappings":";;AAAA,cAAc,UAAU;AACxB,cAAc,oBAAoB","ignoreList":[]}
@@ -1,8 +1,8 @@
1
1
  import React, { ComponentProps } from "react";
2
- import { Image, ImageRequireSource, ImageURISource } from "react-native";
2
+ import { Image, ImageSourcePropType } from "react-native";
3
3
  type Avatar = {
4
4
  size: "small" | "medium";
5
- logoUri?: ImageRequireSource | ImageURISource | ReadonlyArray<ImageURISource>;
5
+ logoUri?: ImageSourcePropType;
6
6
  };
7
7
  /**
8
8
  * Avatar component is used to display the logo of an organization. It accepts the following props:
@@ -1 +1 @@
1
- {"version":3,"file":"Avatar.d.ts","sourceRoot":"","sources":["../../../../src/components/avatar/Avatar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,EACL,KAAK,EACL,kBAAkB,EAClB,cAAc,EAGf,MAAM,cAAc,CAAC;AAYtB,KAAK,MAAM,GAAG;IACZ,IAAI,EAAE,OAAO,GAAG,QAAQ,CAAC;IACzB,OAAO,CAAC,EAAE,kBAAkB,GAAG,cAAc,GAAG,aAAa,CAAC,cAAc,CAAC,CAAC;CAC/E,CAAC;AA0CF;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM,GAAI,mBAAmB,MAAM,sBAoE/C,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAClC,cAAc,CAAC,OAAO,KAAK,CAAC,EAC5B,QAAQ,GAAG,eAAe,CAC3B,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,wDACK,iBAAiB,uBAkC9C,CAAC"}
1
+ {"version":3,"file":"Avatar.d.ts","sourceRoot":"","sources":["../../../../src/components/avatar/Avatar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,cAAc,EAAoB,MAAM,OAAO,CAAC;AAChE,OAAO,EAAE,KAAK,EAAE,mBAAmB,EAAoB,MAAM,cAAc,CAAC;AAY5E,KAAK,MAAM,GAAG;IACZ,IAAI,EAAE,OAAO,GAAG,QAAQ,CAAC;IACzB,OAAO,CAAC,EAAE,mBAAmB,CAAC;CAC/B,CAAC;AA0CF;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM,GAAI,mBAAmB,MAAM,sBA8D/C,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAClC,cAAc,CAAC,OAAO,KAAK,CAAC,EAC5B,QAAQ,GAAG,eAAe,CAC3B,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,wDACK,iBAAiB,uBAkC9C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Banner.d.ts","sourceRoot":"","sources":["../../../../src/components/banner/Banner.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EAGrB,IAAI,EAEL,MAAM,cAAc,CAAC;AAYtB,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,EACL,iBAAiB,EAGlB,MAAM,eAAe,CAAC;AAgCvB,KAAK,eAAe,GAAG,UAAU,CAAC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EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,IAAI,CAAC;IAChD,iBAAiB,CAAC,EAAE,OAAO,CAAC,iBAAiB,EAAE,QAAQ,GAAG,MAAM,CAAC,CAAC;CACnE,GACD;IACE,MAAM,CAAC,EAAE,KAAK,CAAC;IACf,OAAO,CAAC,EAAE,KAAK,CAAC;IAChB,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC,CAAC;AAGN,KAAK,gBAAgB,GACjB;IACE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,IAAI,CAAC;IACjD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GACD;IACE,OAAO,CAAC,EAAE,KAAK,CAAC;IAChB,UAAU,CAAC,EAAE,KAAK,CAAC;CACpB,CAAC;AAEN,MAAM,MAAM,MAAM,GAAG,eAAe,GAClC,mBAAmB,GACnB,iBAAiB,GACjB,gBAAgB,CAAC;AAMnB,eAAO,MAAM,uBAAuB,EAAE,KAAK,CAAC,eAAe,CAAC,OAAO,CAAC,CAGnE,CAAC;AAkBF,eAAO,MAAM,MAAM,GAAI,2JAcpB,MAAM,sBAuHR,CAAC"}
@@ -0,0 +1,27 @@
1
+ import React, { RefObject } from "react";
2
+ import { AccessibilityRole, GestureResponderEvent, View } from "react-native";
3
+ import { WithTestID } from "../../utils/types";
4
+ import { IOIcons } from "../icons";
5
+ type BaseBannerErrorStateProps = WithTestID<{
6
+ icon?: IOIcons;
7
+ label: string;
8
+ viewRef?: RefObject<View>;
9
+ accessibilityLabel?: string;
10
+ accessibilityHint?: string;
11
+ }>;
12
+ type BannerErrorStateActionProps = {
13
+ actionText?: string;
14
+ onPress: (event: GestureResponderEvent) => void;
15
+ accessibilityRole?: never;
16
+ } | {
17
+ actionText?: never;
18
+ onPress?: never;
19
+ accessibilityRole?: AccessibilityRole;
20
+ };
21
+ export type BannerErrorStateProps = BaseBannerErrorStateProps & BannerErrorStateActionProps;
22
+ /**
23
+ ** TODO: Move it to the `io-app-design-system` package
24
+ */
25
+ export declare const BannerErrorState: ({ viewRef, icon, label, actionText, onPress, accessibilityHint, accessibilityLabel, testID }: BannerErrorStateProps) => React.JSX.Element;
26
+ export {};
27
+ //# sourceMappingURL=BannerErrorState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BannerErrorState.d.ts","sourceRoot":"","sources":["../../../../src/components/banner/BannerErrorState.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EAGrB,IAAI,EAEL,MAAM,cAAc,CAAC;AAUtB,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAQ,OAAO,EAAE,MAAM,UAAU,CAAC;AAmBzC,KAAK,yBAAyB,GAAG,UAAU,CAAC;IAC1C,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;IAE1B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC,CAAC;AAEH,KAAK,2BAA2B,GAC5B;IACE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,IAAI,CAAC;IAChD,iBAAiB,CAAC,EAAE,KAAK,CAAC;CAC3B,GACD;IACE,UAAU,CAAC,EAAE,KAAK,CAAC;IACnB,OAAO,CAAC,EAAE,KAAK,CAAC;IAChB,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC,CAAC;AAEN,MAAM,MAAM,qBAAqB,GAAG,yBAAyB,GAC3D,2BAA2B,CAAC;AAE9B;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAAI,8FAS9B,qBAAqB,sBAwFvB,CAAC"}
@@ -1,2 +1,3 @@
1
1
  export * from "./Banner";
2
+ export * from "./BannerErrorState";
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/banner/index.tsx"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/banner/index.tsx"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pagopa/io-app-design-system",
3
- "version": "5.3.1",
3
+ "version": "5.3.2",
4
4
  "description": "The library defining the core components of the design system of @pagopa/io-app",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -1,11 +1,5 @@
1
- import React, { ComponentProps } from "react";
2
- import {
3
- Image,
4
- ImageRequireSource,
5
- ImageURISource,
6
- StyleSheet,
7
- View
8
- } from "react-native";
1
+ import React, { ComponentProps, useRef, useState } from "react";
2
+ import { Image, ImageSourcePropType, StyleSheet, View } from "react-native";
9
3
  import { Icon } from "../../components/icons";
10
4
  import {
11
5
  IOColors,
@@ -19,7 +13,7 @@ import avatarSearchPlaceholder from "./placeholder/avatar-placeholder.png";
19
13
 
20
14
  type Avatar = {
21
15
  size: "small" | "medium";
22
- logoUri?: ImageRequireSource | ImageURISource | ReadonlyArray<ImageURISource>;
16
+ logoUri?: ImageSourcePropType;
23
17
  };
24
18
 
25
19
  const internalSpaceDefaultSize: number = 6;
@@ -72,16 +66,10 @@ const styles = StyleSheet.create({
72
66
  */
73
67
  export const Avatar = ({ logoUri, size }: Avatar) => {
74
68
  const theme = useIOTheme();
75
- const indexValue = React.useRef<number>(0);
69
+ const indexValue = useRef<number>(0);
76
70
 
77
- const [imageSource, setImageSource] = React.useState(
78
- logoUri === undefined
79
- ? undefined
80
- : Array.isArray(logoUri)
81
- ? addCacheTimestampToUri(logoUri[0])
82
- : typeof logoUri === "number"
83
- ? logoUri
84
- : addCacheTimestampToUri(logoUri as ImageURISource)
71
+ const [imageSource, setImageSource] = useState(
72
+ logoUri === undefined ? undefined : addCacheTimestampToUri(logoUri)
85
73
  );
86
74
 
87
75
  const onError = () => {
@@ -11,7 +11,6 @@ import Animated from "react-native-reanimated";
11
11
  import {
12
12
  IOBannerBigSpacing,
13
13
  IOBannerRadius,
14
- IOStyles,
15
14
  useIONewTypeface,
16
15
  useIOTheme,
17
16
  useIOThemeContext
@@ -174,26 +173,18 @@ export const Banner = ({
174
173
  const renderMainBlock = () => (
175
174
  <>
176
175
  <View
177
- style={[IOStyles.flex, IOStyles.selfCenter]}
176
+ style={{ flex: 1, alignSelf: "center", gap: 4 }}
178
177
  accessible={true}
179
178
  // A11y related props
180
179
  accessibilityLabel={accessibilityLabel ?? fallbackAccessibilityLabel}
181
180
  accessibilityHint={accessibilityHint}
182
181
  accessibilityRole={action !== undefined ? accessibilityRole : "text"}
183
182
  >
184
- {title && (
185
- <>
186
- <H6 color={colorTitle}>{title}</H6>
187
- <VSpacer size={4} />
188
- </>
189
- )}
183
+ {title && <H6 color={colorTitle}>{title}</H6>}
190
184
  {content && (
191
- <>
192
- <BodySmall color={theme["textBody-tertiary"]} weight={"Regular"}>
193
- {content}
194
- </BodySmall>
195
- {action && <VSpacer size={8} />}
196
- </>
185
+ <BodySmall color={theme["textBody-tertiary"]} weight={"Regular"}>
186
+ {content}
187
+ </BodySmall>
197
188
  )}
198
189
  {action && (
199
190
  /* Disable pointer events to avoid
@@ -207,7 +198,7 @@ export const Banner = ({
207
198
  accessibilityRole="button"
208
199
  onPress={onPress}
209
200
  >
210
- <VSpacer size={4} />
201
+ <VSpacer size={8} />
211
202
  <IOText
212
203
  font={newTypefaceEnabled ? "Titillio" : "TitilliumSansPro"}
213
204
  weight="Semibold"
@@ -225,7 +216,7 @@ export const Banner = ({
225
216
  </Pressable>
226
217
  )}
227
218
  </View>
228
- <View style={[styles.bleedPictogram, IOStyles.selfCenter]}>
219
+ <View style={[styles.bleedPictogram, { alignSelf: "center" }]}>
229
220
  <PictogramBleed name={pictogramName} size={sizePictogram} />
230
221
  </View>
231
222
  {onClose && labelClose && (
@@ -0,0 +1,163 @@
1
+ import React, { RefObject } from "react";
2
+ import {
3
+ AccessibilityRole,
4
+ GestureResponderEvent,
5
+ Pressable,
6
+ StyleSheet,
7
+ View,
8
+ ViewStyle
9
+ } from "react-native";
10
+ import Animated, { FadeIn, FadeOut } from "react-native-reanimated";
11
+ import {
12
+ hexToRgba,
13
+ IOBannerBigSpacing,
14
+ IOBannerRadius,
15
+ IOColors,
16
+ useIOTheme,
17
+ useIOThemeContext
18
+ } from "../../core";
19
+ import { WithTestID } from "../../utils/types";
20
+ import { Icon, IOIcons } from "../icons";
21
+ import { useScaleAnimation } from "../../hooks";
22
+ import { VSpacer } from "../spacer";
23
+ import { Body } from "../typography";
24
+ import { ButtonLink } from "../buttons";
25
+
26
+ const styles = StyleSheet.create({
27
+ container: {
28
+ flexDirection: "row",
29
+ alignItems: "center",
30
+ alignContent: "center",
31
+ borderRadius: IOBannerRadius,
32
+ borderCurve: "continuous",
33
+ padding: IOBannerBigSpacing
34
+ }
35
+ });
36
+
37
+ /* Component Types */
38
+
39
+ type BaseBannerErrorStateProps = WithTestID<{
40
+ icon?: IOIcons;
41
+ label: string;
42
+ viewRef?: RefObject<View>;
43
+ // A11y related props
44
+ accessibilityLabel?: string;
45
+ accessibilityHint?: string;
46
+ }>;
47
+
48
+ type BannerErrorStateActionProps =
49
+ | {
50
+ actionText?: string;
51
+ onPress: (event: GestureResponderEvent) => void;
52
+ accessibilityRole?: never;
53
+ }
54
+ | {
55
+ actionText?: never;
56
+ onPress?: never;
57
+ accessibilityRole?: AccessibilityRole;
58
+ };
59
+
60
+ export type BannerErrorStateProps = BaseBannerErrorStateProps &
61
+ BannerErrorStateActionProps;
62
+
63
+ /**
64
+ ** TODO: Move it to the `io-app-design-system` package
65
+ */
66
+ export const BannerErrorState = ({
67
+ viewRef,
68
+ icon = "warningFilled",
69
+ label,
70
+ actionText,
71
+ onPress,
72
+ accessibilityHint,
73
+ accessibilityLabel,
74
+ testID
75
+ }: BannerErrorStateProps) => {
76
+ const { onPressIn, onPressOut, scaleAnimatedStyle } =
77
+ useScaleAnimation("medium");
78
+
79
+ const theme = useIOTheme();
80
+ const { themeType } = useIOThemeContext();
81
+
82
+ /* Styles */
83
+ const foregroundColor: IOColors = theme["textBody-tertiary"];
84
+ const backgroundColor: IOColors = "grey-50";
85
+
86
+ const dynamicContainerStyles: ViewStyle = {
87
+ backgroundColor:
88
+ themeType === "dark"
89
+ ? hexToRgba(IOColors[backgroundColor], 0.1)
90
+ : IOColors[backgroundColor]
91
+ };
92
+
93
+ const renderMainBlock = () => (
94
+ <View
95
+ style={{ flex: 1, alignItems: "center", gap: 8 }}
96
+ accessible={true}
97
+ // A11y related props
98
+ accessibilityLabel={accessibilityLabel}
99
+ accessibilityHint={accessibilityHint}
100
+ accessibilityRole={actionText !== undefined ? "button" : undefined}
101
+ >
102
+ {icon && <Icon name={icon} size={24} color={foregroundColor} />}
103
+ {label && (
104
+ <Body color={foregroundColor} textStyle={{ textAlign: "center" }}>
105
+ {label}
106
+ </Body>
107
+ )}
108
+ {actionText && (
109
+ /* Disable pointer events to avoid
110
+ pressed state on the button */
111
+ <View
112
+ pointerEvents="none"
113
+ accessibilityElementsHidden
114
+ importantForAccessibility="no-hide-descendants"
115
+ >
116
+ <VSpacer size={4} />
117
+ <ButtonLink color="primary" onPress={onPress} label={actionText} />
118
+ </View>
119
+ )}
120
+ </View>
121
+ );
122
+
123
+ const PressableContent = () => (
124
+ <Pressable
125
+ ref={viewRef}
126
+ testID={testID}
127
+ onPress={onPress}
128
+ onPressIn={onPressIn}
129
+ onPressOut={onPressOut}
130
+ accessible={false}
131
+ >
132
+ <Animated.View
133
+ style={[styles.container, dynamicContainerStyles, scaleAnimatedStyle]}
134
+ >
135
+ {renderMainBlock()}
136
+ </Animated.View>
137
+ </Pressable>
138
+ );
139
+
140
+ const StaticComponent = () => (
141
+ <View
142
+ ref={viewRef}
143
+ testID={testID}
144
+ style={[styles.container, dynamicContainerStyles]}
145
+ // A11y related props
146
+ accessible={false}
147
+ accessibilityHint={accessibilityHint}
148
+ accessibilityLabel={accessibilityLabel}
149
+ accessibilityRole={"text"}
150
+ >
151
+ {renderMainBlock()}
152
+ </View>
153
+ );
154
+
155
+ return (
156
+ <Animated.View
157
+ entering={FadeIn.duration(150)}
158
+ exiting={FadeOut.duration(150)}
159
+ >
160
+ {actionText ? <PressableContent /> : <StaticComponent />}
161
+ </Animated.View>
162
+ );
163
+ };
@@ -61,14 +61,11 @@ exports[`Test Banner Components - Experimental Enabled Banner Snapshot 1`] = `
61
61
  accessibilityRole="button"
62
62
  accessible={true}
63
63
  style={
64
- [
65
- {
66
- "flex": 1,
67
- },
68
- {
69
- "alignSelf": "center",
70
- },
71
- ]
64
+ {
65
+ "alignSelf": "center",
66
+ "flex": 1,
67
+ "gap": 4,
68
+ }
72
69
  }
73
70
  >
74
71
  <Text
@@ -91,13 +88,6 @@ exports[`Test Banner Components - Experimental Enabled Banner Snapshot 1`] = `
91
88
  >
92
89
  Banner title
93
90
  </Text>
94
- <View
95
- style={
96
- {
97
- "height": 4,
98
- }
99
- }
100
- />
101
91
  <View
102
92
  accessibilityElementsHidden={true}
103
93
  accessibilityLabel="Action text"
@@ -137,7 +127,7 @@ exports[`Test Banner Components - Experimental Enabled Banner Snapshot 1`] = `
137
127
  <View
138
128
  style={
139
129
  {
140
- "height": 4,
130
+ "height": 8,
141
131
  }
142
132
  }
143
133
  />
@@ -365,14 +355,11 @@ exports[`Test Banner Components Banner Snapshot 1`] = `
365
355
  accessibilityRole="button"
366
356
  accessible={true}
367
357
  style={
368
- [
369
- {
370
- "flex": 1,
371
- },
372
- {
373
- "alignSelf": "center",
374
- },
375
- ]
358
+ {
359
+ "alignSelf": "center",
360
+ "flex": 1,
361
+ "gap": 4,
362
+ }
376
363
  }
377
364
  >
378
365
  <Text
@@ -395,13 +382,6 @@ exports[`Test Banner Components Banner Snapshot 1`] = `
395
382
  >
396
383
  Banner title
397
384
  </Text>
398
- <View
399
- style={
400
- {
401
- "height": 4,
402
- }
403
- }
404
- />
405
385
  <View
406
386
  accessibilityElementsHidden={true}
407
387
  accessibilityLabel="Action text"
@@ -441,7 +421,7 @@ exports[`Test Banner Components Banner Snapshot 1`] = `
441
421
  <View
442
422
  style={
443
423
  {
444
- "height": 4,
424
+ "height": 8,
445
425
  }
446
426
  }
447
427
  />
@@ -1 +1,2 @@
1
1
  export * from "./Banner";
2
+ export * from "./BannerErrorState";