@pagopa/io-app-design-system 5.9.0 → 5.10.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.
Files changed (66) hide show
  1. package/README.md +1 -0
  2. package/lib/commonjs/components/icons/Icon.js +7 -3
  3. package/lib/commonjs/components/icons/Icon.js.map +1 -1
  4. package/lib/commonjs/components/icons/svg/IconSecurityPad.js +30 -0
  5. package/lib/commonjs/components/icons/svg/IconSecurityPad.js.map +1 -0
  6. package/lib/commonjs/components/icons/svg/originals/IconSecurityPad.svg +6 -0
  7. package/lib/commonjs/components/modules/ModuleNavigationAlt.js +186 -0
  8. package/lib/commonjs/components/modules/ModuleNavigationAlt.js.map +1 -0
  9. package/lib/commonjs/components/modules/__test__/ModuleNavigationAlt.test.js +110 -0
  10. package/lib/commonjs/components/modules/__test__/ModuleNavigationAlt.test.js.map +1 -0
  11. package/lib/commonjs/components/modules/__test__/__snapshots__/ModuleNavigationAlt.test.tsx.snap +21 -0
  12. package/lib/commonjs/components/modules/index.js +11 -0
  13. package/lib/commonjs/components/modules/index.js.map +1 -1
  14. package/lib/commonjs/components/modules/spid-text-logo.svg +1 -0
  15. package/lib/commonjs/core/IOColors.js +6 -2
  16. package/lib/commonjs/core/IOColors.js.map +1 -1
  17. package/lib/module/components/icons/Icon.js +7 -3
  18. package/lib/module/components/icons/Icon.js.map +1 -1
  19. package/lib/module/components/icons/svg/IconSecurityPad.js +25 -0
  20. package/lib/module/components/icons/svg/IconSecurityPad.js.map +1 -0
  21. package/lib/module/components/icons/svg/originals/IconSecurityPad.svg +6 -0
  22. package/lib/module/components/modules/ModuleNavigationAlt.js +180 -0
  23. package/lib/module/components/modules/ModuleNavigationAlt.js.map +1 -0
  24. package/lib/module/components/modules/__test__/ModuleNavigationAlt.test.js +107 -0
  25. package/lib/module/components/modules/__test__/ModuleNavigationAlt.test.js.map +1 -0
  26. package/lib/module/components/modules/__test__/__snapshots__/ModuleNavigationAlt.test.tsx.snap +21 -0
  27. package/lib/module/components/modules/index.js +1 -0
  28. package/lib/module/components/modules/index.js.map +1 -1
  29. package/lib/module/components/modules/spid-text-logo.svg +1 -0
  30. package/lib/module/core/IOColors.js +6 -2
  31. package/lib/module/core/IOColors.js.map +1 -1
  32. package/lib/typescript/components/icons/Icon.d.ts +2 -0
  33. package/lib/typescript/components/icons/Icon.d.ts.map +1 -1
  34. package/lib/typescript/components/icons/svg/IconSecurityPad.d.ts +5 -0
  35. package/lib/typescript/components/icons/svg/IconSecurityPad.d.ts.map +1 -0
  36. package/lib/typescript/components/modules/ModuleNavigationAlt.d.ts +32 -0
  37. package/lib/typescript/components/modules/ModuleNavigationAlt.d.ts.map +1 -0
  38. package/lib/typescript/components/modules/__test__/ModuleNavigationAlt.test.d.ts +2 -0
  39. package/lib/typescript/components/modules/__test__/ModuleNavigationAlt.test.d.ts.map +1 -0
  40. package/lib/typescript/components/modules/index.d.ts +1 -0
  41. package/lib/typescript/components/modules/index.d.ts.map +1 -1
  42. package/lib/typescript/components/typography/BodyMonospace.d.ts +1 -1
  43. package/lib/typescript/components/typography/ButtonText.d.ts +1 -1
  44. package/lib/typescript/components/typography/Caption.d.ts +1 -1
  45. package/lib/typescript/components/typography/H1.d.ts +1 -1
  46. package/lib/typescript/components/typography/H2.d.ts +1 -1
  47. package/lib/typescript/components/typography/H3.d.ts +1 -1
  48. package/lib/typescript/components/typography/H4.d.ts +1 -1
  49. package/lib/typescript/components/typography/H5.d.ts +1 -1
  50. package/lib/typescript/components/typography/H6.d.ts +1 -1
  51. package/lib/typescript/components/typography/Hero.d.ts +1 -1
  52. package/lib/typescript/components/typography/markdown/MdH1.d.ts +1 -1
  53. package/lib/typescript/components/typography/markdown/MdH2.d.ts +1 -1
  54. package/lib/typescript/components/typography/markdown/MdH3.d.ts +1 -1
  55. package/lib/typescript/core/IOColors.d.ts +3 -1
  56. package/lib/typescript/core/IOColors.d.ts.map +1 -1
  57. package/package.json +1 -1
  58. package/src/components/icons/Icon.tsx +6 -3
  59. package/src/components/icons/svg/IconSecurityPad.tsx +18 -0
  60. package/src/components/icons/svg/originals/IconSecurityPad.svg +6 -0
  61. package/src/components/modules/ModuleNavigationAlt.tsx +210 -0
  62. package/src/components/modules/__test__/ModuleNavigationAlt.test.tsx +116 -0
  63. package/src/components/modules/__test__/__snapshots__/ModuleNavigationAlt.test.tsx.snap +21 -0
  64. package/src/components/modules/index.tsx +1 -0
  65. package/src/components/modules/spid-text-logo.svg +1 -0
  66. package/src/core/IOColors.ts +7 -1
