@pagopa/io-app-design-system 1.2.0 → 1.3.1
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/accordion/RawAccordion.js.map +1 -1
- package/lib/commonjs/components/alert/Alert.js.map +1 -1
- package/lib/commonjs/components/avatar/__test__/avatar.test.js.map +1 -1
- package/lib/commonjs/components/badge/Badge.js.map +1 -1
- package/lib/commonjs/components/banner/Banner.js +1 -1
- package/lib/commonjs/components/banner/Banner.js.map +1 -1
- package/lib/commonjs/components/banner/__test__/banner.test.js.map +1 -1
- package/lib/commonjs/components/buttons/ButtonExtendedOutline.js.map +1 -1
- package/lib/commonjs/components/buttons/ButtonOutline.js +3 -3
- package/lib/commonjs/components/buttons/ButtonOutline.js.map +1 -1
- package/lib/commonjs/components/buttons/ButtonSolid.js +3 -3
- package/lib/commonjs/components/buttons/ButtonSolid.js.map +1 -1
- package/lib/commonjs/components/contentWrapper/ContentWrapper.js.map +1 -1
- package/lib/commonjs/components/listitems/ListItemAction.js.map +1 -1
- package/lib/commonjs/components/listitems/ListItemIDP.js.map +1 -1
- package/lib/commonjs/components/listitems/ListItemNavAlert.js.map +1 -1
- package/lib/commonjs/components/listitems/ListItemTransaction.js.map +1 -1
- package/lib/commonjs/components/listitems/PressableListItemsBase.js.map +1 -1
- package/lib/commonjs/components/listitems/__test__/listitem.test.js.map +1 -1
- package/lib/commonjs/components/listitems/hooks/useListItemSpringAnimation.js.map +1 -1
- package/lib/commonjs/components/pictograms/Pictogram.js +7 -3
- package/lib/commonjs/components/pictograms/Pictogram.js.map +1 -1
- package/lib/commonjs/components/pictograms/svg/PictogramFocusOn.js +56 -0
- package/lib/commonjs/components/pictograms/svg/PictogramFocusOn.js.map +1 -0
- package/lib/commonjs/components/pictograms/svg/originals/PictogramFocusOn.svg +19 -0
- package/lib/commonjs/components/spacer/Spacer.js.map +1 -1
- package/lib/commonjs/components/typography/Body.js.map +1 -1
- package/lib/commonjs/components/typography/Factory.js.map +1 -1
- package/lib/commonjs/components/typography/H1.js.map +1 -1
- package/lib/commonjs/components/typography/H2.js.map +1 -1
- package/lib/commonjs/components/typography/H4.js.map +1 -1
- package/lib/commonjs/components/typography/H5.js.map +1 -1
- package/lib/commonjs/components/typography/H6.js.map +1 -1
- package/lib/commonjs/components/typography/Label.js.map +1 -1
- package/lib/commonjs/components/typography/LabelSmall.js.map +1 -1
- package/lib/commonjs/components/typography/Monospace.js.map +1 -1
- package/lib/commonjs/components/typography/common.js +2 -2
- package/lib/commonjs/components/typography/common.js.map +1 -1
- package/lib/commonjs/utils/image.js.map +1 -1
- package/lib/module/components/accordion/RawAccordion.js.map +1 -1
- package/lib/module/components/alert/Alert.js.map +1 -1
- package/lib/module/components/avatar/__test__/avatar.test.js.map +1 -1
- package/lib/module/components/badge/Badge.js.map +1 -1
- package/lib/module/components/banner/Banner.js +1 -1
- package/lib/module/components/banner/Banner.js.map +1 -1
- package/lib/module/components/banner/__test__/banner.test.js.map +1 -1
- package/lib/module/components/buttons/ButtonExtendedOutline.js.map +1 -1
- package/lib/module/components/buttons/ButtonOutline.js +3 -3
- package/lib/module/components/buttons/ButtonOutline.js.map +1 -1
- package/lib/module/components/buttons/ButtonSolid.js +3 -3
- package/lib/module/components/buttons/ButtonSolid.js.map +1 -1
- package/lib/module/components/buttons/IconButtonContained.js.map +1 -1
- package/lib/module/components/buttons/IconButtonSolid.js.map +1 -1
- package/lib/module/components/contentWrapper/ContentWrapper.js.map +1 -1
- package/lib/module/components/listitems/ListItemAction.js.map +1 -1
- package/lib/module/components/listitems/ListItemIDP.js.map +1 -1
- package/lib/module/components/listitems/ListItemNavAlert.js.map +1 -1
- package/lib/module/components/listitems/ListItemTransaction.js.map +1 -1
- package/lib/module/components/listitems/PressableListItemsBase.js.map +1 -1
- package/lib/module/components/listitems/__test__/listitem.test.js.map +1 -1
- package/lib/module/components/listitems/hooks/useListItemSpringAnimation.js.map +1 -1
- package/lib/module/components/pictograms/Pictogram.js +7 -3
- package/lib/module/components/pictograms/Pictogram.js.map +1 -1
- package/lib/module/components/pictograms/svg/PictogramFocusOn.js +48 -0
- package/lib/module/components/pictograms/svg/PictogramFocusOn.js.map +1 -0
- package/lib/module/components/pictograms/svg/originals/PictogramFocusOn.svg +19 -0
- package/lib/module/components/spacer/Spacer.js.map +1 -1
- package/lib/module/components/typography/Body.js.map +1 -1
- package/lib/module/components/typography/Factory.js.map +1 -1
- package/lib/module/components/typography/H1.js.map +1 -1
- package/lib/module/components/typography/H2.js.map +1 -1
- package/lib/module/components/typography/H4.js.map +1 -1
- package/lib/module/components/typography/H5.js.map +1 -1
- package/lib/module/components/typography/H6.js.map +1 -1
- package/lib/module/components/typography/Label.js.map +1 -1
- package/lib/module/components/typography/LabelSmall.js.map +1 -1
- package/lib/module/components/typography/Monospace.js.map +1 -1
- package/lib/module/components/typography/common.js +2 -2
- package/lib/module/components/typography/common.js.map +1 -1
- package/lib/module/utils/image.js.map +1 -1
- package/lib/typescript/components/alert/Alert.d.ts.map +1 -1
- package/lib/typescript/components/badge/Badge.d.ts.map +1 -1
- package/lib/typescript/components/banner/Banner.d.ts.map +1 -1
- package/lib/typescript/components/buttons/ButtonExtendedOutline.d.ts.map +1 -1
- package/lib/typescript/components/buttons/ButtonOutline.d.ts.map +1 -1
- package/lib/typescript/components/buttons/ButtonSolid.d.ts.map +1 -1
- package/lib/typescript/components/buttons/IconButtonContained.d.ts.map +1 -1
- package/lib/typescript/components/contentWrapper/ContentWrapper.d.ts.map +1 -1
- package/lib/typescript/components/listitems/ListItemAction.d.ts.map +1 -1
- package/lib/typescript/components/listitems/ListItemIDP.d.ts +1 -1
- package/lib/typescript/components/listitems/ListItemIDP.d.ts.map +1 -1
- package/lib/typescript/components/listitems/ListItemNavAlert.d.ts.map +1 -1
- package/lib/typescript/components/listitems/ListItemTransaction.d.ts.map +1 -1
- package/lib/typescript/components/listitems/PressableListItemsBase.d.ts.map +1 -1
- package/lib/typescript/components/listitems/hooks/useListItemSpringAnimation.d.ts.map +1 -1
- package/lib/typescript/components/pictograms/Pictogram.d.ts +2 -0
- package/lib/typescript/components/pictograms/Pictogram.d.ts.map +1 -1
- package/lib/typescript/components/pictograms/svg/PictogramFocusOn.d.ts +5 -0
- package/lib/typescript/components/pictograms/svg/PictogramFocusOn.d.ts.map +1 -0
- package/lib/typescript/components/spacer/Spacer.d.ts.map +1 -1
- package/lib/typescript/components/typography/Body.d.ts.map +1 -1
- package/lib/typescript/components/typography/Factory.d.ts.map +1 -1
- package/lib/typescript/components/typography/H1.d.ts.map +1 -1
- package/lib/typescript/components/typography/H2.d.ts.map +1 -1
- package/lib/typescript/components/typography/H4.d.ts.map +1 -1
- package/lib/typescript/components/typography/H5.d.ts.map +1 -1
- package/lib/typescript/components/typography/H6.d.ts.map +1 -1
- package/lib/typescript/components/typography/Label.d.ts.map +1 -1
- package/lib/typescript/components/typography/LabelSmall.d.ts.map +1 -1
- package/lib/typescript/components/typography/Monospace.d.ts.map +1 -1
- package/lib/typescript/components/typography/common.d.ts +2 -2
- package/lib/typescript/components/typography/common.d.ts.map +1 -1
- package/lib/typescript/utils/image.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/components/Advice/index.tsx +1 -1
- package/src/components/accordion/RawAccordion.tsx +3 -3
- package/src/components/alert/Alert.tsx +4 -1
- package/src/components/avatar/Avatar.tsx +1 -1
- package/src/components/avatar/__test__/avatar.test.tsx +7 -4
- package/src/components/avatar/index.tsx +1 -1
- package/src/components/badge/Badge.tsx +16 -11
- package/src/components/banner/Banner.tsx +206 -195
- package/src/components/banner/__test__/banner.test.tsx +11 -9
- package/src/components/banner/index.tsx +1 -1
- package/src/components/buttons/ButtonExtendedOutline.tsx +80 -80
- package/src/components/buttons/ButtonOutline.tsx +278 -280
- package/src/components/buttons/ButtonSolid.tsx +142 -141
- package/src/components/buttons/IconButtonContained.tsx +17 -17
- package/src/components/buttons/IconButtonSolid.tsx +11 -11
- package/src/components/contentWrapper/ContentWrapper.tsx +12 -12
- package/src/components/contentWrapper/index.tsx +1 -1
- package/src/components/divider/index.tsx +1 -1
- package/src/components/icons/index.tsx +1 -1
- package/src/components/listitems/ListItemAction.tsx +120 -119
- package/src/components/listitems/ListItemIDP.tsx +115 -115
- package/src/components/listitems/ListItemNavAlert.tsx +114 -110
- package/src/components/listitems/ListItemTransaction.tsx +2 -6
- package/src/components/listitems/PressableListItemsBase.tsx +29 -29
- package/src/components/listitems/__test__/listitem.test.tsx +53 -15
- package/src/components/listitems/hooks/useListItemSpringAnimation.ts +54 -52
- package/src/components/pictograms/Pictogram.tsx +6 -3
- package/src/components/pictograms/svg/PictogramFocusOn.tsx +39 -0
- package/src/components/pictograms/svg/originals/PictogramFocusOn.svg +19 -0
- package/src/components/spacer/Spacer.tsx +21 -18
- package/src/components/spacer/index.tsx +1 -1
- package/src/components/typography/Body.tsx +10 -10
- package/src/components/typography/Factory.tsx +38 -38
- package/src/components/typography/H1.tsx +19 -19
- package/src/components/typography/H2.tsx +19 -19
- package/src/components/typography/H4.tsx +12 -12
- package/src/components/typography/H5.tsx +24 -24
- package/src/components/typography/H6.tsx +10 -10
- package/src/components/typography/Label.tsx +16 -16
- package/src/components/typography/LabelSmall.tsx +27 -28
- package/src/components/typography/Monospace.tsx +14 -14
- package/src/components/typography/common.tsx +20 -20
- package/src/components/typography/index.tsx +0 -1
- package/src/index.tsx +0 -1
- package/src/json-import.d.ts +3 -4
- package/src/utils/dates.ts +1 -1
- package/src/utils/image.ts +22 -22
|
@@ -1,29 +1,40 @@
|
|
|
1
1
|
import React, { useCallback } from "react";
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
AccessibilityRole,
|
|
4
|
+
GestureResponderEvent,
|
|
5
|
+
Pressable,
|
|
6
|
+
StyleSheet,
|
|
7
|
+
View,
|
|
8
|
+
ViewStyle
|
|
9
9
|
} from "react-native";
|
|
10
10
|
import Animated, {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
Extrapolate,
|
|
12
|
+
interpolate,
|
|
13
|
+
useAnimatedStyle,
|
|
14
|
+
useDerivedValue,
|
|
15
|
+
useSharedValue,
|
|
16
|
+
withSpring
|
|
17
17
|
} from "react-native-reanimated";
|
|
18
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
IOBannerBigSpacing,
|
|
20
|
+
IOBannerRadius,
|
|
21
|
+
IOBannerSmallHSpacing,
|
|
22
|
+
IOBannerSmallVSpacing,
|
|
23
|
+
IOScaleValues,
|
|
24
|
+
IOSpringValues,
|
|
25
|
+
IOStyles
|
|
26
|
+
} from "../../core";
|
|
19
27
|
import { IOColors } from "../../core/IOColors";
|
|
20
28
|
import { WithTestID } from "../../utils/types";
|
|
21
29
|
import { ButtonLink, IconButton } from "../buttons";
|
|
22
|
-
import {
|
|
30
|
+
import {
|
|
31
|
+
IOPictogramSizeScale,
|
|
32
|
+
IOPictogramsBleed,
|
|
33
|
+
Pictogram
|
|
34
|
+
} from "../pictograms";
|
|
23
35
|
import { VSpacer } from "../spacer";
|
|
24
36
|
import { H6, LabelSmall } from "../typography";
|
|
25
37
|
|
|
26
|
-
|
|
27
38
|
/* Styles */
|
|
28
39
|
|
|
29
40
|
const colorTitle: IOColors = "blueIO-850";
|
|
@@ -38,42 +49,42 @@ const sizeSmallHPadding = IOBannerSmallHSpacing;
|
|
|
38
49
|
const sizeSmallVPadding = IOBannerSmallVSpacing;
|
|
39
50
|
|
|
40
51
|
const styles = StyleSheet.create({
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
container: {
|
|
53
|
+
flexDirection: "row",
|
|
54
|
+
alignItems: "flex-start",
|
|
55
|
+
alignContent: "center",
|
|
56
|
+
borderRadius: IOBannerRadius
|
|
57
|
+
},
|
|
58
|
+
bleedPictogram: {
|
|
59
|
+
marginRight: -sizeBigPadding
|
|
60
|
+
},
|
|
61
|
+
closeIconButton: {
|
|
62
|
+
position: "absolute",
|
|
63
|
+
right: closeButtonDistanceFromEdge,
|
|
64
|
+
top: closeButtonDistanceFromEdge,
|
|
65
|
+
opacity: closeButtonOpacity
|
|
66
|
+
}
|
|
56
67
|
});
|
|
57
68
|
|
|
58
69
|
const dynamicContainerStyles = (
|
|
59
|
-
|
|
60
|
-
|
|
70
|
+
size: BaseBannerProps["size"],
|
|
71
|
+
color: BaseBannerProps["color"]
|
|
61
72
|
): ViewStyle => ({
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
73
|
+
backgroundColor: IOColors[mapBackgroundColor[color]],
|
|
74
|
+
paddingVertical: size === "big" ? sizeBigPadding : sizeSmallVPadding,
|
|
75
|
+
paddingHorizontal: size === "big" ? sizeBigPadding : sizeSmallHPadding
|
|
65
76
|
});
|
|
66
77
|
|
|
67
78
|
/* Component Types */
|
|
68
79
|
|
|
69
80
|
type BaseBannerProps = WithTestID<{
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
81
|
+
size: "big" | "small";
|
|
82
|
+
color: "neutral" | "turquoise";
|
|
83
|
+
pictogramName: IOPictogramsBleed;
|
|
84
|
+
viewRef: React.RefObject<View>;
|
|
85
|
+
// A11y related props
|
|
86
|
+
accessibilityLabel?: string;
|
|
87
|
+
accessibilityHint?: string;
|
|
77
88
|
}>;
|
|
78
89
|
|
|
79
90
|
/* Description only */
|
|
@@ -84,194 +95,194 @@ type BannerPropsTitleOnly = { title?: string; content: never };
|
|
|
84
95
|
type BannerPropsTitleAndDesc = { title?: string; content?: string };
|
|
85
96
|
|
|
86
97
|
type RequiredBannerProps =
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
98
|
+
| BannerPropsDescOnly
|
|
99
|
+
| BannerPropsTitleOnly
|
|
100
|
+
| BannerPropsTitleAndDesc;
|
|
90
101
|
|
|
91
102
|
type BannerActionProps =
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
103
|
+
| {
|
|
104
|
+
action?: string;
|
|
105
|
+
onPress: (event: GestureResponderEvent) => void;
|
|
106
|
+
accessibilityRole?: never;
|
|
96
107
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
108
|
+
| {
|
|
109
|
+
action?: never;
|
|
110
|
+
onPress?: never;
|
|
111
|
+
accessibilityRole?: AccessibilityRole;
|
|
101
112
|
};
|
|
102
113
|
|
|
103
114
|
// Banner will display a close button if this event is provided
|
|
104
115
|
type BannerCloseProps =
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
116
|
+
| {
|
|
117
|
+
onClose?: (event: GestureResponderEvent) => void;
|
|
118
|
+
labelClose?: string;
|
|
108
119
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
120
|
+
| {
|
|
121
|
+
onClose?: never;
|
|
122
|
+
labelClose?: never;
|
|
112
123
|
};
|
|
113
124
|
|
|
114
125
|
export type Banner = BaseBannerProps &
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
126
|
+
RequiredBannerProps &
|
|
127
|
+
BannerActionProps &
|
|
128
|
+
BannerCloseProps;
|
|
118
129
|
|
|
119
130
|
// COMPONENT CONFIGURATION
|
|
120
131
|
|
|
121
132
|
/* Used to generate automatically the colour variants
|
|
122
133
|
in the Design System screen */
|
|
123
134
|
export const bannerBackgroundColours: Array<BaseBannerProps["color"]> = [
|
|
124
|
-
|
|
125
|
-
|
|
135
|
+
"neutral",
|
|
136
|
+
"turquoise"
|
|
126
137
|
];
|
|
127
138
|
|
|
128
139
|
const mapBackgroundColor: Record<
|
|
129
|
-
|
|
130
|
-
|
|
140
|
+
NonNullable<BaseBannerProps["color"]>,
|
|
141
|
+
IOColors
|
|
131
142
|
> = {
|
|
132
|
-
|
|
133
|
-
|
|
143
|
+
neutral: "grey-50",
|
|
144
|
+
turquoise: "turquoise-50"
|
|
134
145
|
};
|
|
135
146
|
|
|
136
147
|
export const Banner = ({
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
148
|
+
viewRef,
|
|
149
|
+
size,
|
|
150
|
+
color,
|
|
151
|
+
pictogramName,
|
|
152
|
+
title,
|
|
153
|
+
content,
|
|
154
|
+
action,
|
|
155
|
+
labelClose,
|
|
156
|
+
onPress,
|
|
157
|
+
onClose,
|
|
158
|
+
accessibilityHint,
|
|
159
|
+
accessibilityLabel,
|
|
160
|
+
testID
|
|
150
161
|
}: Banner) => {
|
|
151
|
-
|
|
162
|
+
const isPressed: Animated.SharedValue<number> = useSharedValue(0);
|
|
152
163
|
|
|
153
|
-
|
|
154
|
-
|
|
164
|
+
// Scaling transformation applied when the button is pressed
|
|
165
|
+
const animationScaleValue = IOScaleValues?.magnifiedButton?.pressedState;
|
|
155
166
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
167
|
+
// Using a spring-based animation for our interpolations
|
|
168
|
+
const progressPressed = useDerivedValue(() =>
|
|
169
|
+
withSpring(isPressed.value, IOSpringValues.button)
|
|
170
|
+
);
|
|
160
171
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
172
|
+
// Interpolate animation values from `isPressed` values
|
|
173
|
+
const pressedAnimationStyle = useAnimatedStyle(() => {
|
|
174
|
+
// Link color states to the pressed states
|
|
164
175
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
176
|
+
// Scale down button slightly when pressed
|
|
177
|
+
const scale = interpolate(
|
|
178
|
+
progressPressed.value,
|
|
179
|
+
[0, 1],
|
|
180
|
+
[1, animationScaleValue],
|
|
181
|
+
Extrapolate.CLAMP
|
|
182
|
+
);
|
|
172
183
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
184
|
+
return {
|
|
185
|
+
transform: [{ scale }]
|
|
186
|
+
};
|
|
187
|
+
});
|
|
177
188
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
189
|
+
const onPressIn = useCallback(() => {
|
|
190
|
+
// eslint-disable-next-line functional/immutable-data
|
|
191
|
+
isPressed.value = 1;
|
|
192
|
+
}, [isPressed]);
|
|
193
|
+
const onPressOut = useCallback(() => {
|
|
194
|
+
// eslint-disable-next-line functional/immutable-data
|
|
195
|
+
isPressed.value = 0;
|
|
196
|
+
}, [isPressed]);
|
|
186
197
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
198
|
+
const renderMainBlock = () => (
|
|
199
|
+
<>
|
|
200
|
+
<View style={[IOStyles.flex, IOStyles.selfCenter]}>
|
|
201
|
+
{title && (
|
|
202
|
+
<>
|
|
203
|
+
{/* Once we get 'gap' property, we can get rid of
|
|
193
204
|
these <VSpacer> components */}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
205
|
+
<H6 weight="SemiBold" color={colorTitle}>
|
|
206
|
+
{title}
|
|
207
|
+
</H6>
|
|
208
|
+
<VSpacer size={4} />
|
|
209
|
+
</>
|
|
210
|
+
)}
|
|
211
|
+
{content && (
|
|
212
|
+
<>
|
|
213
|
+
<LabelSmall color={colorContent} weight={"Regular"}>
|
|
214
|
+
{content}
|
|
215
|
+
</LabelSmall>
|
|
216
|
+
{action && <VSpacer size={8} />}
|
|
217
|
+
</>
|
|
218
|
+
)}
|
|
219
|
+
{action && (
|
|
220
|
+
/* Disable pointer events to avoid
|
|
210
221
|
pressed state on the button */
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
222
|
+
<View pointerEvents="none">
|
|
223
|
+
<VSpacer size={4} />
|
|
224
|
+
<ButtonLink color="primary" onPress={onPress} label={action} />
|
|
225
|
+
</View>
|
|
226
|
+
)}
|
|
227
|
+
</View>
|
|
228
|
+
<View style={[styles.bleedPictogram, IOStyles.selfCenter]}>
|
|
229
|
+
<Pictogram
|
|
230
|
+
name={pictogramName}
|
|
231
|
+
size={size === "big" ? sizePictogramBig : sizePictogramSmall}
|
|
232
|
+
/>
|
|
233
|
+
</View>
|
|
234
|
+
{onClose && labelClose && (
|
|
235
|
+
<View style={styles.closeIconButton}>
|
|
236
|
+
<IconButton
|
|
237
|
+
icon="closeSmall"
|
|
238
|
+
color={colorCloseButton}
|
|
239
|
+
onPress={onClose}
|
|
240
|
+
accessibilityLabel={labelClose}
|
|
241
|
+
/>
|
|
242
|
+
</View>
|
|
243
|
+
)}
|
|
244
|
+
</>
|
|
245
|
+
);
|
|
235
246
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
247
|
+
const PressableButton = () => (
|
|
248
|
+
<Pressable
|
|
249
|
+
ref={viewRef}
|
|
250
|
+
testID={testID}
|
|
251
|
+
onPress={onPress}
|
|
252
|
+
onPressIn={onPressIn}
|
|
253
|
+
onPressOut={onPressOut}
|
|
254
|
+
// A11y related props
|
|
255
|
+
accessible={true}
|
|
256
|
+
accessibilityLabel={accessibilityLabel}
|
|
257
|
+
accessibilityHint={accessibilityHint}
|
|
258
|
+
accessibilityRole={"button"}
|
|
259
|
+
>
|
|
260
|
+
<Animated.View
|
|
261
|
+
style={[
|
|
262
|
+
styles.container,
|
|
263
|
+
dynamicContainerStyles(size, color),
|
|
264
|
+
pressedAnimationStyle
|
|
265
|
+
]}
|
|
266
|
+
>
|
|
267
|
+
{renderMainBlock()}
|
|
268
|
+
</Animated.View>
|
|
269
|
+
</Pressable>
|
|
270
|
+
);
|
|
260
271
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
272
|
+
const StaticComponent = () => (
|
|
273
|
+
<View
|
|
274
|
+
ref={viewRef}
|
|
275
|
+
testID={testID}
|
|
276
|
+
style={[styles.container, dynamicContainerStyles(size, color)]}
|
|
277
|
+
// A11y related props
|
|
278
|
+
accessible={false}
|
|
279
|
+
accessibilityHint={accessibilityHint}
|
|
280
|
+
accessibilityLabel={accessibilityLabel}
|
|
281
|
+
accessibilityRole={"text"}
|
|
282
|
+
>
|
|
283
|
+
{renderMainBlock()}
|
|
284
|
+
</View>
|
|
285
|
+
);
|
|
275
286
|
|
|
276
|
-
|
|
287
|
+
return action ? <PressableButton /> : <StaticComponent />;
|
|
277
288
|
};
|
|
@@ -10,15 +10,17 @@ const onLinkPress = () => {
|
|
|
10
10
|
|
|
11
11
|
describe("Test Banner Components", () => {
|
|
12
12
|
it("Banner Snapshot", () => {
|
|
13
|
-
const advice = TestRenderer.create(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
const advice = TestRenderer.create(
|
|
14
|
+
<Banner
|
|
15
|
+
viewRef={viewRef}
|
|
16
|
+
color="neutral"
|
|
17
|
+
size="big"
|
|
18
|
+
title="Banner title"
|
|
19
|
+
pictogramName="donation"
|
|
20
|
+
action="Action text"
|
|
21
|
+
onPress={onLinkPress}
|
|
22
|
+
/>
|
|
23
|
+
).toJSON();
|
|
22
24
|
expect(advice).toMatchSnapshot();
|
|
23
25
|
});
|
|
24
26
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./Banner";
|
|
1
|
+
export * from "./Banner";
|