@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.
Files changed (47) hide show
  1. package/lib/commonjs/components/alert/Alert.js +34 -7
  2. package/lib/commonjs/components/alert/Alert.js.map +1 -1
  3. package/lib/commonjs/components/banner/Banner.js +45 -22
  4. package/lib/commonjs/components/banner/Banner.js.map +1 -1
  5. package/lib/commonjs/components/banner/__test__/__snapshots__/banner.test.tsx.snap +48 -190
  6. package/lib/commonjs/components/featureInfo/FeatureInfo.js +27 -26
  7. package/lib/commonjs/components/featureInfo/FeatureInfo.js.map +1 -1
  8. package/lib/commonjs/components/layout/index.js +0 -11
  9. package/lib/commonjs/components/layout/index.js.map +1 -1
  10. package/lib/commonjs/components/spacer/Spacer.js +1 -1
  11. package/lib/commonjs/components/spacer/Spacer.js.map +1 -1
  12. package/lib/commonjs/components/stack/Stack.js +17 -14
  13. package/lib/commonjs/components/stack/Stack.js.map +1 -1
  14. package/lib/commonjs/core/IOColors.js.map +1 -1
  15. package/lib/module/components/alert/Alert.js +36 -9
  16. package/lib/module/components/alert/Alert.js.map +1 -1
  17. package/lib/module/components/banner/Banner.js +50 -27
  18. package/lib/module/components/banner/Banner.js.map +1 -1
  19. package/lib/module/components/banner/__test__/__snapshots__/banner.test.tsx.snap +48 -190
  20. package/lib/module/components/featureInfo/FeatureInfo.js +29 -28
  21. package/lib/module/components/featureInfo/FeatureInfo.js.map +1 -1
  22. package/lib/module/components/layout/index.js +0 -1
  23. package/lib/module/components/layout/index.js.map +1 -1
  24. package/lib/module/components/spacer/Spacer.js +1 -1
  25. package/lib/module/components/spacer/Spacer.js.map +1 -1
  26. package/lib/module/components/stack/Stack.js +17 -14
  27. package/lib/module/components/stack/Stack.js.map +1 -1
  28. package/lib/module/core/IOColors.js.map +1 -1
  29. package/lib/typescript/components/alert/Alert.d.ts.map +1 -1
  30. package/lib/typescript/components/banner/Banner.d.ts.map +1 -1
  31. package/lib/typescript/components/featureInfo/FeatureInfo.d.ts.map +1 -1
  32. package/lib/typescript/components/layout/index.d.ts +0 -1
  33. package/lib/typescript/components/layout/index.d.ts.map +1 -1
  34. package/lib/typescript/components/spacer/Spacer.d.ts +0 -1
  35. package/lib/typescript/components/spacer/Spacer.d.ts.map +1 -1
  36. package/lib/typescript/components/stack/Stack.d.ts +9 -6
  37. package/lib/typescript/components/stack/Stack.d.ts.map +1 -1
  38. package/lib/typescript/core/IOColors.d.ts.map +1 -1
  39. package/package.json +1 -1
  40. package/src/components/alert/Alert.tsx +46 -15
  41. package/src/components/banner/Banner.tsx +64 -29
  42. package/src/components/banner/__test__/__snapshots__/banner.test.tsx.snap +48 -190
  43. package/src/components/featureInfo/FeatureInfo.tsx +26 -28
  44. package/src/components/layout/index.tsx +0 -1
  45. package/src/components/spacer/Spacer.tsx +2 -4
  46. package/src/components/stack/Stack.tsx +24 -16
  47. package/src/core/IOColors.ts +1 -0
@@ -9,9 +9,9 @@ import {
9
9
  IOPictograms,
10
10
  Icon,
11
11
  Pictogram,
12
- VSpacer
12
+ VStack
13
13
  } from "../../components";
14
- import { IOStyles } from "../../core";
14
+ import { IOStyles, useIOTheme } from "../../core";
15
15
 