@@ -0,0 +1,210 @@
1
+ import React from "react";
2
+ import {
3
+ Image,
4
+ ImageSourcePropType,
5
+ ImageURISource,
6
+ StyleSheet,
7
+ View
8
+ } from "react-native";
9
+ import { SvgProps } from "react-native-svg";
10
+ import { useIOTheme } from "../../context";
11
+ import {
12
+ IOColors,
13
+ IOListItemVisualParams,
14
+ IOSpacer,
15
+ IOVisualCostants
16
+ } from "../../core";
17
+ import { useIOFontDynamicScale } from "../../utils/accessibility";
18
+ import { WithTestID } from "../../utils/types";
19
+ import { Badge } from "../badge";
20
+ import { IOIconSizeScale, IOIcons, Icon } from "../icons";
21
+ import { HStack, VStack } from "../layout";
22
+ import { LoadingSpinner } from "../loadingSpinner";
23
+ import { IOSkeleton } from "../skeleton";
24
+ import { BodySmall, LabelMini } from "../typography";
25
+ import { ModuleStatic } from "./ModuleStatic";
26
+ import {
27
+ PressableModuleBase,
28
+ PressableModuleBaseProps
29
+ } from "./PressableModuleBase";
30
+ type LoadingProps = {
31
+ isLoading: true;
32
+ loadingAccessibilityLabel?: string;
33
+ };
34
+
35
+ type ImageProps =
36
+ | { icon: IOIcons; image?: never }
37
+ | {
38
+ icon?: never;
39
+ image:
40
+ | ImageURISource
41
+ | ImageSourcePropType
42
+ | React.ReactElement<SvgProps>;
43
+ };
44
+
45
+ type BaseProps = {
46
+ isLoading?: false;
47
+ title: string;
48
+ subtitle?: string;
49
+ badge?: Badge;
50
+ isFetching?: boolean;
51
+ rightIcon?: IOIcons;
52
+ iconColor?: IOColors;
53
+ } & ImageProps &
54
+ PressableModuleBaseProps;
55
+
56
+ type ModuleNavigationAltProps = LoadingProps | BaseProps;
57
+
58
+ export const ModuleNavigationAlt = (
59
+ props: WithTestID<ModuleNavigationAltProps>
60
+ ) => {
61
+ const theme = useIOTheme();
62
+ const { hugeFontEnabled } = useIOFontDynamicScale();
63
+
64
+ const graphicWrapperSize: IOIconSizeScale = 48;
65
+
66
+ if (props.isLoading) {
67
+ return (
68
+ <ModuleNavigationAltSkeleton
69
+ loadingAccessibilityLabel={props.loadingAccessibilityLabel}
70
+ />
71
+ );
72
+ }
73
+
74
+ const {
75
+ testID,
76
+ icon,
77
+ iconColor = theme["interactiveElem-default"],
78
+ image,
79
+ title,
80
+ subtitle,
81
+ onPress,
82
+ badge,
83
+ isFetching,
84
+ rightIcon,
85
+ ...pressableProps
86
+ } = props;
87
+
88
+ const iconComponent = icon && (
89
+ <Icon name={icon} size={32} color={iconColor} />
90
+ );
91
+
92
+ const imageComponent = () => {
93
+ if (!image) {
94
+ return null;
95
+ }
96
+
97
+ if (React.isValidElement(image)) {
98
+ return image;
99
+ } else {
100
+ return (
101
+ <View>
102
+ <Image
103
+ source={image as ImageSourcePropType}
104
+ style={styles.image}
105
+ accessibilityIgnoresInvertColors={true}
106
+ />
107
+ </View>
108
+ );
109
+ }
110
+ };
111
+
112
+ const endComponent = () => {
113
+ if (isFetching) {
114
+ return (
115
+ <LoadingSpinner
116
+ testID={testID ? `${testID}_activityIndicator` : undefined}
117
+ />
118
+ );
119
+ }
120
+ if (onPress) {
121
+ return (
122
+ <Icon
123
+ name={rightIcon ?? "chevronRightListItem"}
124
+ color={theme["interactiveElem-default"]}
125
+ size={IOListItemVisualParams.chevronSize}
126
+ />
127
+ );
128
+ }
129
+ return null;
130
+ };
131
+
132
+ return (
133
+ <PressableModuleBase {...pressableProps} onPress={onPress}>
134
+ <HStack space={8} style={{ alignItems: "center" }}>
135
+ <HStack
136
+ space={IOVisualCostants.iconMargin as IOSpacer}
137
+ style={{ alignItems: "center", flexGrow: 1, flexShrink: 1 }}
138
+ >
139
+ {!hugeFontEnabled && (
140
+ <View
141
+ style={{
142
+ alignItems: "center",
143
+ justifyContent: "center",
144
+ width: graphicWrapperSize,
145
+ height: graphicWrapperSize
146
+ }}
147
+ >
148
+ {iconComponent ?? imageComponent()}
149
+ </View>
150
+ )}
151
+
152
+ <VStack space={8} style={{ flexShrink: 1, alignItems: "flex-start" }}>
153
+ {badge ? <Badge {...badge} /> : null}
154
+ <View>
155
+ <BodySmall
156
+ color={theme["interactiveElem-default"]}
157
+ weight="Semibold"
158
+ numberOfLines={2}
159
+ lineBreakMode="middle"
160
+ style={{ flexShrink: 1 }}
161
+ >
162
+ {title}
163
+ </BodySmall>
164
+ {subtitle && (
165
+ <LabelMini weight="Regular" color={theme["textBody-tertiary"]}>
166
+ {subtitle}
167
+ </LabelMini>
168
+ )}
169
+ </View>
170
+ </VStack>
171
+ </HStack>
172
+ {endComponent()}
173
+ </HStack>
174
+ </PressableModuleBase>
175
+ );
176
+ };
177
+
178
+ const ModuleNavigationAltSkeleton = ({
179
+ loadingAccessibilityLabel
180
+ }: Pick<LoadingProps, "loadingAccessibilityLabel">) => (
181
+ <ModuleStatic
182
+ accessible={true}
183
+ accessibilityLabel={loadingAccessibilityLabel}
184
+ accessibilityState={{ busy: true }}
185
+ startBlock={
186
+ <HStack
187
+ style={{ alignItems: "center" }}
188
+ space={IOVisualCostants.iconMargin as IOSpacer}
189
+ >
190
+ <IOSkeleton shape="square" size={32} radius={8} />
191
+ <VStack space={4}>
192
+ <IOSkeleton shape="rectangle" width={52} height={12} radius={8} />
193
+ <IOSkeleton shape="rectangle" width={96} height={16} radius={8} />
194
+ <IOSkeleton shape="rectangle" width={160} height={12} radius={8} />
195
+ </VStack>
196
+ </HStack>
197
+ }
198
+ endBlock={
199
+ <IOSkeleton shape="rectangle" width={64} height={24} radius={16} />
200
+ }
201
+ />
202
+ );
203
+
204
+ const styles = StyleSheet.create({
205
+ image: {
206
+ width: "100%",
207
+ height: "auto",
208
+ resizeMode: "contain"
209
+ }
210
+ });
@@ -0,0 +1,116 @@
1
+ // __tests__/ModuleNavigationAlt.test.tsx
2
+ import React from "react";
3
+ import * as TestRenderer from "react-test-renderer";
4
+ import { Alert } from "react-native";
5
+ import { TestRendererWithExperimentalEnabledContextProvider } from "../../../utils/testing";
6
+ import { ModuleNavigationAlt } from "../ModuleNavigationAlt";
7
+
8
+ const onPress = () => {
9
+ Alert.alert("Alert", "Action triggered");
10
+ };
11
+
12
+ describe("ModuleNavigationAlt - Snapshot", () => {
13
+ it("Loading state", () => {
14
+ const tree = TestRenderer.create(
15
+ <ModuleNavigationAlt
16
+ isLoading
17
+ loadingAccessibilityLabel="loading items"
18
+ />
19
+ ).toJSON();
20
+ expect(tree).toMatchSnapshot();
21
+ });
22
+
23
+ it("Title only + chevron (onPress)", () => {
24
+ const tree = TestRenderer.create(
25
+ <ModuleNavigationAlt title="My Title" onPress={onPress} icon="spid" />
26
+ ).toJSON();
27
+ expect(tree).toMatchSnapshot();
28
+ });
29
+
30
+ it("Title + Subtitle", () => {
31
+ const tree = TestRenderer.create(
32
+ <ModuleNavigationAlt
33
+ title="My Title"
34
+ subtitle="A nice subtitle"
35
+ icon="spid"
36
+ />
37
+ ).toJSON();
38
+ expect(tree).toMatchSnapshot();
39
+ });
40
+
41
+ it("With Badge (badge + chevron)", () => {
42
+ const tree = TestRenderer.create(
43
+ <ModuleNavigationAlt
44
+ title="With Badge"
45
+ onPress={onPress}
46
+ badge={{ text: "TEST", variant: "highlight" }}
47
+ icon="spid"
48
+ />
49
+ ).toJSON();
50
+ expect(tree).toMatchSnapshot();
51
+ });
52
+
53
+ it("With Image (no icon) + chevron (onPress)", () => {
54
+ const tree = TestRenderer.create(
55
+ <ModuleNavigationAlt
56
+ title="With Image"
57
+ image={{ uri: "https://example.com/icon.png" }}
58
+ onPress={onPress}
59
+ />
60
+ ).toJSON();
61
+ expect(tree).toMatchSnapshot();
62
+ });
63
+ });
64
+
65
+ describe("ModuleNavigationAlt - Snapshot (Experimental Enabled)", () => {
66
+ it("Loading state", () => {
67
+ const tree = TestRendererWithExperimentalEnabledContextProvider(
68
+ <ModuleNavigationAlt
69
+ isLoading
70
+ loadingAccessibilityLabel="loading items"
71
+ />
72
+ ).toJSON();
73
+ expect(tree).toMatchSnapshot();
74
+ });
75
+
76
+ it("Title only + chevron (onPress)", () => {
77
+ const tree = TestRendererWithExperimentalEnabledContextProvider(
78
+ <ModuleNavigationAlt title="My Title" onPress={onPress} icon="spid" />
79
+ ).toJSON();
80
+ expect(tree).toMatchSnapshot();
81
+ });
82
+
83
+ it("Title + Subtitle", () => {
84
+ const tree = TestRendererWithExperimentalEnabledContextProvider(
85
+ <ModuleNavigationAlt
86
+ title="My Title"
87
+ subtitle="A nice subtitle"
88
+ icon="spid"
89
+ />
90
+ ).toJSON();
91
+ expect(tree).toMatchSnapshot();
92
+ });
93
+
94
+ it("With Badge (badge + chevron)", () => {
95
+ const tree = TestRendererWithExperimentalEnabledContextProvider(
96
+ <ModuleNavigationAlt
97
+ title="With Badge"
98
+ onPress={onPress}
99
+ badge={{ text: "TEST", variant: "highlight" }}
100
+ icon="spid"
101
+ />
102
+ ).toJSON();
103
+ expect(tree).toMatchSnapshot();
104
+ });
105
+
106
+ it("With Image (no icon) + chevron (onPress) - Experimental", () => {
107
+ const tree = TestRendererWithExperimentalEnabledContextProvider(
108
+ <ModuleNavigationAlt
109
+ title="With Image"
110
+ image={{ uri: "https://example.com/icon.png" }}
111
+ onPress={onPress}
112
+ />
113
+ ).toJSON();
114
+ expect(tree).toMatchSnapshot();
115
+ });
116
+ });
@@ -0,0 +1,21 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`ModuleNavigationAlt - Snapshot (Experimental Enabled) Loading state 1`] = `null`;
4
+
5
+ exports[`ModuleNavigationAlt - Snapshot (Experimental Enabled) Title + Subtitle 1`] = `null`;
6
+
7
+ exports[`ModuleNavigationAlt - Snapshot (Experimental Enabled) Title only + chevron (onPress) 1`] = `null`;
8
+
9
+ exports[`ModuleNavigationAlt - Snapshot (Experimental Enabled) With Badge (badge + chevron) 1`] = `null`;
10
+
11
+ exports[`ModuleNavigationAlt - Snapshot (Experimental Enabled) With Image (no icon) + chevron (onPress) - Experimental 1`] = `null`;
12
+
13
+ exports[`ModuleNavigationAlt - Snapshot Loading state 1`] = `null`;
14
+
15
+ exports[`ModuleNavigationAlt - Snapshot Title + Subtitle 1`] = `null`;
16
+
17
+ exports[`ModuleNavigationAlt - Snapshot Title only + chevron (onPress) 1`] = `null`;
18
+
19
+ exports[`ModuleNavigationAlt - Snapshot With Badge (badge + chevron) 1`] = `null`;
20
+
21
+ exports[`ModuleNavigationAlt - Snapshot With Image (no icon) + chevron (onPress) 1`] = `null`;
@@ -3,6 +3,7 @@ export * from "./ModuleCheckout";
3
3
  export * from "./ModuleCredential";
4
4
  export * from "./ModuleIDP";
5
5
  export * from "./ModuleNavigation";
6
+ export * from "./ModuleNavigationAlt";
6
7
  export * from "./ModulePaymentNotice";
7
8
  export * from "./ModuleSummary";
8
9
  export * from "./PressableModuleBase";
@@ -0,0 +1 @@
1
+ <svg id="Layer_1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 143 69.9"><style>.st0{fill:#06C}</style><path id="XMLID_85_" class="st0" d="M29.8 25c-6.3-.8-10.8-1.2-13.3-1.2s-4.2.2-4.9.7c-.7.5-1.1 1.2-1.1 2.2 0 1 .5 1.7 1.5 2.1 1 .4 3.6.9 7.7 1.7 4.1.7 7.1 2 8.8 3.6 1.7 1.7 2.6 4.4 2.6 8.2 0 8.3-5.1 12.4-15.4 12.4-3.4 0-7.5-.5-12.3-1.4l-2.5-.5.3-8.6c6.3.8 10.8 1.2 13.2 1.2 2.5 0 4.2-.2 5.1-.7.9-.5 1.3-1.2 1.3-2.2 0-1-.5-1.7-1.4-2.1-.9-.5-3.4-1-7.4-1.7s-6.9-1.8-8.9-3.4C1.2 33.7.2 30.9.2 26.8s1.4-7.1 4.1-9.2c2.8-2.1 6.3-3.1 10.7-3.1 3 0 7.1.5 12.4 1.5l2.5.5-.1 8.5z"/><path id="XMLID_82_" class="st0" d="M55.4 23.7c-1.9 0-3.8.4-5.8 1.2l-.9.4v20.1c2.3.3 4.2.5 5.6.5 3 0 5-.9 6.1-2.6 1.1-1.7 1.7-4.7 1.7-8.9 0-7.2-2.2-10.7-6.7-10.7M38.5 69.9V15.4h10.2v2.1c3.3-2 6.2-3 8.8-3 5.2 0 9 1.6 11.4 4.6 2.5 3.1 3.7 8.4 3.7 15.8s-1.4 12.6-4.1 15.5c-2.7 2.9-7.2 4.3-13.4 4.3-1.7 0-3.5-.2-5.5-.5l-.9-.2v15.8H38.5z"/><path id="XMLID_79_" class="st0" d="M131.6 44.5l1.1-.2V24.1c-2.8-.5-5.3-.8-7.5-.8-4.1 0-6.2 3.7-6.2 11.1 0 4 .5 6.8 1.4 8.5.9 1.7 2.4 2.5 4.6 2.5s4.3-.2 6.6-.9M143 0v53.8h-10.2v-1.6c-3.6 1.7-6.7 2.5-9.3 2.5-5.6 0-9.5-1.6-11.7-4.8-2.2-3.2-3.3-8.3-3.3-15.3s1.3-12.1 4-15.3c2.6-3.2 6.6-4.8 11.9-4.8 1.6 0 3.9.3 6.8.8l1.5.3V0H143z"/><path id="XMLID_78_" class="st0" d="M90.5 37.7c-3.2 0-5.8-1.1-7.8-3.2s-3.1-4.8-3.1-8 1-5.8 3.1-7.9c2-2.1 4.6-3.1 7.8-3.1s5.8 1.1 7.7 3.2c2 2.2 3 4.8 3 8s-1 5.8-3 7.9c-2 2-4.5 3.1-7.7 3.1"/><path id="XMLID_77_" class="st0" d="M79.6 53.2c0-3.2 1-5.8 3.1-7.9 2-2.1 4.6-3.1 7.8-3.1s5.8 1.1 7.7 3.2c2 2.2 3 4.8 3 8"/></svg>
@@ -80,7 +80,9 @@ export const IOColors = asIOColors({
80
80
  "info-100": "#E1F5FE",
81
81
  "blueItalia-850": "#001F3D",
82
82
  "blueItalia-600": "#0052A3",
83
- "blueItalia-500": "#0066CC" /* pagoPA service */,
83
+ "blueItalia-500":
84
+ "#0066CC" /* Italian services, such as pagoPA, CieID, SpID, etc… */,
85
+ "blueItalia-300": "#4595E5",
84
86
  "blueItalia-100": "#C4DCF5",
85
87
  "blueItalia-50": "#DDEBFA"
86
88
  });
@@ -190,6 +192,7 @@ export const IOColorsExtra = {
190
192
  "blueItalia-850": IOColors["blueItalia-850"],
191
193
  "blueItalia-600": IOColors["blueItalia-600"],
192
194
  "blueItalia-500": IOColors["blueItalia-500"],
195
+ "blueItalia-300": IOColors["blueItalia-300"],
193
196
  "blueItalia-100": IOColors["blueItalia-100"],
194
197
  "blueItalia-50": IOColors["blueItalia-50"]
195
198
  };
@@ -217,6 +220,7 @@ const themeKeys = [
217
220
  "buttonText-danger",
218
221
  "buttonText-disabled",
219
222
  "listItem-pressed",
223
+ "italyBrand-default",
220
224
  // Typography
221
225
  "textHeading-default",
222
226
  "textHeading-secondary",
@@ -291,6 +295,7 @@ export const IOThemeLight: IOTheme = {
291
295
  "buttonText-danger": "white",
292
296
  "buttonText-disabled": "grey-700",
293
297
  "listItem-pressed": "grey-50",
298
+ "italyBrand-default": "blueItalia-500",
294
299
  // Typography
295
300
  "textHeading-default": "black",
296
301
  "textHeading-secondary": "grey-850",
@@ -360,6 +365,7 @@ export const IOThemeDark: IOTheme = {
360
365
  "buttonText-danger": "white",
361
366
  "buttonText-disabled": "grey-300",
362
367
  "listItem-pressed": "grey-900",
368
+ "italyBrand-default": "blueItalia-300",
363
369
  // Typography
364
370
  "textHeading-default": "white",
365
371
  "textHeading-secondary": "grey-300",