16
16
  type PartialFeatureInfo = {
17
17
  // Necessary to render main body with different formatting
@@ -42,11 +42,7 @@ const DEFAULT_PICTOGRAM_SIZE: IOPictogramSizeScale = 48;
42
42
 
43
43
  const renderNode = (body: FeatureInfoProps["body"]) => {
44
44
  if (typeof body === "string") {
45
- return (
46
- <BodySmall color="grey-700" testID="infoScreenBody">
47
- {body}
48
- </BodySmall>
49
- );
45
+ return <BodySmall testID="infoScreenBody">{body}</BodySmall>;
50
46
  }
51
47
 
52
48
  return body;
@@ -57,23 +53,25 @@ export const FeatureInfo = ({
57
53
  pictogramName,
58
54
  body,
59
55
  action
60
- }: FeatureInfoProps) => (
61
- <View style={[IOStyles.flex, IOStyles.row, IOStyles.alignCenter]}>
62
- {iconName && (
63
- <Icon name={iconName} size={DEFAULT_ICON_SIZE} color="grey-300" />
64
- )}
65
- {pictogramName && (
66
- <Pictogram name={pictogramName} size={DEFAULT_PICTOGRAM_SIZE} />
67
- )}
68
- <HSpacer size={24} />
69
- <View style={{ flexShrink: 1 }}>
70
- {renderNode(body)}
71
- {action && (
72
- <>
73
- {/* Add "marginTop" equivalent if body text is present.
74
- This verbose code could be deleted once we got "gap"
75
- property support */}
76
- {body && <VSpacer size={4} />}
56
+ }: FeatureInfoProps) => {
57
+ const theme = useIOTheme();
58
+
59
+ return (
60
+ <View style={[IOStyles.flex, IOStyles.row, IOStyles.alignCenter]}>
61
+ {iconName && (
62
+ <Icon
63
+ name={iconName}
64
+ size={DEFAULT_ICON_SIZE}
65
+ color={theme["icon-decorative"]}
66
+ />
67
+ )}
68
+ {pictogramName && (
69
+ <Pictogram name={pictogramName} size={DEFAULT_PICTOGRAM_SIZE} />
70
+ )}
71
+ <HSpacer size={24} />
72
+ <VStack space={4} style={{ flexShrink: 1 }}>
73
+ {renderNode(body)}
74
+ {action && (
77
75
  <BodySmall
78
76
  weight="Semibold"
79
77
  asLink
@@ -84,8 +82,8 @@ export const FeatureInfo = ({
84
82
  >
85
83
  {action.label}
86
84
  </BodySmall>
87
- </>
88
- )}
85
+ )}
86
+ </VStack>
89
87
  </View>
90
- </View>
91
- );
88
+ );
89
+ };
@@ -1,4 +1,3 @@
1
- export * from "./BlockButtons";
2
1
  export * from "./FooterActions";
3
2
  export * from "./FooterActionsInline";
4
3
  export * from "./FooterWithButtons";
@@ -2,10 +2,8 @@ import React from "react";
2
2
  import { View } from "react-native";
3
3
  import { hexToRgba, IOColors, IOSpacer } from "../../core";
4
4
 
5
- export type SpacerOrientation = "vertical" | "horizontal";
6
-
7
5
  type BaseSpacerProps = {
8
- orientation: SpacerOrientation;
6
+ orientation: "vertical" | "horizontal";
9
7
  size: IOSpacer;
10
8
  };
11
9
 
@@ -21,7 +19,7 @@ const debugBg = hexToRgba(IOColors.red, 0.2);
21
19
 
22
20
  /**
23
21
  Native `Spacer` component
24
- @param {SpacerOrientation} orientation
22
+ @param {string} orientation
25
23
  @param {IOSpacer} size
26
24
  */
27
25
  const Spacer = ({ orientation, size }: BaseSpacerProps) => {
@@ -1,27 +1,36 @@
1
- import React, { ReactNode } from "react";
1
+ import React, { PropsWithChildren } from "react";
2
2
  import { View, ViewStyle } from "react-native";
3
3
  import { IOSpacer } from "../../core";
4
4
 
5
5
  type AllowedStyleProps = Pick<
6
6
  ViewStyle,
7
- "alignItems" | "flexShrink" | "flexGrow" | "flex" | "flexWrap"
7
+ "alignItems" | "flexShrink" | "flexGrow" | "flex" | "flexWrap" | "width"
8
8
  >;
9
9
 
10
- type Stack = {
10
+ type Stack = PropsWithChildren<{
11
11
  space?: IOSpacer;
12
- children: ReactNode;
13
12
  style?: AllowedStyleProps;
13
+ }>;
14
+
15
+ type BaseStack = Stack & {
16
+ orientation: "vertical" | "horizontal";
14
17
  };
15
18
 
16
19
  /**
17
20
  Horizontal Stack component
18
21
  @param {IOSpacer} space
19
22
  */
20
- export const HStack = ({ space, children, style }: Stack) => (
23
+
24
+ const Stack = ({
25
+ space,
26
+ style,
27
+ orientation = "vertical",
28
+ children
29
+ }: BaseStack) => (
21
30
  <View
22
31
  style={{
23
32
  display: "flex",
24
- flexDirection: "row",
33
+ flexDirection: orientation === "horizontal" ? "row" : "column",
25
34
  gap: space,
26
35
  ...style
27
36
  }}
@@ -30,20 +39,19 @@ export const HStack = ({ space, children, style }: Stack) => (
30
39
  </View>
31
40
  );
32
41
 
42
+ export const HStack = ({ children, ...props }: Stack) => (
43
+ <Stack orientation="horizontal" {...props}>
44
+ {children}
45
+ </Stack>
46
+ );
47
+
33
48
  /**
34
49
  Vertical Stack component
35
50
  @param {IOSpacer} space
36
51
  */
37
52
 
38
- export const VStack = ({ space, children, style }: Stack) => (
39
- <View
40
- style={{
41
- display: "flex",
42
- flexDirection: "column",
43
- gap: space,
44
- ...style
45
- }}
46
- >
53
+ export const VStack = ({ children, ...props }: Stack) => (
54
+ <Stack orientation="vertical" {...props}>
47
55
  {children}
48
- </View>
56
+ </Stack>
49
57
  );
@@ -233,6 +233,7 @@ export const IOColorsStatus = asIOColors({
233
233
  });
234
234
 
235
235
  export type IOColorsStatus = keyof typeof IOColorsStatus;
236
+
236
237
  export type IOColorsStatusForeground = Extract<
237
238
  IOColorsStatus,
238
239
  "error-850" | "warning-850" | "info-850" | "success-850"